Document descriptor (file descriptors)
/etc/security/limits.conf
Here is the file descriptor limit that the current user allows to open, which can be ulimit -n
viewed.
Modify the configuration as follows:
* hard nofile 65536
root hard nofile 65536
* soft nofile 65536
root soft nofile 65536
Note: Root and * must be written, this *
represents a different account than root (the pit is correct)
Log off and re-login in effect.
Maximum number of connections (max connections)
/etc/sysctl.conf
Here you can set the system's total file descriptor limit (all users), as well as other TCP-related settings.
The maximum number of connections is net.core.somaxconn
that this parameter is inconsistent in different Linux cores, so you can set it two times and use a different upper limit.
fs.file-max=102400
net.ipv4.tcp_slow_start_after_idle = 0
net.core.somaxconn = 65535
net.ipv4.tcp_keepalive_time=300
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_no_metrics_save=1
net.core.somaxconn=262144
net.ipv4.tcp_max_orphans=262144
net.ipv4.tcp_synack_retries=2
net.ipv4.tcp_syn_retries=2
net.ipv4.tcp_syncookies=0
net.ipv4.tcp_max_syn_backlog=262144
net.core.wmem_max=16777216
net.core.rmem_max=16777216
net.ipv4.tcp_wmem=4096 4096 16777216
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_rmem=4096 4096 16777216
net.core.netdev_max_backlog=30000
net.ipv4.ip_local_port_range=5000 65535
net.ipv4.tcp_fin_timeout=30
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.netdev_max_backlog=16384
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_syncookies=1
After modification, the use sysctl -p
takes effect.
Note that after the above modifications are complete, many services must be restarted to take effect.
Common parameters modification of Linux Server