Saturday, February 27, 2016

AWS Elastic Load Balancing session stickiness - Part 2

In my previous post "AWS Elastic Load Balancing session stickiness" I demonstrated the use of AWS ELB  Load Balancer Generated Cookie Stickiness. In this post we'll use application generated cookie to control session stickiness.
To demonstrate this feature, I created a simple ASP.NET MVC application that just displays some instance details to test the load balancing.

Starting from the default ASP.NET MVC web application template, I modified the Index action of the HomeController:

Similar to what I've done in the previous posts using Linux shell scripts, this time I'm using C# code to request instance metadata from the URL then I store the host name and IP address in the ViewBag object and display them in the view:

I deployed the application to two EC2 Windows 2012 R2 instances. As expected, using the default ELB settings, requests will be routed randomly to one of the instances. This can be tested by looking at the host name and IP displayed in the response.

Looking to the request and response cookies, we can find the session cookie added:

To configure stickiness based on the ASP.NET_SessionId cookie, edit the stickiness configuration and enter the cookie name:

Checking the cookies, we find that ELB generates a cookie named "AWSELB". As documented: "The load balancer only inserts a new stickiness cookie if the application response includes a new application cookie."

Now the browser will send back both the session and ELB cookies:

Still my preference for maintaining session state is to use a distributed cache service like Redis or even SQL server. Because in case an instance goes down or is removed from an auto-scaling the user will lose his session data in case it's stored in memory.


Tanishka said...

Really an awesome post. I wondered by reading this blog post. Thanks a lot for posting this unique post which you have shared with us. Keep on posting like this exclusive post with us.

Hadoop Training in Chennai

Anu Sri said...

Excellent post !. I learned lot of information. Thanks!

php training in chennai

Arjun Rishi said...

Great article. Thanks for sharing such a useful post.

ppc training in chennai

Anu Sri said...

Nice post. glad to find your blog. Thanks for sharing.

web design training institute in Chennai

Andrew Son said...

Hadoop is a framework which has four classifications in it. Each has different properties and apache hadoop is an open source software framework. It is used for distributed processing and distributed storage. It use handle large set of data and information.
Big Data Training in Chennai | Hadoop Training in Chennai

Nivedageorge said...

Great article, Happy to visit your blog. Keep sharing such a useful post.

SEO Training in Kodambakkam

jhansi joe said...

Im no expert, but I believe you just made an excellent You certainly understand what youre speaking about, and I can truly get behind that.
SEO Training

Jhon Mick said...

Php is abbreviated as Hypertext preprocessor. Learn php and its dynamic working behavior is really interesting.
PHP Training in Chennai | PHP Course in Chennai

Anonymous said...

Have you been thinking about the power sources and the tiles whom use blocks I wanted to thank you for this great read!! I definitely enjoyed every little bit of it and I have you bookmarked to check out the new stuff you post. java training in jalandhar

Anonymous said...

Nice post. Thanks for the shearing valuable information. I really fiend this type blog. Special thanks to writer. web designing jalandhar

reginald surict said...

Thanks for sharing this post. You can also download apps to spy on your spouse.

for IT the said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training India . Nowadays Java has tons of job opportunities on various vertical industry.

JamesWilliam said...

Informative blog and it was up to the point describing the information very effectively. Thanks to blog author for wonderful and informative post. Also great with all of the valuable information on mobile app and you are doing well.
Mobile application developers in Chennai | Android application developers in Chennai

JamesWilliam said...

Thanks for sharing this niche useful informative post to our knowledge.
brochure designers in chennai | brochure design company in chennai

sriram said...

This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
Php course in chennai

ranjith s said...

Thank you for sharing valuable information
Mobile app development company in chennai
Web design company in chennai
Web development company in chennai

senthilkumar said...

thank you so much, sir for Sharing this informative blog

kmcool acservice said...

ac service ambattur

Pavel Co Ebele said...

Great Article
Final Year Projects for CSE in Dot Net
FInal Year Project Centers in Chennai

JavaScript Training in Chennai
JavaScript Training in Chennai said...

Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates.

Excelanto Global Services said...

Nice blog with awesome information. it’s very helpful. thanks for sharing.
Erp Software Company In India
Erp In India
Web Development Company In Chennai
Cloud Erp in India

sathyaramesh said...

Thank you for this wonderful post, It really nice and informative. Keep sharing!!
cloud computing training in chennai
Hadoop Training in Chennai
Selenium Training in Chennai
Digital Marketing Course in Chennai
JAVA Training in Chennai
German Classes in chennai
Android Course in Chennai
Android Training Chennai

jefrin adams said...

Best blog to read
cloud computing course in chennai

secretmasth said...

super your post in the website
honeymoon packages in andaman
andaman tour packages
andaman holiday packages
andaman tourism package
laptop service center in chennai
website designers in chennai
web development company in chennai
website designing company in chennai