Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the number of TCP connections configuration

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report