There is a site, I use AB to do the pressure test, the result ab always return error, I did some of the following tuning, and finally normal.
Configuration of Nginx
. conf:
Worker_processes 32;
Worker_connections 65536;
Too much time_wait.
In the stress, many time_wait connection descriptors are found through Netstat:
netstat-n | awk '/^tcp/{++state[$NF]} end {for (key in state) print key , "\ t" , State[key ]} ' ss-ant | awk ' Nr>1 {++s[$1 ]} END {for (k in s) Print K,s[k]} "
After a network connection is disconnected, there is a 30-second time_wait time, which causes the connection to run out if the assembly is in parallel.
By looking at the/proc/sys/net/ipv4/ip_local_port_range you can know the port range of the configured Linux kernel auto-assigned port:
Shell> Cat/proc/sys/net/ipv4/ip_local_port_range
1025 65535
Solve:
/etc/sysctl.conf
Net.ipv4.tcp_tw_reuse = 1
Net.ipv4.tcp_tw_recycle = 1
The/sbin/sysctl-p is then executed to let the parameters take effect, allowing the connection to be reused and recycled.
DMESG Error
AB return apr_socket_recv:connection timed out (110)
Cause: DMESG View System error message displays a large number of nf_conntrack:table full, dropping packet, so you need to modify the parameters of this module.
Solve:
Vi/etc/sysctl.conf
Net.nf_conntrack_max = 655360
net.netfilter.nf_conntrack_tcp_timeout_established = 1200
Sysctl-p/etc/sysctl.conf
Tuning of Linux system parameters during stress testing