Bug 36507

Summary: mod_proxy_balancer does not handle sticky sessions with tomcat correctly
Product: Apache httpd-2 Reporter: Christoph Bachhuber-Haller <bachhube>
Component: mod_proxy_balancerAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED FIXED    
Severity: major CC: bachhube
Priority: P2 Keywords: PatchAvailable
Version: 2.1-HEAD   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: Patch against trunk

Description Christoph Bachhuber-Haller 2005-09-05 17:41:35 UTC
Apache Tomcat uses JSESSIONID values like
95C5BB2B084DB06938BF798FCF3B3994.tomcat2 for sticky sessions. "tomcat2" is the
route set in jvmRoute in the Engine element in server.xml. 

I expected that mod_proxy_balancer would match its path argument against the
part after the . from JSESSIONID, but it tries to match against the whole cookie
and fails obviousely. (in httpd-2.1.6-alpha/modules/proxy/mod_proxy_balancer.c,
find_route_worker function)

That way, balancer is useless as a replacement for mod_jk load balancing with
sticky sessions.
Comment 1 Rüdiger Plüm 2005-09-28 23:17:33 UTC
Created attachment 16546 [details]
Patch against trunk

I can confirm this problem.
The attached patch should fix this. Can you please give it a try?
Comment 2 Christoph Bachhuber-Haller 2005-10-04 14:47:58 UTC
Hi Ruediger,

(In reply to comment #1)
> Created an attachment (id=16546) [edit]
> Patch against trunk
> 
> I can confirm this problem.
> The attached patch should fix this. Can you please give it a try?

I can confirm that this patch fixes my problem. Thank you very much! I wonder
though whether the tomcat session id format is any standard or if apache should
support sticky sessions for load balancing in a more generic way. 

Bye,
Christoph
Comment 4 Ruediger Pluem 2005-10-06 23:14:45 UTC
Committed and backported to 2.2.x branch (r306888).
Comment 5 Ruediger Pluem 2005-10-06 23:21:00 UTC
> though whether the tomcat session id format is any standard or if apache should
> support sticky sessions for load balancing in a more generic way. 

It does. As you can choose the name of the cookie you can make any application
where you can set a cookie work with that. Just set cookie BLAH=a.route in your
application. Of course it is more convenient if the application container is
able to do this (like Tomcat). BTW: I know no standard for coding such routing
information inside a cookie. But if you know one I would be interested to get it
known.