Compactar tráfego entre o balanceador de carga uwsgi-nginx e nginx

1

Eu tenho 7 servidores web nginx executando um aplicativo python e servindo-o no nginx via uwsgi e um arquivo de soquete, em frente a esses 7 servidores Web existe um balanceador de carga nginx, o tráfego que sai do balanceador de carga para o público é compactado corretamente resultando em apenas ~ 20Mbps de tráfego de saída, no entanto o tráfego que sai dos servidores da Web e do balanceador de carga por algum motivo não é comprimido resultando no balanceador de carga ter um tráfego total de entrada de 400Mbps e cada um dos servidores da web para ter cerca de 70 Mbps de tráfego de saída.

A compressão gzip deve ser ativada da mesma forma que foi ativada no balanceador de laod (onde funciona)? é alguma configuração diferente aqui?

Servidores da Web nginx.conf:

user xxx;
worker_rlimit_nofile 99999;
worker_processes  16;

events {
    worker_connections 65535;
}
http {
    proxy_cache_path  /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
    proxy_temp_path /tmp;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 620;
        keepalive_requests 20000;
#   types_hash_max_size 2048;
    client_max_body_size 200m;

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

    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_prefer_server_ciphers on;

    proxy_buffer_size   128k; 
    proxy_buffers   16 256k;
    proxy_busy_buffers_size   256k;
    uwsgi_buffer_size 128k;
    uwsgi_buffers 16 256k;
    uwsgi_busy_buffers_size 256k;
#   uwsgi_param UWSGI_SCHEME https;
#   uwsgi_param HTTPS on;

    #log info
    log_format  main  '[$time_local] - $remote_addr - $request_time - $remote_user - $upstream_addr - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $http_cookie';
    log_format  body  '[$time_local] - $remote_addr - $request_time - $remote_user - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $request_body $http_cookie';

    access_log off;
    #access_log /home/xxx/log/ng_access.log;
    error_log /home/xxx/log/ng_error.log;

    gzip on;
    gzip_disable "msie6";
        gzip_comp_level 4;
        gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    open_file_cache          max=8000 inactive=60s;
    open_file_cache_valid    120s;
    open_file_cache_min_uses 2;
    open_file_cache_errors   off;
    #uwsgi_buffering  off;

    #the cdn server, listening on port 83
    include /etc/nginx/conf.d/cdn.conf;

    #the xxx app, listening on port 81
    include /etc/nginx/conf.d/xxx.conf;

    #the dealers app, listening on port 82
    include /etc/nginx/conf.d/dealers.conf;

    #a fallback server listening on port 80, it acts as a local "load balancer" in case that we need to use this server without
    #a load balancer
    include /etc/nginx/conflb.d/http_upstreams.conf;
    include /etc/nginx/conflb.d/xxx.conf;
    include /etc/nginx/conflb.d/dealers.conf;
    include /etc/nginx/conflb.d/es.conf;
    include /etc/nginx/conflb.d/db.conf;

}

Balanceador de carga nginx.conf:

user nginx;
worker_rlimit_nofile 99999;
worker_processes  15;
pid /run/nginx.pid;
events {
    worker_connections  65535;
}
http {

    include /etc/nginx/conf.d/http_upstreams.conf;

        sendfile        on;
        proxy_busy_buffers_size 128k;
        proxy_buffer_size 64k;
        proxy_buffers 4 64k;
        #proxy_max_temp_file_size 0;
        keepalive_timeout  620;
        gzip  on;
        gzip_comp_level 4;
        gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
        include       mime.types;
        default_type  application/octet-stream;
    client_max_body_size 200m;
    #log info
    log_format  main  '[$time_local] - $remote_addr - $request_time - $remote_user - $upstream_addr - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $http_cookie';
    log_format  body  '[$time_local] - $remote_addr - $request_time - $remote_user - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $request_body $http_cookie';

        access_log  /var/log/nginx/access.log  main;

    real_ip_header CF-Connecting-IP;


        include /etc/nginx/conf.d/db1.conf;
    include /etc/nginx/conf.d/db2.conf;   
        include /etc/nginx/conf.d/es.conf;
    include /etc/nginx/conf.d/st.conf;
    include /etc/nginx/conf.d/xxx.conf;
    include /etc/nginx/conf.d/dealers.conf;

    #catch all server
    server {
        listen 80 default_server;
        rewrite ^(.*) http://www.xxx.gr$1 permanent;
    }
}
    
por SteveL 02.02.2017 / 11:36

1 resposta

1

Hey man use compactação gzip assim

    gzip on;
    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 image/gif image/jpeg application/atom+xml application/rss+xml text/x-component image/png image/tiff image/vnd.wap.wbmp image/x-icon image/x-jng image/x-ms-bmp image/svg+xml image/webp application/font-woff application/msword application/pdf;
    gzip_buffers 16 8k;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    
por 02.02.2017 / 14:11