alibaba / tengine

A distribution of Nginx with some advanced features
https://tengine.taobao.org
BSD 2-Clause "Simplified" License
12.84k stars 2.52k forks source link

NGINX Configuration to Boost Performance #1964

Open fero-majeeth opened 4 weeks ago

fero-majeeth commented 4 weeks ago

Hi Team,

I tested the scenario (proxy termination case, downstream is HTTPS and upstream is HTTP) with a 64KB file using the OpenSSL engine and observed that the throughput is very low for small files (64KB). I have attached the proxy and backend server configurations. Please review the configurations and guide me if any additional configurations are needed to boost performance.

For single process NGINX, I am getting 0.11 GBPS with 256 TPS.

OpenSSL version: 1.1.1q NGINX version: release-1.22.0

Proxy configuration:

events { use epoll; worker_connections 65536; multi_accept on; accept_mutex off; }

http { keepalive_timeout 300s; connection_pool_size 1024; keepalive_requests 1000000; access_log off;

    upstream backend {
        server 17.0.0.5:8000;

        keepalive 32;
        keepalive_requests 1000;
        keepalive_time 1h;
        keepalive_timeout 60s;
    }

    server {
            listen 443 ssl default_server;
            ssl_certificate /etc/nginx/certs/server.crt.pem;
            ssl_certificate_key /etc/nginx/certs/server.key.pem;
            ssl_client_certificate /etc/nginx/certs/RootCA.crt.pem;
            ssl_asynch on;
            ssl_max_pipelines 8;
            root /var/www/html;
            gzip on;
            gzip_types text/plain text/css;
            gzip_min_length 20;
            gzip_comp_level 5;
            gzip_vary on;
            gunzip on;

            ssl_session_tickets on;
            ssl_session_cache shared:SSL:10m;

            index index.html index.htm index.nginx-debian.html;
            server_name _;
            location / {
               proxy_pass http://backend;
               proxy_max_temp_file_size 0;
               proxy_http_version 1.1;
               proxy_set_header Connection "";
             }
    }

}

Backend Server:

events { use epoll; worker_connections 65536; multi_accept on; accept_mutex off; }

http { keepalive_timeout 300s; connection_pool_size 1024; keepalive_requests 1000000; access_log off; server { listen 8000 default_server; root /var/www/html; index index.html index.htm index.nginx-debian.html; servername ; location / { try_files $uri $uri/ =404; } } }

drawing commented 1 week ago

@fero-majeeth During the stress test, check the CPU consumption of the tengine process. It is possible that gzip compression consumes more CPU and the CPU is fully utilized.