开发者社区> 问答> 正文

Nginx 反向代理Tomcat 高峰时报 connect() failed (110: Connection timed out)

落地花开啦 2016-05-30 11:16:35 7587

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;
        }
    }
} 
}
XML JSON 前端开发 应用服务中间件 Linux nginx 虚拟化 数据格式
分享到
取消 提交回答
全部回答(2)
  • cyy_buaa
    2019-07-17 19:19:22

    1、看看tomcat的 access log,看一下tomcat的处理时间。
    2、看看tomcat系统的cpu load 与gc

    如果cpu load gc比较高,就需要找出系统问题了。
     cpu较高,找出cpu耗费较高的线程,top -H ,找出java 线程号,在结合jstack定位到代码。
     gc比较频繁,看看gc内存设置,有没有优化空间。

    总是这是一个系统的问题

    0 0
  • 落地花开啦
    2019-07-17 19:19:22

    问题还是出在你的应用程序性能上,或者你试试高峰期直接访问 tomcat 看看。

    0 0
添加回答

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程