title: How to properly configure Apache Httpd as Load Balancer where some hosts may be unavailable
body: <p>I am using an Apache Httpd instance as proxy in front of multiple Java Tomcat instances. Apache acts as load balancer for the Tomcat instances.</p>
  
  <p>The apache config basically looks like follows</p>
  
  <pre><code>&lt;Proxy balancer://mycluster&gt;
      BalancerMember ajp://host1:8280 route=jvmRoute-8280
      BalancerMember ajp://host2:8280 route=jvmRoute-8280
      BalancerMember ajp://host3:8280 route=jvmRoute-8280
  &lt;/Proxy&gt;
  &lt;VirtualHost *:80&gt;
  ProxyPass / balancer://mycluster/
  ProxyPassReverse / balancer://mycluster/
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>This basically works when the AJP ports are configured in the Tomcat instances. Requests are sent to one of the hosts and the load is distributed across the Tomcat instances.</p>
  
  <p>However I see very long delays that seem to be caused inside Httpd whenever one of the hosts is not available, i.e. it seems Apache does not remember that one of the hosts is not available and repeatedly tries to send requests also to the missing hosts instead of sending it to one of the available hosts and trying the failing host at some time later.</p>
  
  <p>Is there a way to configure mod_proxy et.al. from Apache Httpd to support such a failover scenario, i.e. having multiple hosts and don't cause huge delays when one host fails? Preferably Apache should periodically check in the background which hosts are gone and not as them for any requests.</p>
  
  <p>I did find <a href="http://haproxy.1wt.eu/">HAProxy</a> which seems to be more suited for this kind of thing, but I would prefer to stick with Apache for a number of unrelated reasons.</p>
  
  <hr>
  
  <h2>Update</h2>
  
  <p>In the meantime I found out that part of my problem was caused by clients which kept the connection open endlessly and thus no more connections/threads were available.</p>
  
  <p>Thus I change the question to:
  What configuration options would you use to minimize the effect of something like this? I.e. allow many open connections or close them quickly in this case? Otherwise this sounds like a very easy DOS-attack with my current config?</p>