Can I use application-controlled session stickiness in AWS Elastic Beanstalk?

I am developing a Lift application deployed on a Tomcat 7 AWS Elastic Beanstalk container. My application requires sticky sessions when using elastic load balancing.

Since my application uses standard servlet material, it serves the JSESSIONID cookie for the client. I would like AWS to use an application-specific stickiness session where, given my cookie name, it will track sessions. However, in the Elastic Beanstalk Load Balancer configuration, I only see the ability to configure an AWS-managed cookie. I believe this will work, but I would only prefer to serve one cookie and have a stickiness that matches the sessions, in sequence with how we set them up in our application.

While it seems that we can configure application management bindings in the EC2 settings associated with my EB instance, the settings we apply will be knocked down anytime we make changes to the EB console. This is not terribly surprising behavior, but I would expect that we will soon forget this behavior and accidentally destroy our settings.

Does anyone know if it's possible to make stickiness sticky? :)

+6
source share
1 answer

Elastic load balancing (ELB) supports application controllability ( http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/elb-sticky-sessions.html#enable-sticky-sessions-application ). If you want to do this, you can create .ebextensions scripts to modify the ELB Beanstalk. You cannot do this through the Beanstalk web console.

To configure via .ebextensions , simply create a directory named .ebextensions inside your Beanstalk root application and create a file (for example: 00-load-balancer.config ) inside the .ebextensions directory.

The .ebextensions/00-load-balancer.config can be:

 { "Resources": { "AWSEBLoadBalancer": { "Type": "AWS::ElasticLoadBalancing::LoadBalancer", "Properties": { "AppCookieStickinessPolicy": [ { "PolicyName": "HttpSessionStickinessPolicy", "CookieName": "JSESSIONID" } ], "Listeners": [ { "LoadBalancerPort": 80, "Protocol": "HTTP", "InstancePort": 80, "InstanceProtocol": "HTTP", "PolicyNames": [ "HttpSessionStickinessPolicy" ] } ] } } } } 

The configuration will modify the ELB to listen on port 80 and redirect it to the specific port 80 of the EC2 instance based on the HttpSessionStickinessPolicy policy. HttpSessionStickinessPolicy will perform application sticky session stickiness.

Refer to AWAS Elastic Beanstalk ( http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-resources.html ) and AWS CloudFormation ( http://docs.aws.amazon.com/AWSCloudFormation/latest/ UserGuide / aws-properties-ec2-elb.html ) to learn more about this.

+1
source

All Articles