This topic describes the causes of and solution to the following issue: A large number of "TCP: time wait bucket table overflow" error messages appear in the /var/log/messages file of a Linux Elastic Compute Service (ECS) instance.
Problem description
A large number of "TCP: time wait bucket table overflow" error messages appear in the /var/log/messages file of a Linux ECS instance.
Cause
A large number of TCP connections enter the TIME-WAIT state on the ECS instance, which exceeds the upper limit defined by the net.ipv4.tcp_max_tw_buckets (or tcp_max_tw_buckets) kernel parameter.
tcp_max_tw_buckets: indicates the maximum number of supported TCP sockets in the TIME_WAIT state. If the maximum number is exceeded, the system stops excess sockets in the TIME_WAIT state and generates the "TCP: time wait bucket table overflow" error message.
net.ipv4.tcp_max_tw_buckets: has the same function as the tcp_max_tw_buckets parameter and is used to defend against simple DDoS attacks. Do not decrease the value of this parameter unless your business requires a smaller value. If you require a value greater than the default value based on your network conditions, increase the value of the net.ipv4.tcp_max_tw_buckets parameter or the memory size.
Solution
To resolve the preceding issue, increase the value of the net.ipv4.tcp_max_tw_buckets parameter.
Connect to the Linux ECS instance.
For more information, see Connection method overview.
Change the value of the
net.ipv4.tcp_max_tw_bucketsparameter.Run the following command to open the
sysctl.conffile:vim /etc/sysctl.confPress the
Ikey to enter Insert mode.Increase the value of the
net.ipv4.tcp_max_tw_bucketsparameter based on your business requirements.In this example, change the value of the
net.ipv4.tcp_max_tw_bucketsparameter to 20000.net.ipv4.tcp_max_tw_buckets = 20000Press the
Esckey, enter:wq, and then press the Enter key to save and exit the file.Run the following command to allow the change to take effect:
sysctl -p
Run the following command to query connection statistics:
netstat -an | grep 80 | awk '{print $6}' | sort | uniq -c | sort -rn