Attention! Helicon Tech Blog has moved to

Friday, January 14, 2011

Load balancing with Helicon Ape mod_proxy

Helicon Ape mod_proxy module provides simple way to configure load balancer. This article is giving explicit instructions of how to configure and test such load balancer.


Create simple cluster in which one front-end server (, accessible via Internet, proxies some application operation in an intranet (not accessible via Internet).

load balancer with Helicon Ape mod_proxy

To improve stability (resistance to failures) and speed the application will run on internal servers ( & which will distribute requests between themselves. In case one server is down (scheduled maintenance, upgrade, breakdown), all requests will be directed to another server.

Requests between the servers are distributed based on the response time value. I.e. the quicker back-end returns responses (better copes with the load), the more requests it will get.

The application uses sessions, so if the request contains the cookie with session id, this request must be assigned to the back-end which initiated this session. The cookie is of the following format [session_data]![backend_id].

Static content is also shared between two internal servers ( & so they need to distribute it among themselves as well.


Here’s the sample configuration of the balancer described above:

# route all requests starts with /static/ to static balancer
ProxyPass /static/ balancer://static-balancer/

# describe static balancer members

# enable reversing of response redirects
ProxyPassReverse /static/
ProxyPassReverse /static/

# route all other requests to application balancer
ProxyPass / balancer://app-balancer/ stickysession=sessionid routeregex=!(.*)$

# describe application balancer members
BalancerMember route=app1
BalancerMember route=app2

# enable reversing of response redirects
ProxyPassReverse /
ProxyPassReverse /
# enable reversing of domain in Set-Cookie headers

What was that?

And here’s the explanation of the code above.


section conditions that all directives inside it are applied only to the requests to This is especially important when the server manges several sites.

ProxyPass /static/ balancer://static-balancer/

directive tells mod_proxy that all requests beginning with /static/ must be proxied via static-balancer balancer.

<Proxy balancer://static-balancer/> ... 
Bookmark and Share

HeliconTech activity

Great tool