Saturday, October 5, 2013

A Quick Tour of the Cloud Foundry Router and Sticky Sessions

The Cloud Foundry Router is a key component of the platform that provides:
  • load balancing to multiple instances of applications with a dynamic routing table updated in a fraction of a second every time there is a change in the system
  • sticky session support
  • access log for apps that feeds into an application's Loggregator stream
  • support for Web Socket and other TCP protocols via HTTP Connect
Cloud Foundry has had support for "sticky" sessions in both v1 and v2. This week I had a meeting with a very large technology provider that has been using Cloud Foundry for quite awhile. They had no idea that sticky sessions were supported or how they worked and I realized we should have a better explanation and showcase of this capability. The use-case for this scenario involved a significant performance optimization when using sticky sessions because of user-specific data caching in the warmed-up app instance.

To enable Cloud Foundry sticky sessions all you need to do in the application is set a cookie named JSESSIONID. Java web applications have a history of using a cookie named JSESSIONID when you enable a session with code like request.getSession( true ) and because many Cloud Foundry users run Java apps, the project decided to use JSESSIONID as an indicator that sticky sessions should be used. To use another sticky sessions with another language like Ruby or Node.js, all you need to do is set a cookie named JSESSIONID and Cloud Foundry will attempt to consistently route requests to the same app instance.

I created a simple Java web application to show how this works and I hosted a copy of it on http://sticky-session.cfapps.io. In the first screenshot you can see that sticky sessions are not enabled. First we can see that there are 4 instances of the app running.


Now when we visit the app and use something like Chrome Dev Tools to inspect the app. Refresh the app several times and observe that the printed out port changes as we are load balanced across the multiple app instances.


Now we'll click the "start a sticky session" link in the app, which creates a Java session in Tomcat and creates a JSESSIONID cookie. The router will notice the JSESSIONID cookie and set a Cloud Foundry specific cookie named __VCAP_ID__ with a value of the app instance GUID. The __VCAP_ID__ cookie is the hint to the router to send the request to the specific app instance. With these cookies set, refresh the page and the browser should consistently route to the single app instance.


If you use Chrome Dev Tools to delete the __VCAP_ID__ cookie and refresh the page, and you should see a randomly selected app instance value get set again for __VCAP_ID__. Subsequent page refreshes will be sticky to the instance reflected in the updated __VCAP_ID__ cookie value.

If you are interested in other features for the Cloud Foundry Router, let us know on the Cloud Foundry mailing list.  

31 comments:

Lei Zhang said...

I also tested that before. It really works! Good job!

Lei Zhang said...

I also tested that before. It really works! Good job!

Lei Zhang said...

I also tested that before. It really works! Good job!

Dr Nic said...

Used this app for the demo today. Works great.

pak gendoet said...

Jual aneka barang ONLINE.

bisa di pilih mana yang pingin di order.

http://kopiluwakliar01.blogspot.com
http://kopiluwakliar.vvty.in/
http://bantalsilikon.vvty.in/

http://bantalsilikon01.blogspot.com

http://marinirseo.blogspot.com.com
http://bumbupecel1.blogspot.com


h
ttp://bantalsilikon01.blogspot.com
http://kopiluwakliar01.blogspot.com
http://marinirseo.blogspot.com.com/
http://bumbupecel1.blogspot.com/
http://bantalsilikon01.blogdetik.com/

http://kopiluwakliar.vvty.in/
http://bantalsilikon.vvty.in/
CP : +62-85-635-945-40

josi josisonali said...

packers and movers pune @ http://www.the5th.in/packers-and-movers-pune.html
packers and movers mumbai @ http://www.the5th.in/packers-and-movers-mumbai.html
packers and movers gurgaon @ http://www.the5th.in/packers-and-movers-gurgaon.html
packers and movers bangalore @ http://www.the5th.in/packers-and-movers-bangalore.html
http://www.the5th.in/

Sumit Kumar said...

Thanks for post this helpful post - Please visit for More information about -
Packers and Movers Hyderabad
Packers and Movers Mumbai
Packers and Movers Chennai
Packers and Movers Noida

Sumit Kumar said...

This article is really fantastic and thanks for sharing the valuable post.
Packers and Movers Delhi
Packers and Movers Bangalore
Packers and Movers Gurgaon
Packers and Movers Pune

