0

Would like to know the real benefit/advantage of configuring sticky sessions @ load balancer level in AWS..

i understood from the AWS documentation that the user request will be routed to a specific instance based on the cookie added to the request by ELB(Elastic load balancer)

http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/elb-sticky-sessions.html#enable-sticky-sessions-duration

But not able understand the real benefit of using this feature..Please help!!!

shiv455
  • 223
  • 1
  • 3
  • 7

1 Answers1

2

I'll give an example to illustrate their utility.

PHP, by default, stores session data in a file on the server. If you have two servers behind an ELB and no sticky sessions, the user's session data will be lost/inconsistent as they bounce between the two servers at random.

There are workarounds for this - storing session data in a database or caching layer, for example - but for some applications (particularly legacy ones you have little control over) it's a lot easier to just use the stickiness option.

ceejayoz
  • 32,910
  • 7
  • 82
  • 106
  • actually we deployed Java rest api in AWS and we recieve huge number of client requests to this api...would like to know if this feature is beneficial to us??? – shiv455 Jan 06 '16 at 16:08
  • 1
    @shiv455 That's not a question we can answer for you. If you're already receiving lots of requests without errors, there's no reason to turn on sticky sessions. They're a workaround, but not a best practice. – ceejayoz Jan 06 '16 at 16:29
  • 2
    a good practice is to avoid stickiness on AWS as long as possible, and keep session state in database or cache if you want to properly leverage autoscaling and load balancing – Tom Jan 06 '16 at 16:34
  • ok i thought it is a best practice to follow as it was mentioned in http://aws.amazon.com/articles/1636185810492479 – shiv455 Jan 06 '16 at 16:53
  • @shiv455 Nothing there says it's a best practice. It's off by default, they mention some of the pitfalls it causes, and encourage you to decide whether they're necessary for you. If they aren't necessary for your app to run, you shouldn't use them. – ceejayoz Jan 06 '16 at 17:20
  • Thanks for your response!! but im unable to vote for the answer.. – shiv455 Jan 06 '16 at 18:42
  • 1
    @shiv455 if your API is stateless then my guess is you do not need sticky sessions - if you don't need it don't use it! – TheFiddlerWins Jan 06 '16 at 19:57