Nginx 反向代理Tomcat 高峰时报 connect() failed (110: Connection timed out) while connecting to upstream,
nginx-upstream-jvm-route
操作系统 :虚拟化的:Centos 5.5 cpu 8核 内存12g 硬盘100G
Nginx 1.0.10 tomcat6.0 和nginx-upstream-jvm-route
平峰一切OK 反应很快, 一到高峰期就很多connect() failed (110: Connection timed out) while connecting to upstream,
因为用的是Session 所以客户端就频繁报超时了。
配置文件如下:
worker_processes 8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
worker_rlimit_nofile 51200;
timer_resolution 2s; #此参数加上效果也不明显,1s都也试了
events {
use epoll;
worker_connections 51200;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 192;
client_header_buffer_size 64k;
large_client_header_buffers 8 64k;
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 0;
send_timeout 60;
keepalive_timeout 30;
client_body_buffer_size 512k;
proxy_connect_timeout 60;
proxy_read_timeout 120;
proxy_send_timeout 600;
proxy_buffer_size 64k;
proxy_buffers 8 128k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_types application/json text/plain application/x-javascript text/css application/xml;
gzip_vary on;
upstream jkda_server {
# tomcat http port and jvmroute name;
server 127.0.0.1:7080 weight=2 srun_id=jkda8009;
server 127.0.0.1:8810 weight=2 srun_id=jkda8019;
server 127.0.0.1:8820 weight=2 srun_id=jkda8029;
server 127.0.0.1:8830 weight=2 srun_id=jkda8039;
server 127.0.0.1:8840 weight=2 srun_id=jkda8049;
server 127.0.0.1:8850 weight=2 srun_id=jkda8059;
server 127.0.0.1:8860 weight=2 srun_id=jkda8069;
server 127.0.0.1:8870 weight=2 srun_id=jkda8079;
server 127.0.0.1:8880 weight=2 srun_id=jkda8089;
server 127.0.0.1:8890 weight=2 srun_id=jkda8099;
jvm_route $cookie_JSESSIONID|sessionid reverse;
}
server {
listen 80 default backlog=32768;
server_name localhost;
access_log off;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|htm)$
{
expires 30d;
}
location ~ .*\.(css)?$
{
expires 8h;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /jkda/{
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://jkda_server;
}
}
}
}
1、看看tomcat的 access log,看一下tomcat的处理时间。
2、看看tomcat系统的cpu load 与gc
如果cpu load gc比较高,就需要找出系统问题了。
cpu较高,找出cpu耗费较高的线程,top -H ,找出java 线程号,在结合jstack定位到代码。
gc比较频繁,看看gc内存设置,有没有优化空间。
总是这是一个系统的问题
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。