I'm currently having a socket leak with my Node.js application. This bug is also posted here. I hope to fix this soon. CLOSE_WAIT and FIN_WAIT2 seem to be the major problem.
Connections: 1662
ESTABLISHED: 238
CLOSE_WAIT: 770
FIN_WAIT1: 4
FIN_WAIT2: 632
The following data is retrieved by entering (alternatives like) this:
netstat -anp | grep ${node_pid} | wc -l
I've read that you can solve this by tuning these variables:
net.ipv4.tcp_fin_timeout ( = 60 )
net.ipv4.tcp_keepalive_time ( = 7200 )
Although my tcp_fin_timeout is set to 60 seconds, my sockets keep being there for more than 60 seconds. That's why I think I should tune the tcp_keepalive_time
.
It's hosted on a Linux Centos 5 server which is also running Apache and MySQL.
Can I easily decrease tcp_keepalive_time
to something like 1800, or will it have negative impacts on Apache, for example?