I would like to know the low level details of how a network load balancer works with sticky session enabled.

Reason behind the question:

We have a legacy ASP.NET application that is both a front-end application and a REST service.


  1. https://somedomain.com/legacyapp/UI.aspx
  2. https://somedomain.com/legacyapp/Service.aspx

No. 1 is a no-login page but stateful. No. 2 is a service endpoint receiving an XML payload via HTTP POST

There are 2 instances of legacyapp behind the load balancer.

The load balancer has session affinity enabled. We noticed an unequal distribution of load. For each client there are lots of calls to the service endpoint (No. 2). We would want to leverage load balancing for No. 2. However, due to the session affinity being enabled, it's ignoring load balancing i.e. routing traffic to a single instance where a session was established initially.

  • Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask
    – gnat
    Jun 9, 2015 at 20:12

1 Answer 1


That's one of those "it depends" questions. I am going to mostly discuss web server balancing here.

Some do it by creating a hash of some pertinent information (client IP, target server IP and/or URL; map this to one of N backends).

Some do it by taking any un-allocated incoming session and send it to an arbitrary backend, then that backend sets a cookie of some sort (I'll call that an "affinity cookie"). If the cookie is set, the session is sent preferentially to that backend. If that backend is no longer alive, one of two things happen. Either it picks a new backend (and a new affinity cookie is set) or the session is terminated.

  • Thanks a lot for the information Valtine. I'm looking for ways to defeat the session affinity. We have a legacy application that is both a front-end application and a service endpoint. I would like the service endpoint to be "stateless" so that load balancing will be leveraged. From your answer, I figured that I can't simply force the session of the service piece to expire.
    – setzamora
    Jun 9, 2015 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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