I have two web apps - App-A & App-B - running in 2 EC2 instances (both web apps are running in both instances) fronted with an AWS ELB. The session stickiness is enabled using 'Application Generated Cookie Stickiness' and the cookie is set as "JSESSIONID".
Following is the scenario:
1) User first tries to access App-B. The request goes to Node-A and app creates a JSESSIONID with the path "/appb/" and ELB generates an AWSELB cookie for the same path.
Set-cookie headers coming to the browser:
Set-Cookie: JSESSIONID=8629A2C6FA26A99678599B0868511610; Path=/appb/; Secure; HttpOnly
Set-Cookie: AWSELB=B321B10B128ADF1E237E8419717E1CC409A63A5C6B3EA2E2C6CEE56E4F76FCE48DFDA95F1F20ED1ADEED570326993D2492C17C070ED41500F3EDC7EB993ED53188BF73D37301213483075952D1ADAD619C3C890672;PATH=/appb/;SECURE;HTTPONLY
2) Then user tries to access App-A. The request goes to Node-B and app creates a JSESSIONID with the path "/" and ELB generates an AWSELB cookie for the same path.
Set-cookie headers coming to the browser:
Set-Cookie: JSESSIONID=5DA3507629D0CB34DE1B032FA71D1CB2; Path=/; Secure; HttpOnly
Set-Cookie: AWSELB=B321B10B128ADF1E237E8419717E1CC409A63A5C6BC5080020E5701A0FB3756B152B401A70BF4CA755D30D9B06C82E5C1EB2E81E99C160A62D108BDB79947DEF2E2421C11C513C2C7452FA63B46EE8DF693FB5ED03;PATH=/;SECURE;HTTPONLY
3) Now the user tries to access App-B again. The browser sends both JSESSIONID cookies and the 2 AWSELB cookies to it, because App-A's cookies are created for "/". As far as I know, a cookie for the root context should be sent to all the other web contexts in the same domain.
Following is the cookie header going to App-B:
Cookie: JSESSIONID=8629A2C6FA26A99678599B0868511610; AWSELB=B321B10B128ADF1E237E8419717E1CC409A63A5C6B3EA2E2C6CEE56E4F76FCE48DFDA95F1F20ED1ADEED570326993D2492C17C070ED41500F3EDC7EB993ED53188BF73D37301213483075952D1ADAD619C3C890672; JSESSIONID=5DA3507629D0CB34DE1B032FA71D1CB2; AWSELB=B321B10B128ADF1E237E8419717E1CC409A63A5C6BC5080020E5701A0FB3756B152B401A70BF4CA755D30D9B06C82E5C1EB2E81E99C160A62D108BDB79947DEF2E2421C11C513C2C7452FA63B46EE8DF693FB5ED03
In this scenario I'm experiencing session stickiness issues where consecutive browser requests for App-B going to both nodes, rather than only to Node-A.
I'm curious how AWS ELB manages session stickiness in such a situation. Based on what does it select 1 AWSELB cookie out of the 2? Am I missing some configuration in the ELB?
Thanks in advance.