Sumit Kumar said...

Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write
Packers and Movers Thane
Packers and Movers Navi Mumbai
Packers and Movers Ghaziabad
Packers and Movers Faridabad

Swati Kumari said...

The article is very nice and informative.I enjoyed alot while reading. Thanks for sharing.
movers and packers in delhi
packers and movers in navi mumbai
movers and packers in mumbai
movers and packers in pune
movers and packers in hyderabad
packers and movers in bangalore
chennai packers and movers

amine lahragui said...

Your work is very good and I appreciate you and hopping for some more informative posts. happy new year 2016 new year 2016 bonne année 2016 happy new year 2016 images feliz año nuevo 2016 imagenes de año nuevo 2016 feliz año 2016

Hosting Coupons&Discounts said...

new year 2016
diwali wishes 2015
diwali quotes 2015
diwali images 2015
new year 2016 wishes
new year 2016 sms
new year 2016 quotes
new year 2016 messages
new year 2016 poems
new year 2016 fb status
new year 2016 whatsapp status
new year hindi wishes
new year 2016 french
new year 2016 spanish

Express Home Packers and Movers said...

Thanks for sharing informative post with us.
packers and movers in pune
packers and movers in hinjewadi
packers and movers in magarpatta
packers and movers in wakad
movers and packers in viman nagar
packers and movers in hadapsar
packers and movers in kondhwa
packers and movers in kothrud
packers and movers in pashan
packers and movers in aundh
movers and packers in kharadi
packers and movers in warje
packers and movers in kalyaninagar
packers and movers in koregaon
packers and movers in pimpri
packers and movers in pimple saudagar
packers and movers in hyderabad
packers and movers in gurgaon

Dhruv Shah said...

Nice article. Celebrate new year with messages & sms.
new year wishes 2016
new year messages
happy new year message
new year sms

Dallas Larden said...

Thanks for sharing it!!!

Crazy Bulk

novin1 said...

It is fair to say that your information is very useful .
I would appreciated for your site .
It is fair to say that I enjoyed your site a lot .

طراحی سایت
هدایای تبلیغاتی
دستگاه حضور و غیاب
هدایای تبلیغاتی
دستگاه تصفیه آب خانگی

prem chand said...

Republic Day 2016
Republic Day 2016 Images
Happy Republic Day Quotes
Republic Day Messages and Sms
Valentines Day 2016
Happy Valentines Day images
Happy Holi 2016 images
Happy Holi Messages and Sms
Happy Lohri 2016 images
Happy Lohri Messages Sms Quotes in Punjabi

Men said...

Happy Pongal Wishes SMS

Happy Pongal Wishes Recipes

Happy Pongal Wishes Greetings

Happy Pongal Wishes Kolam

Happy Pongal Wishes

asds said...

Inspirational Love Quotes
Love Quotes
Inspirational Quotes

Inspirational Quotes
Love Quotes
Photoshop Tutorials

Happy Mothers Day
Happy Mother's Day
Happy Mothers Day 2016
Happy Mother's Day 2016
Mothers Day 2016
Mother's Day 2016

happy mothers day quotes
happy mothers day messages
happy mothers day poems

asds said...

mothers day quotes from daughter
mothers day quotes from son
mothers day quotes from husband to wife

mothers day quotes from family
mothers day quotes
mothers day messages

mothers day poems
mothers day poems from daughter
funny mothers day quotes

funny mothers day messages
funny mothers day sayings
mothers day sayings

mothers day love quotes
inspirational mothers day quotes

asds said...

Happy Mothers Day
Happy Mother's Day
Happy Mothers Day 2016

Happy Mother's Day 2016
Mothers Day 2016
Mother's Day 2016

Happy Mothers Day
Happy Mother's Day
Happy Mothers Day 2016

Happy Mother's Day 2016
Mothers Day 2016
Mother's Day 2016

asds said...

Happy fathers Day
Happy father's Day
Happy fathers Day 2016

Happy father's Day 2016
fathers Day 2016
father's Day 2016

father's day
fathers day

fathers day quotes
fathers day messages
fathers day poems
Happy fathers Day
Happy father's Day
Happy fathers Day 2016

Happy father's Day 2016
fathers Day 2016
father's Day 2016

Happy Father’S Day 2016 Quotes

asds said...

