Nginx tuning concurrent testing
The figure shows the basic optimization idea, enabling more socket connections and opening more files.
1. From the perspective of opening the file
System level:
First use ulimit -n to see the default number of files that a process can open. Default is 128. ulimit -n 50000 Change the number of open files to 50000.
nginx level:
Configure worker_rlimit_nofile in nginx (there are some problems with the parameters in the figure) worker_rlimit_nofile 20000
2. From the angle of establishing sorket connection
System level:
The requested URL/proc/sys/net/core/somaxconn/was not found on this server.
The requested URL/proc/sys/net/ipv4/tcp_tw_recycle was not found on this server.
The requested URL/html/html/index.php was not found on this server.
The requested URL/proc/sys/net/ipv4/tcp/was not found on this server.
nginx level:
worker_connections 20000;
keepalive_timeout 0; Long connections need to be used with caution in high concurrency situations. will put more requests on hold.
Experimental environment: Take vmware to open a virtual machine 6g memory 20g hard disk 4 cores
Experimental results:
Before optimization, take ab test 3000 concurrency is OK, but more than 3000 concurrency has a large number of failures
After optimization, 10000 concurrent 0 failures 80% completed in one second