nginx slow problem at upstream,need help!

yzhzx nginx-forum at nginx.us
Mon Jan 11 14:01:00 MSK 2010


nginx upstream set 2 tomcat links:

upstream tomcats {
      server localhost:8080 max_fails=3 fail_timeout=3s;      
       server localhost:8081 max_fails=3 fail_timeout=3s;

    }
 server {
        listen       80 default;
        server_name  localhost;

        charset UTF-8;

	location / {
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass http://tomcats;

		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             client_max_body_size 50m;
             client_body_buffer_size 256k;
             proxy_connect_timeout 10;
             proxy_send_timeout 60;
             proxy_read_timeout 60;
             proxy_buffer_size 128k;
             proxy_buffers 8 128k;
             proxy_busy_buffers_size 128k;
             proxy_temp_file_write_size 128k;
		proxy_max_temp_file_size 128k;

		}
    }


at run ab.exe or webbench is slow,but the static html page is very fast.
static html page can run 9000 request/m,but upstream's 2tomcat is slow.

when i run 
ab -n 20000 -c 1000 http://192.168.0.242/CStar/LEAP/CStar/HTML/Login.html

visit has block  at:  http://192.168.0.242:80/CStar/LEAP/CStar/HTML/Login.html
visit tomcat is succeed at:  http://192.168.0.242:8081/CStar/LEAP/CStar/HTML/Login.html
                                        or   http://192.168.0.242:8082/CStar/LEAP/CStar/HTML/Login.html

some time visit 1 tomcat  has block,but the other one has succeed,always the nginx is block.

when the ab run end,the nginx some times is block little,some times is ok.

please help me.

the full config file:

user  tomcat tomcat;
worker_processes  2;
#worker_cpu_affinity 00000001 00000010;

error_log  /var/log/nginx/error.log  notice;

pid /var/run/nginx.pid;

worker_rlimit_nofile 2048;
events {
     use epoll;
    worker_connections  2048;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    source_charset UTF-8;
    server_names_hash_bucket_size 256;
    client_header_buffer_size 4k;
    large_client_header_buffers 4 4k;

	#open_file_cache max=65536 inactive=20s;

	  #size limits
         client_max_body_size             50m;
         client_body_buffer_size        256k;
         client_header_timeout     3m;
         client_body_timeout 3m;
         send_timeout             3m;
	
	#参数都有所调整.目的是解决代理过程中出现的一些502 499错误    
         sendfile on;
         tcp_nopush         on;
         keepalive_timeout 120; #参数加大,以解决做代理时502错误
         tcp_nodelay on;




    upstream tomcats {
      server localhost:8080 max_fails=3 fail_timeout=3s;      
       server localhost:8081 max_fails=3 fail_timeout=3s;

    }

    server {
        listen       80 default;
        server_name  localhost;

        charset UTF-8;

	location / {
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass http://tomcats;

		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             client_max_body_size 50m;
             client_body_buffer_size 256k;
             proxy_connect_timeout 10;
             proxy_send_timeout 60;
             proxy_read_timeout 60;
             proxy_buffer_size 128k;
             proxy_buffers 8 128k;
             proxy_busy_buffers_size 128k;
             proxy_temp_file_write_size 128k;
		proxy_max_temp_file_size 128k;

		}
    }

    server {
        listen       81;
        server_name  localhost;

        charset UTF-8;


        location / {
            root   /f/yumserver;
            index  index.html index.htm;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }



       
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,39701,39701#msg-39701




More information about the nginx mailing list