Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

You can use net.ipv4.tcp_fin_timeout kernel parameter:

# sysctl net.ipv4.tcp_fin_timeout=15

Edit /etc/sysctl.conf, add to end

net.ipv4.tcp_fin_timeout = 15

then run:

# sysctl -p
share|improve this answer
    
thanks for your help –  Akash Mar 2 '11 at 14:37
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.