Re: Load Balancing for Apache Query

From: Willy Tarreau <>
Date: Fri, 16 Jul 2010 06:27:38 +0200

Hi Christopher,

On Fri, Jul 16, 2010 at 11:05:34AM +1000, Christopher Little wrote:
> This is my first time using HAproxy and I've come into a bit of an issue.
> I'm using haproxy to load balance two apache servers for a proof of
> concept, currently running ab to test performance and I've noticed that
> telling ab to have a number of concurrent connections that is greater than
> the maximum number of clients supported by the apache servers causes it to
> drop the packages somewhere and not log them or report them in any way. I
> was just wondering if this was by design or if it was an error in my
> configuration files.
> Heres a copy of my haproxy.cfg for reference:
> global
> maxconn 10000 # Total Number of
> Connections
> log local0
> log local1 notice
> daemon
> nbproc 1 # Number of Processes
> user haproxy
> group haproxy
> chroot /var/chroot/haproxy
> defaults
> log global
> option tcplog
> mode tcp
> clitimeout 60000
> srvtimeout 30000
> contimeout 4000
> retries 3
> option redispatch
> listen load_balanced
> mode http
> balance roundrobin
> server webserver2 weight 1 maxconn 10 check
> server webserver3 weight 1 maxconn 10 check
> listen admin_stats
> mode http
> stats enable
> And the command I am running in ab is this: ab -n 1000 -c 20
> index.php is simply a script that sleeps for 3 seconds as part of the test.
> Any help with would be very much appreciated.

You don't get anything useful in the logs because of "tcplog" instead of "httplog". Once you enable this, it is possible that you'll notice some "sQ--" flags, indicating that a request spent to much time in the queue waiting for a server and was aborted. This is because the default queue timeout is equal to the connection timeout, which is low here. In other words, you should have something like this :

       timeout connect 4s
       timeout client 60s
       timeout server 60s
       timeout queue  60s

Also, please ensure that your apache can accept at least 11 connections, because you have 10 max configured, and haproxy also checks the servers, which regularly results in a 11th connection. If the check fails, the server will be marked as down and it won't get any more traffic until the connections end and the check works again.

Otherwise your config is one of the simplest we can dream of, so there's no particular issue there.

Willy Received on 2010/07/16 06:27

This archive was generated by hypermail 2.2.0 : 2010/07/16 06:30 CEST