How to fix the error «TCP: time wait bucket table overflow»?
How to fix the error “TCP: time wait bucket table overflow” ?
I was getting the following error in the “/var/log/messages” on my webserver.
1 2 3 4 5 | web1.myhost.com May 22 06:38:04 web1 kernel: TCP: time wait bucket table overflow web1.myhost.com May 22 06:38:04 web1 kernel: TCP: time wait bucket table overflow web1.myhost.com May 22 06:38:04 web1 kernel: TCP: time wait bucket table overflow |
This used to happen when the traffic on the server increased beyond 20k qps.
After googling for sometime, i found reason for this. This error was due to increased number of TIME_WAIT connections on the server. You can find more details of TIME_WAIT connections here
In order to fix this, i had to enable the following kernel parameters
1 2 | net.ipv4.tcp_tw_reuse net.ipv4.tcp_tw_recycle |
On a Centos Machine, you can do this by adding following lines in the /etc/sysctl.conf
1 2 | net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 |
Now run the following command , to load the changes we made
1 | sysctl –p |
Now you can verify the values by
1 2 3 4 | [root@testlocal ~]# sysctl -a |grep tcp_tw_re net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 [root@testlocal ~]# |
As you can see both “ipv4.tcp_tw_recycle” and “ipv4.tcp_tw_reuse” set to 1 now. I never seen those errors after making the above changes.