Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to modify the number of TCP connections configuration

Shulou Source: shulou.com Published: 2022-06-02 06:59:34 09月21日 Update

Today, I will talk to you about how to modify the configuration of TCP connection number. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Usually, under the stress test, there are too many TCP short links, so you need to set up the system configuration.

The following configurations can be added to / etc/sysctl.conf as needed

Net.ipv4.tcp_syncookies = 1

# means to enable SYN Cookies. When a SYN waiting queue overflow occurs, enable cookies to deal with it to prevent a small number of SYN attacks. The default is 0, which means it is turned off.

Net.ipv4.tcp_tw_reuse = 1

# means to enable reuse. Allow TIME-WAIT sockets to be reused for new TCP connections. Default is 0, which means off.

Net.ipv4.tcp_tw_recycle = 1

# means to enable fast recycling of TIME-WAIT sockets in TCP connections. Default is 0, which means disabled.

Net.ipv4.tcp_fin_timeout = 30

# indicates that if the socket is closed by the local request, this parameter determines how long it remains in the FIN-WAIT-2 state.

Net.ipv4.tcp_keepalive_time = 1200

# indicates the frequency of keepalive messages sent by TCP when keepalive is used. The default is 2 hours, which changes to 20 minutes.

Net.ipv4.ip_local_port_range = 1024 65000

# represents the range of ports used for outbound connections. Small by default: 32768 to 61000, changed to 1024 to 65000.

Net.ipv4.tcp_max_tw_buckets = 5000

# indicates that the system maintains the maximum number of TIME_WAIT sockets at the same time, if this number is exceeded

The # TIME_WAIT socket will be cleared immediately and the warning message will be printed. The default is 180000, which changes to 5000.

# for servers such as Apache and Nginx, the parameters in the first few lines can well reduce the number of TIME_WAIT sockets

Typical modifications:

Modify the following two parameters to allow the sockets of TIME_WAIT status to be quickly recycled

Net.ipv4.tcp_tw_reuse=1

Net.ipv4.tcp_tw_recycle=1

Effective:

The following command can be configured with immediate effect

/ sbin/sysctl-p

After reading the above, do you have any further understanding of how to modify the configuration of the number of TCP connections? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Configuration sockets content parameters quantity status system maximum two information typical pressure simultaneous commands hours conditions numbers time time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL NVidia Apple MariaDB Linux