I have a rest service that sends requests to an IIS7 web server that is hosting an ASP.net MVC app. I'm presently allowing persistent connections so that many requests can be sent without taking up too many client ports and for performance reasons. However, I don't want the connection to stay open long at all. The reason I don't want a long lived connection is so that new connections can go through load balancers and end up on a new server.
I've looked around on how to configure the time of a connection timeout, and have it set within IIS on the application to timeout at 5 seconds. However using Wireshark (a packet monitoring tool), I found that the server is disconnecting anywhere from 7-19 seconds instead of the 5 seconds. Is setting it that low not reliable?
Also are there any consequences to setting it to a low number? For example, where the request or response might be large, or the processing on the server may take a longer period of time to process.
Last question is, is there a way to set a connection timeout within the web.config instead of relying on IIS settings?