I have a WCF web service hosted in a load balanced environment. I do not need any WCF session related functionality in the service.


What are the scenarios in which performances will be best if

  1. keepAliveEnabled = false

  2. keepAliveEnabled = true


From Load Balancing

By default, the BasicHttpBinding sends a connection HTTP header in messages with a Keep-Alive value, which enables clients to establish persistent connections to the services that support them. This configuration offers enhanced throughput because previously established connections can be reused to send subsequent messages to the same server. However, connection reuse may cause clients to become strongly associated to a specific server within the load-balanced farm, which reduces the effectiveness of round-robin load balancing. If this behavior is undesirable, HTTP Keep-Alive can be disabled on the server using the KeepAliveEnabled property with a CustomBinding or user-defined Binding.


Because you asked about performance:

keepAliveEnabled = false

For best performance, if your average latency is low, use this (though it probably won't make a huge difference).

keepAliveEnabled = true

For best performance, if your average latency is high, use this.


Keep-Alive tells the client that it can maintain the TCP connection the HTTP traffic is flowing over open, rather than opening and closing it per transport.

If you're in a load balanced environment you will not be able to have reliably 'sticky' sessions* / connections with a particular server. The chance is that on each transport the message will hit a different server in the environment.

Maintaining Keep-Alive means that you'll be maintaining a connection with every server the client hits. In a high-bandwidth low-latency scenario it's unnecessary as the overhead for a new connection is neglible.

*It's not so much related to sessions as those are handled differently (cookies on the client, a centralized store in the server cluster)

  • You wouldn't want to rely on keep-alives for making sure that you're hitting the same server to be able to access your session data. It will work most of the time, but if the client's connection drops out (eg on a mobile), on their next "hit" they might reach a different server. You need a better solution than just keep-alives. – Rocklan Jun 13 '13 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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