Wishes Quotes
Wishes Quotes Greetings
Easter Sunday
Easter Sunday 2016

Recover Deleted Files on Android
Apple iPad Mini 4 Cases and Covers
Online Music Identification Services

Multiplayer Games for your iPhone
Free Stock Photo Websites
Design Resources

Free Android Apps
Improve the Performance of Android Tablet
Screen Recording Software
Screen Sharing Software for Remote Access

asds said...

Valentines day 2016
Happy Valentines day 2016
Happy Valentines day
Valentine's day 2016

Happy Valentine Day Quotes For Husband
kiss quotes for her
kiss quotes for girlfriend

happy valentines day 2016
valentines day 2016
valentine's day 2016

happy propose day
valentines day quotes
happy valentines day quotes
happy valentines day quotes

kiss quotes for boyfriend
anti valentines day quotes
anti valentines day quotes

asds said...

propose day sms
short valentines day poems

valentines day poems for her
valentines day poems for girlfriend
Happy Rose Day Quotes SMS And Sayings

Happy Propose Day SMS - Messages For Him And Her
Valentines Day Quotes
Happy Chocolate Day Love Quotes

Happy Chocolate Day Sms Messages
Valentines Day Gifts For Her
Cheap Valentines Day Cards

Cute Valentines Day Quotes
Valentines Day Poems For Him
Happy Valentines Day Whatsapp Messages

Valentines Day Ideas For Kids
Valentines Day Pick Up Lines
Happy Chocolate Day Quotes For Him And Her

happy valentines day quotes
valentines day quotes
Happy Valentine Day Quotes For Husband

asds said...

Valentines day 2016
Happy Valentines day 2016
Happy Valentines day
Valentine's day 2016

Funny Valentines Day Quotes
Valentine Week List 2016
Valentines Day Quotes
Happy Valentines Day Quotes
fathers day quotes
fathers day messages
fathers day poems

Easter Quotes From The Bible
Happy Easter Quotes
Easter Quotes

ankitagoyal said...

Email Database
Email Service Provider
Bulk Email services in Delhi
Bulk Email services in Indore
Bulk Email services in Amritsar
Bulk Email services in Ludhiana
Bulk Email services in Punjab
Bulk Email services in Karnataka
Bulk Email services in Bengal
Bulk Email services in UP
Bulk Email services in Tamilnadu
Bulk Email services in Chennai
Bulk Email services in Jodhpur
Bulk Email services in Chandigarh
Bulk Email services in Tamilnadu

Valentines Day Quotes said...

valentines day images 2016
Valentines Day 2016 Shayaries
happy Valentines Day Quotes 2016
happy Valentines Day 2016
Valentines Day 2016 Wishes
Valentines Day 2016 Messages

Abhi K said...

Best packers and movers in Bhubaneswar, household shifting service in Bhubaneswar, home relocation in Bhubaneswar, car carriers service in Bhubaneswar, car transport in Bhubaneswar. packers and movers Bhubaneswar

prem chand said...

Hello sir your article or work is so nice and full informative with each and singal point and i loved to reading that kind article which is available in your website so thanks and yes keep updating more stuff on this topic. Below check some stuff,
Happy Valentines Day 2016 , Valentines Day 2016 images , Happy Valentines Day Sms , Valentines Day 2016 Messages , Happy Holi 2016 Messages , Happy Holi 2016 Sms , Happy Holi 2016 Quotes , Happy Chocolate Day 2016 , Chocolate Day 2016 images , Happy Chocolate Day Sms , Chocolate Day 2016 Messages , Happy Hug Day 2016 , Hug Day 2016 images , Happy Hug Day Sms , Hug Day 2016 Messages , Happy Kiss Day Sms , Kiss Day 2016 Messages , Happy Kiss Day 2016 , Kiss Day 2016 images , Valentines Day Sms and Messages for Her or Him , Valentines Day Messages for Husband and Wife , Valentines Day Images for Facebook and Whatsapp Status , Valentines Day Quotes
Happy Holi Images Pictures for Facebook and Whatsapp Status , Happy Holi Quotes , Happy Holi Messages , Happy Holi Sms

Naila Musdalifah said...

perangsang wanita terpercaya

phero-x terbaik

Obat tidur super cepat

perangsang gell

toko Potenzol terbaik

penjual Blue Wizard

perangsang spray

obat perangsang permen