Chapter 8
[ 211 ]
Performance problems
When designing an application and configuring NGINX to deliver it, we expect it to
perform well. When we experience performance problems, however, we need to take a
look at what could cause them. It may be in the application itself. It may be our NGINX
configuration. We will investigate how to discover where the problem lies.
When proxying, NGINX does most of its work over the network. If there are any
limitations at the network level, NGINX cannot perform optimally. Network tuning
is again specific to the operating system and network that you are running NGINX
on, so these tuning parameters should be examined in your particular situation.
One of the most important values relating to network performance is the size of the
listen queue for new TCP connections. This number should be increased to enable
more clients. Exactly how to do this and what value to use depends on the operating
system and optimization goal.
- Linux
vi /etc/sysctl.conf
net.core.somaxconn = 3240000
# sysctl -p /etc/sysctl.conf
- FreeBSD
vi /etc/sysctl.conf
kern.ipc.somaxconn=4096
# /etc/rc.d/sysctl reload
- Solaris
ndd -set /dev/tcp tcp_conn_req_max_q 1024
ndd -set /dev/tcp tcp_conn_req_max_q0 4096