1

I have a server which sends thousands of requests in a minute. This is connected to a Nginx server. Nginx will upstream the requests to 4 servers as per the configuration settings below.

upstream cmdc {
server cmdc2b:5600 max_fails=3 fail_timeout=30s;
server cmdc2a:5600 max_fails=3 fail_timeout=30s;
server cmdc1d:5600 max_fails=3 fail_timeout=30s;
server cmdc1c:5600 max_fails=3 fail_timeout=30s;
keepalive 30;
}

What I can see from ELK is that almost 50% of requests go to cmdc2b and others are distributed among others. Does anyone suspect any other values which is causing the issue? I am listing my Nginx configuration below.

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
worker_rlimit_nofile 30000;
pid        /var/run/nginx.pid;


events {
    worker_connections  10240;
}


http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;


log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" cachestatus: $upstream_cache_status'
    'dest: $upstream_addr'
                  ' response_time: $request_time';

access_log  /var/log/nginx/access.log  main;
sendfile        off;
#tcp_nopush     on;

keepalive_timeout  65;
keepalive_requests 5000;
gzip  on;#page will be served using Nginx Gzip Module if requested by client
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
#error_page--configure the server's statuses when errors occur
proxy_cache_path /opt/nds/data/nginx/cache levels=1:2 keys_zone=cmdc_cache:10m max_size=11g loader_threshold=300 loader_files=200 inactive=5m;
proxy_cache_key "$scheme$request_method$host$request_uri";
include /etc/nginx/conf.d/cmdc.conf;
}

Can someone please put some light here?

1 Answer 1

0

Instead of relying on the default which is round robin you might find that you are looking for least connections instead:

upstream cmdc {
  least_conn;
  server cmdc2b:5600 max_fails=3 fail_timeout=30s;
  server cmdc2a:5600 max_fails=3 fail_timeout=30s;
  server cmdc1d:5600 max_fails=3 fail_timeout=30s;
  server cmdc1c:5600 max_fails=3 fail_timeout=30s;
  keepalive 30;
}

You may also want to apply weighting to the servers, see here for more info

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .