Here are some Linux kernel tuning tips for handling high traffic (large number of tcp connections) on your Linux server, You can also use these configurations to improve apache ab or siege benchmark results (requests per second).
Where to add these parameters?
All parameters must be appended to the file :
/etc/sysctl.conf
How to apply These Parameters?
You can apply these parameters without rebooting server using command:
sudo sysctl -p
On The Server Side
net.core.somaxconn
net.core.somaxconn: This parameter allows you to set the maximum number of requests queued to a listen socket. You can change it up from the default value of 128 to 1024.
net.core.somaxconn=1024
net.core.netdev_max_backlog & net.ipv4.tcp_max_syn_backlog
net.core.netdev_max_backlog & net.ipv4.tcp_max_syn_backlog: This parameter sets the Maximum number of remembered connection requests, which did not yet received an acknowledgment from connecting client.
sysctl net.core.netdev_max_backlog=2000
sysctl net.ipv4.tcp_max_syn_backlog=2048
fs.file-max
fs.file-max :This parameter sets the number of open file handles and inode cache
fs.file-max = 1000000
On The Client Side (Benchmark tool)
net.ipv4.ip_local_port_range
net.ipv4.ip_local_port_range : This parameter allows you to set the ephemeral port range. Note: When changing this value make sure you don’t have any services running in given range
net.ipv4.ip_local_port_range = 12000 65535
net.ipv4.tcp_fin_timeout
net.ipv4.tcp_fin_timeout: This parameter defines the minimum time these sockets will stay in TIME_WAIT state
net.ipv4.tcp_fin_timeout = 60
tcp_tw_recycle & tcp_tw_reuse
tcp_tw_recycle & tcp_tw_reuse: These parameters allow you to reuse the sockets in wait state
sysctl net.ipv4.tcp_tw_recycle=1
sysctl net.ipv4.tcp_tw_reuse=1
fs.file-max
fs.file-max :This parameter sets the number of open file handles and inode cache
fs.file-max = 1000000
0 Comments