nginx performance tuning

/etc/security.limits.conf

www-data       soft    nofile  30000
www-data       hard    nofile  50000

ทดสอบผลลัพธ์โดย log out/log in แล้ว ulimit -Hn ; ulimit -Sn

/etc/nginx.conf

worker_processes auto;

# Increase open files
worker_rlimit_nofile 30000;

events {
        #worker_connections 2048;
        worker_connections 30000;
        # multi_accept on;
}

http {

...
        client_max_body_size 30m;


        proxy_connect_timeout 20;


        proxy_send_timeout          120;
        proxy_read_timeout          120;
        send_timeout                120;
...

        gzip on;
        gzip_disable "msie6";
        gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/json;
}

/etc/sysctl.conf

BOTH on the host and inside the container. And make sure there is sysctl -p /etc/sysctl.conf in the start up script of the container.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

net.core.somaxconn = 2048
fs.file-max = 70000

/etc/php/7.2/fpm/pool.d/www.conf

pm.max_children = 500

Leave a comment