NGINX loading page slow when requests increase

Hamid Gholami 045hamid at gmail.com
Wed May 13 11:50:00 UTC 2020


Hi to all,

I have a NGINX and configure it as load balancer (hash remote_IP) in front
of java application. When number of requests are normal all things good and
working fine but when requests go high NGINX has a delay to response to
each request. at this moment if I stop NGINX and requests straight to
application (java app and use tomcat as webserver) it works without delay
but when use NGINX it works with delay.

This is nginx.conf file:

user  root;
worker_processes  auto;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;

worker_rlimit_nofile 100000;
events {
    worker_connections  40000;
    #   use epoll;
    #    multi_accept on;
}


http {
error_log  /appserver/nginx/logs/error.log crit;
error_log  /appserver/nginx/logs/error.log emerg;
error_log  /appserver/nginx/logs/error.log error;
error_log  /appserver/nginx/logs/error.log alert;
error_log  /appserver/nginx/logs/debug.log debug;
error_log  /appserver/nginx/logs/warn.log warn;

include     mime.types;
default_type application/octet-stream;
fastcgi_read_timeout 100000;


        log_format netdata '$remote_addr - $remote_user [$time_local] '
                      '"$request" $status $body_bytes_sent '
                      '$request_length $request_time
$upstream_response_time $bytes_sent '
                      '"$http_referer" "$http_user_agent" $upstream_addr '
'request_time=$request_time '
               'upstream_response_time=$upstream_response_time '
               'upstream_connect_time=$upstream_connect_time '
               'upstream_header_time=$upstream_header_time '
                '$msec';

        access_log /appserver/nginx/logs/access.log netdata;

    client_body_buffer_size 256k;
    client_header_buffer_size 256k;
    subrequest_output_buffer_size 128k;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    client_max_body_size 100M;
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    access_log      on;
    keepalive_timeout 600;
    client_body_timeout 600;
    client_header_timeout 600;
    send_timeout 10;
    reset_timedout_connection on;
    gzip  on;
    gzip_min_length 10240;
    gzip_comp_level 1;
    gzip_vary on;
    gzip_disable msie6;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types
text/css
        text/javascript
        text/xml
        text/plain
        text/x-component
        application/javascript
        application/x-javascript
        application/json
        application/xml
        application/rss+xml
        application/atom+xml
        font/truetype
        font/opentype
        application/vnd.ms-fontobject
        image/svg+xml;

    upstream nginxBRANCH21 {
        server x.x.x.21:448  max_fails=1      fail_timeout=15s;
    }
    upstream nginxBRANCH {
        #server x.x.x.x:443  max_fails=1      fail_timeout=15s;
        #server x.x.x.x:448  max_fails=1      fail_timeout=15s;
        server x.x.x.x:448  max_fails=1      fail_timeout=15s;
        server x.x.x.x:443  max_fails=1      fail_timeout=15s;
        server x.x.x.x:443  max_fails=1      fail_timeout=15s;
        server x.x.x.x:443  max_fails=1      fail_timeout=15s;
        server x.x.x.x:443  max_fails=1      fail_timeout=15s;
        server x.x.x.x:443   max_fails=1      fail_timeout=15s;
        hash $remote_addr;
}
     upstream server150 {
           server x.x.x.x:443  max_fails=1      fail_timeout=15s;
     }
     upstream nginx_Z {
           server x.x.x.x:448  max_fails=1      fail_timeout=15s;
     }

     server {
        listen 80 default_server;
        server_name _;
        return 301 https://$host$request_uri;
     }


        server {
        listen           443  ssl;
        ssl_protocols        TLSv1 TLSv1.1 TLSv1.2;
      # ssl    on;
        ssl_certificate      /etc/ssl/certs/myssl.crt;
        ssl_certificate_key  /etc/ssl/private/myssl.key;

        location / {
            #if ( $remote_addr ~
"(x.x.x.x)|(x.x.x.x)|(x.x.x.x)|(x.x.x.x)|(x.x.x.x)|(x.x.x.x)|(x.x.x.x)|(x.x.x.x)|(x.x.x.x)"
){
            #   proxy_pass   https://server150;
            #}
            proxy_pass          https://nginxBRANCH21;
            proxy_set_header    X-Real-IP $remote_addr;
            proxy_set_header    Host $http_host;
            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header    X-NginX-Proxy true;
            proxy_set_header    X_FORWARDED_PROTO https;
            proxy_read_timeout     100000;
            proxy_connect_timeout  100000;
        }

        location /FCBZ {
            proxy_pass          https://nginx_Z;
            proxy_set_header    X-Real-IP $remote_addr;
            proxy_set_header    Host $http_host;
            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header    X-NginX-Proxy true;
            proxy_set_header    X_FORWARDED_PROTO https;
            proxy_read_timeout     100000;
            proxy_connect_timeout  100000;
        }


        }



server {
   listen 9666;
     location /basic_status {
        stub_status;
}

    }
}


Can anyone help me?
Thank you

-- 
<https://www.yourcompany.com/>
Hamid Gholami DevOps Engineer

* t: *+982191002809
 *m:* +989126105157*Linkedin
<https://www.linkedin.com/in/hamid-gholami/> , Twitter
<https://twitter.com/HamidGholami6> , Telegram <https://t.me/hamid045>*
<https://www.honeybook.com/email-signature>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20200513/1da7d696/attachment-0001.htm>


More information about the nginx mailing list