Apache 2.2.x
Apache HTTP Server versions 2.2.x provides load balancing tools through two Apache modules
The two modules are:
The mod_proxy_balancer module provides support of HTTP requests load balancing. The mod_headers module provides HTTP cookies management needed by the Cookie-based request processing. For Sessionless request processing, the mod_headers module is not required.
Sessionless requests
<IfModule mod_proxy.c>
ProxyPass / balancer://GASFarm
<Proxy balancer://GASFarm>
BalancerMember http://GAS1.corporate.com
BalancerMember http://GAS2.corporate.com
</Proxy>
</IfModule>
- These configuration entries can be put at the server level in the httpd.conf file.
- The
ProxyPass
instruction tells the module to rewrite all incoming requests so that they are routed to theGASFarm
web farm. - The
<Proxy balancer://GASFarm>...</Proxy>
block defines which are the members ofGASFarm
web farm. - The
BalancerMember
instructions declare two HTTP web server members ofGASFarm
web farm:GAS1.corporate.com
andGAS2.corporate.com
.
For example, the http://localhost/ws/r/echo
URL will be rewritten to
http://GAS1.corporate.com/ws/r/echo
, assuming that the GAS1.corporate.com
server has been chosen.
Session-bound requests
<IfModule mod_proxy.c>
ProxyPass / balancer://GASFarm stickysession=GAS_AFFINITY
<Proxy balancer://GASFarm>
BalancerMember http://GAS1.corporate.com route=GAS1
BalancerMember http://GAS2.corporate.com route=GAS2
</Proxy>
</IfModule>
<IfModule mod_headers.c>
Header add Set-Cookie "GAS_AFFINITY=balancer.%{BALANCER_WORKER_ROUTE}e;
path=/; domain=.corporate.com" env=BALANCER_WORKER_ROUTE
</IfModule>
- These configuration entries can be put at the server level in the httpd.conf file.
- The
ProxyPass
instruction tells the module to rewrite all incoming requests so that they are routed to theGASFarm
web farm. Thestickysession
parameter gives the name of the cookie to use to retrieve the GAS that holds the session. - The
<Proxy balancer://GASFarm>...</Proxy>
block declares which are the members ofGASFarm
web farm. - The
BalancerMember
instructions declare two HTTP web server members of theGASFarm
web farm:GAS1.corporate.com
andGAS2.corporate.com
. Theroute
parameter gives the name of the route associated with that member. If that route name is found in the request cookie, then that member will be chosen. - The
Header
instruction will set, in the HTTP response, the cookie named GAS_AFFINITY to valuebalancer.BALANCER_WORKER_ROUTE
. TheBALANCER_WORKER_ROUTE
variable is assigned to the route of theGASFarm
member that has be chosen for the current request. Lastly, theenv
parameter tells the module to set that cookie only if theBALANCER_WORKER_ROUTE
variable is defined.
For example, the http://localhost/ua/r/gwc-demo
URL will be rewritten to
http://GAS1.corporate.com/ua/r/gwc-demo
, assuming that the
GAS1.corporate.com server has been chosen.