Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I set up a load balancer with Apache 2.2 via mod_proxy and mod_proxy_balancer. The load balancing works just fine, but there is one case I cannot find any configuration options for, namely, while using persistent connections to the backend servers, when one of them dies (shuts down, crashes, etc ), the existing connections to it still try to access it.

Is there a way to configure the apache Load Balancer so that it quits or recreates connections to dead backend servers? In the LVS world the Ldirector has an option under Proc FS that governs just that:


When this is set persistent sessions / connections or a dead backend server will be flushed so that on the next client request they can be recreated.

Is there something similar to it in the Apache world?

P.S. In what manner does Apache check the status of the backend servers? Does it try to connect to some port or something like that? It would be great if someone could shed some light on that too!

Here is my virtual host configuration file:

ServerAdmin ServerName

DocumentRoot /srv/www/vhosts/

ErrorLog /var/log/apache2/
CustomLog /var/log/apache2/ combined

HostnameLookups Off
UseCanonicalName Off
ServerSignature On
ScriptAlias /cgi-bin/ "/srv/www/vhosts/"

<Location /balancer-manager>
    SetHandler balancer-manager
    Order Deny,Allow
    Deny from all
    Allow from all

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from bmf.intern.netz

<Proxy balancer://myapp>
    BalancerMember loadfactor=10 route=1 connectiontimeout=200ms
    BalancerMember loadfactor=10 route=2 connectiontimeout=200ms
    ProxySet stickysession=ROUTEID
    ProxySet lbmethod=byrequests

ProxyPass /balancer-manager !
ProxyPass /server-status !
ProxyPass / balancer://myapp/ lbmethod=byrequests
ProxyPassReverse / balancer://myapp/

<Directory "/srv/www/vhosts/">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all

<IfModule mod_userdir.c>
    UserDir public_html
    Include /etc/apache2/mod_userdir.conf

# This should be changed to whatever you set DocumentRoot to.
<Directory "/srv/www/vhosts/">

    Options Indexes FollowSymLinks
    AllowOverride None

    Order allow,deny
    Allow from all


share|improve this question
If you are not forced to use apache, maybe you can give a try to haproxy Otherwise with mod_proxy you may also try to play with ttl, retry and timeout values. Check documentation here : As far as I know the "alive" check is done at request time. – Tony May 16 '13 at 17:36
First of all thanks for the reply :) TTL values will make the users re-authorize every while and then, which is not desired at all. Connectiontimeout presents the same problem. All in all I don't want to kill or restrict the users' connections when the real servers are online, I want to redirect them when the server to which they have been connected dies / becomes unavailable. Does HAproxy has this stickyness removal option, like the expire quiescent templates? – Konstantin Boyanov May 17 '13 at 8:20

If you switch mod_proxy to use ajp13 connection which require (I think) a Java backend, you might be able to achieve session stickyness

I think that the "expire" option you are looking for is present in HAProxy

option redispatch no option redispatch Enable or disable session redistribution in case of connection failure May be used in sections: defaults | frontend | listen | backend yes | no | yes | yes Arguments : none

In HTTP mode, if a server designated by a cookie is down, clients may definitely stick to it because they cannot flush the cookie, so they will not be able to access the service anymore.

Specifying "option redispatch" will allow the proxy to break their
persistence and redistribute them to a working server.

It also allows to retry last connection to another server in case of multiple connection failures. Of course, it requires having "retries" set to a nonzero value.

This form is the preferred form, which replaces both the "redispatch" and "redisp" keywords.

If this option has been enabled in a "defaults" section, it can be disabled in a specific instance by prepending the "no" keyword before it.

See also : "redispatch", "retries", "force-persist"

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.