0

It would be a great help if you can clarify on this please.

When am using a load balancer and I bind a server with a client with say either appsession or any other means. However if that server goes down then the load balancer redirects the client to another server and while doing so, the whole session is lost. So do i have to write my application in such a way that it stores session data externally so that it can be shared?

So how good is using a load balancer when a transaction fails halfway because the server goes unresponsive?

Please let me know, thanks.

Neo
  • 49
  • 12

1 Answers1

3

There is a difference between the 2 concepts: session stickiness and session replication.

  • Session stickiness gives you an assurance that once a request from a client reaches a healthy server, subsequent requests from the same client will be handled by that server. When your server goes down, the stickiness is lost, and new requests go to a different healthy server. Session stickiness is usually offered by the load balancer and your application servers generally do not need to do anything.
  • Session replication gives you the capability of recovering the session when a server goes down. In the above case, stickiness is lost, but the new server will be able to recover the previous session based on an external session storage, which you will have to implement.
duyvh
  • 419
  • 3
  • 5
  • Thank you. So as per your first point, at some point if the request is forwarded to a different server, the load balancer will also restore the session variables? – Neo Jun 23 '21 at 07:50
  • no, load balancer doesn't restore anything related to the session, in the case of AWS Elastic Load Balancer, it uses a special cookie in the request to support session stickiness. Ref: https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html – duyvh Jun 23 '21 at 08:49
  • Ok. I think this line of yours got me carried away ** Session stickiness is usually offered by the load balancer and your application servers generally do not need to do anything.** – Neo Jun 23 '21 at 09:13
  • what I meant is if you need session stickiness without replication, you don't need to do anything special, as load balancer can support that with just a simple configuration. However, that also means you are willing to lose a few clients' sessions if your servers go down unexpectedly. – duyvh Jun 23 '21 at 09:55