Troubleshooting Techniques
[ 212 ]
The next parameter to change is the size of the send and receive buffers. Note that
these values are for illustration purposes only— they may lead to excessive memory
usage, so be sure to test in your specific scenario.
- Linux
vi /etc/sysctl.conf
net.ipv4.tcp_wmem = 8192 87380 1048576
net.ipv4.tcp_rmem = 8192 87380 1048576
# sysctl -p /etc/sysctl.conf
- FreeBSD
vi /etc/sysctl.conf
net.inet.tcp.sendspace=1048576
net.inet.tcp.recvspace=1048576
# /etc/rc.d/sysctl reload
- Solaris
ndd -set /dev/tcp tcp_xmit_hiwat 1048576
ndd -set /dev/tcp tcp_recv_hiwat 1048576
You can also change these buffers in NGINX's configuration directly, so that they are
only valid for NGINX and not for any other software you are running on the machine.
This may be desirable when you have multiple services running, but want to ensure
that NGINX gets the most out of your network stack:
server {
listen 80 sndbuf=1m rcvbuf=1m;
}
Depending on your network setup, you will notice a marked change in performance.
You should examine your particular setup, though, and make one change at a time,
observing the results after each change. Performance tuning can be done on so many
different levels that this small treatment here does not do the subject justice. If you
are interested in learning more about performance tuning, there are a number of
books and online resources that you should take a look at.