Linux Improving file concurrency, enabling advanced algorithms hybla
Under Linux, we use the command ulimit -n to see the maximum number of file handles that can be opened by a single process (socket connections are included in this). The system default value is 1024. 1024 is perfectly adequate for general applications (like Apache, system processes). But how the single process, such as squid, mysql, java and other applications to deal with a large number of requests is a bit stretched. If the number of file handles open by a single process exceeds the system-defined value, the error "too many files open" will be mentioned. In order to handle more concurrent TCP connections, we should increase the limit of the maximum number of concurrently open files.
Increase the maximum number of concurrent files
Add two lines of text to limits.conf
echo '* soft nofile 51200 * hard nofile 51200' >> /etc/security/limits.conf
Then go ahead and set up ulimit.
ulimit -n 51200
Adjusting kernel parameters + enabling advanced algorithms hybl
Note: This step does not apply to OpenVZ or lower kernel versions, otherwise the last step sysctl -p will report a lot of errors, if not, it means that the kernel supports advanced algorithms such as hibla and other parameter adjustments.
Add some parameters to /etc/sysctl.conf
echo 'fs.file-max = 51200 net.core.rmem_max = 67108864 net.core.wmem_max = 67108864 net.core.netdev_max_backlog = 250000 net.core.somaxconn = 4096 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 0 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.ip_local_port_range = 10000 65000 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_max_tw_buckets = 5000 net.ipv4.tcp_fastopen = 3 net.ipv4.tcp_mem = 25600 51200 102400 net.ipv4.tcp_rmem = 4096 87380 67108864 net.ipv4.tcp_wmem = 4096 65536 67108864 net.ipv4.tcp_mtu_probing = 1 net.ipv4.tcp_congestion_control = hybla' >> /etc/sysctl.conf
Then run "sysctl -p" to reload the configuration.
If you are prompted with a message similar to the following, then your kernel does not support the feature or command that prompted the error
sysctl: cannot stat /proc/sys/net/ipv4/xxxxx: No such file or directory