Load balancing with appservers who set a bad sticky cookie

Some application servers, or even dumb backends that only speak HTTP do not set a cookie that can be used to track user experience. Some times, though, these applications do require session persistence to the backend that created it. As an Apache HTTPD administrator, how can we give these developers what they want without requiring code changes to the backend?

Solution

You will need:

And this configuration:

<Proxy balancer://Application_cluster>
   BalancerMember http://host1:80 route=member0
   BalancerMember http://host2:80 route=member1
   BalancerMember http://host3:80 route=member2
   ProxySet stickysession=Application_STICKY
</Proxy>
Header add Set-Cookie "Application_STICKY=sticky.%{BALANCER_WORKER_ROUTE}e;path=/;" env=BALANCER_ROUTE_CHANGED

Wait a minute.. what is going on here?

We are creating a load balancer using mod_proxy_balancer with the Proxy block. Inside that balancer we are creating three members and telling the balancer to look for a cookie called "Application_STICKY" as the cookie in question. This is pretty straight forward stuff.

The next line, however, is asking mod_headers to...

This works perfectly because:

LoadBalanceWithoutStickyCookie (last edited 2010-03-29 16:35:57 by DRuggeri)