I have a ajax application that makes a request every 3 seconds, the requested page sets the header to (header("Connection: Keep-Alive, close");) then performs a database query and returns the latest data.
The value for TIME_WAIT is 60 seconds, so even tough I close the connection in my requested page(i.e "Connection: Keep-Alive, close"), the connection seem to be present for the next 60 seconds (this occurs for every Ajax request that I make), so for 1 minute 20 requests are made and total TIME_WAIT for that IP seems to be around 20
Is it possible to reduce the TIME_WAIT to say 15 seconds, to reduce the overall TIME_WAITS or is it possible to force a connection close after every Ajax request
Any help will be appreciated
Thanks
You can use net.ipv4.tcp_fin_timeout kernel parameter:
Edit /etc/sysctl.conf, add to end
then run:
Connection: keep-alive, close
is not valid HTTP 1.1, as exactly one connection-token is allowed, so I'd expect this header to be ignored and keep-alive to be active nonetheless; in HTTP 1.0, the "Connection" tag means something completely different.There should be no technical difference whether the connection is "recycled" or not, and you should leave that choice to the browser. Playing with FIN timeouts is almost never a good idea.