Hello! I have spent a lot of time researching and testing different methods for introducing the use of mod_proxy_balancer and sticky sessions with little success. I am running Apache 2.2.8 on Centos 5.2 32-bit. Apache is and has been up and running successfully for some time now, and I have pretty much all modules loaded (although few are in use). The idea is to have three virtual hosts. One contains the load balancer mod_proxy_balancer, which directs connections to the two other virtual hosts, where each one will use mod_proxy to ProxyPass the connection to another non-local site. The load balancing portion and virtual hosts I have setup with no problem. I got it working to the point that when connecting to the load balancer it will evenly distribute the requests along both virtual hosts. Well I realize this is no good because it should actually pull all requests for a site from one virtual host, then if you were to reconnect it should pull all requests from the other site. So the sessions should in fact be balanced rather than the individual requests. I suppose sticky sessions are my answer. Right now I have it to the point where it will distribute the sessions, but not evenly. It is almost there. I see in the logs that the "Header add..." line seems to still be active even though I have commented it out?? Below are the configuration and logs. Any ideas? I am pretty much stuck for good here. I don't know what else to do. Thanks. Jason. ------------------------------------------------------------ Virtual Host / Load Balancing Section of httpd.conf: ------------------------------------------------------------ #RewriteEngine On #RewriteRule .* - [CO=BALANCEID:balancer.localhost:80] #RewriteRule .* - [CO=BALANCEID:balancer.localhost:8082] # This section contains the load balancer <VirtualHost *:7070> ErrorLog logs/lb_error_log CustomLog logs/lb_access_log combined # Header add Set-Cookie "BALANCEID=balancer.BALANCER_SESSION_ROUTE" ProxyPass / balancer://mycluster/ stickysession=BALANCEID # ProxyPass /balancer-manager http://localhost:7070/balancer-manager <Proxy balancer://mycluster/> BalancerMember http://localhost:80 route=serv1 BalancerMember http://localhost:8082 route=serv2 BalancerMember http://localhost:8080 status=+H Order Deny,Allow Allow from all ProxySet lbmethod=byrequests </Proxy> <IfModule mod_proxy.c> </IfModule> # <Location /balancer-manager> # SetHandler balancer-manager # Order Deny,Allow # Allow from all # </Location> </VirtualHost> # This section comprises of remote staging sites using the proxy <VirtualHost *:80> ErrorLog logs/sc_error_log CustomLog logs/sc_access_log combined <IfModule mod_proxy.c> ProxyRequests Off ProxyPreserveHost On # Header add Set-Cookie BALANCEID=balancer.serv1 ProxyPass / http://siteURLhere/ ProxyPassreverse / http://siteURLhere/ </IfModule> # RewriteEngine On # RewriteRule .* - [CO=BALANCEID:balancer.localhost:80] </VirtualHost> <VirtualHost *:8082> ErrorLog logs/t1_error_log CustomLog logs/t1_custom_log combined <IfModule mod_proxy.c> ProxyRequests Off ProxyPreserveHost On # Header add Set-Cookie BALANCEID=balancer.serv2 ProxyPass / http://siteURLhere/ ProxyPassreverse / http://siteURLhere/ </IfModule> # RewriteEngine On # RewriteRule .* - [CO=BALANCEID:balancer.localhost:8082] </VirtualHost> -------------------------------------------------- Partial lb_error_log entries: -------------------------------------------------- [Tue Jul 29 09:26:21 2008] [debug] cache_storage.c(272): Cached response for /images/tn_br_11.gif isn't fresh. Adding/replacing conditional request headers. [Tue Jul 29 09:26:21 2008] [debug] mod_cache.c(131): Adding CACHE_SAVE filter for /images/tn_br_11.gif [Tue Jul 29 09:26:21 2008] [debug] mod_cache.c(138): Adding CACHE_REMOVE_URL filter for /images/tn_br_11.gif [Tue Jul 29 09:26:21 2008] [debug] mod_proxy_balancer.c(42): proxy: BALANCER: canonicalising URL //mycluster/images/tn_br_11.gif [Tue Jul 29 09:26:21 2008] [debug] mod_proxy_balancer.c(274): proxy: BALANCER: Found value balancer.serv1 for stickysession BALANCEID [Tue Jul 29 09:26:21 2008] [debug] mod_proxy_balancer.c(284): proxy: BALANCER: Found route serv1 [Tue Jul 29 09:26:21 2008] [debug] mod_proxy_balancer.c(533): proxy: BALANCER (balancer://mycluster) worker (http://localhost) rewritten to http://localhost/images/tn_br_11.gif [Tue Jul 29 09:26:21 2008] [debug] mod_proxy.c(849): Running scheme balancer handler (attempt 0) [Tue Jul 29 09:26:21 2008] [debug] mod_proxy_http.c(1822): proxy: HTTP: serving URL http://localhost/images/tn_br_11.gif [Tue Jul 29 09:26:21 2008] [debug] proxy_util.c(1855): proxy: HTTP: has acquired connection for (localhost) [Tue Jul 29 09:26:21 2008] [debug] proxy_util.c(1916): proxy: connecting http://localhost/images/tn_br_11.gif to localhost:80 [Tue Jul 29 09:26:21 2008] [debug] proxy_util.c(2015): proxy: connected /images/tn_br_11.gif to localhost:80 [Tue Jul 29 09:26:21 2008] [debug] proxy_util.c(2269): proxy: HTTP: connection complete to 127.0.0.1:80 (localhost) [Tue Jul 29 09:26:21 2008] [debug] mod_proxy_http.c(1700): proxy: header only [Tue Jul 29 09:26:21 2008] [debug] mod_cache.c(633): cache: Caching url: /images/tn_br_07.gif [Tue Jul 29 09:26:21 2008] [debug] mod_cache.c(639): cache: Removing CACHE_REMOVE_URL filter. [Tue Jul 29 09:27:28 2008] [debug] mod_cache.c(131): Adding CACHE_SAVE filter for / [Tue Jul 29 09:27:28 2008] [debug] mod_cache.c(138): Adding CACHE_REMOVE_URL filter for / [Tue Jul 29 09:27:28 2008] [debug] mod_proxy_balancer.c(42): proxy: BALANCER: canonicalising URL //mycluster/ [Tue Jul 29 09:27:28 2008] [debug] mod_proxy_balancer.c(274): proxy: BALANCER: Found value balancer.BALANCER_WORKER_ROUTE for stickysession BALANCEID [Tue Jul 29 09:27:28 2008] [debug] mod_proxy_balancer.c(284): proxy: BALANCER: Found route BALANCER_WORKER_ROUTE [Tue Jul 29 09:27:28 2008] [debug] mod_proxy_balancer.c(914): proxy: Entering byrequests for BALANCER (balancer://mycluster) [Tue Jul 29 09:27:28 2008] [debug] mod_proxy_balancer.c(533): proxy: BALANCER (balancer://mycluster) worker (http://localhost:8082) rewritten to http://localhost:8082/ [Tue Jul 29 09:27:28 2008] [debug] mod_proxy.c(849): Running scheme balancer handler (attempt 0) [Tue Jul 29 09:27:28 2008] [debug] mod_proxy_http.c(1822): proxy: HTTP: serving URL http://localhost:8082/ [Tue Jul 29 09:27:28 2008] [debug] proxy_util.c(1855): proxy: HTTP: has acquired connection for (localhost) [Tue Jul 29 09:27:28 2008] [debug] proxy_util.c(1916): proxy: connecting http://localhost:8082/ to localhost:8082 [Tue Jul 29 09:27:28 2008] [debug] proxy_util.c(2015): proxy: connected / to localhost:8082 [Tue Jul 29 09:27:28 2008] [debug] proxy_util.c(2112): proxy: HTTP: backend socket is disconnected. [Tue Jul 29 09:27:28 2008] [debug] proxy_util.c(2172): proxy: HTTP: fam 2 socket created to connect to localhost [Tue Jul 29 09:27:28 2008] [debug] proxy_util.c(2269): proxy: HTTP: connection complete to 127.0.0.1:8082 (localhost) [Tue Jul 29 09:27:28 2008] [debug] mod_proxy_http.c(1607): proxy: start body send [Tue Jul 29 09:27:28 2008] [debug] mod_cache.c(528): cache: / not cached. Reason: No Last-Modified, Etag, or Expires headers [Tue Jul 29 09:27:28 2008] [debug] mod_proxy_http.c(1696): proxy: end body send [Tue Jul 29 09:27:28 2008] [debug] proxy_util.c(1873): proxy: HTTP: has released connection for (localhost)
hmmm well, does anyone at least have examples of their own code or some explanations of how sticky sessions/load balancing work?