Re: HAProxy: listening port set up and performance

From: Willy Tarreau <>
Date: Tue, 20 Jan 2009 05:26:01 +0100


On Mon, Jan 19, 2009 at 06:11:13PM -0800, Hsin, Chih-fan wrote:
> Hi, I am new to HAProxy and have questions about the configuration and performance.
> I downloaded HAProxy from<blocked::> to /home/user/Tool
> Unpacked it by "tar xopf name.tar.gz.tar"
> Run "make TARGET=linux26"
> 1) Apache HTTP testing
> Servers webA ( and webB ( have Apache server started.
> Client ( sends http requests to webA ( and webB (, and can get valide http response (default Apache response).
> [client] -> [webA],[webB]
> Now, the HAProxy does not have Apache server and has IP address
> At HAProxy, run "./haproxy -f ./haproxy1.cfg". The haproxy1.cfg is below
> [client] -> [HAProxy] -> [webA],[webB].
> Client sends http request to HAProxy via IE web browing to However, the client cannot get web response.

By this, do you mean that no response ever comes back, or that you get an error ?

> Client sends http request to HAProxy via multiple IE web browsing to Then it works.

Are you sure that your apache machines don't block access from haproxy ? Also, do you have any form of virtual hosting on those machines, which would refuse requests with a "Host:" field with a wrong IP address in it ?

> haproxy1.cfg file
> listen webfarm <- How do I decide the correct port number to make work?

This is the correct form.

> mode http
> balance roundrobin
> cookie SERVERID insert indirect
> stats enable
> server webA cookie A check
> server webB cookie B check

I see that you have not configured timeouts. This is bad (though it should not cause you the problem you're seeing). Please add the following lines to the section above :

	timeout client 30s
	timeout server 30s
	timeout connect 5s

Also, you should log, you would see in the logs what is wrong. For this, please add the following line :

        log local0

Then ensure that your syslogd listens to the UDP socket (syslogd -r), and check the log files (you will see one line added when you start haproxy, then one line per request).

> 2) TCP testing (using Iperf)
> Servers webA ( and webB (192,168.5.5) run Iperf TCP sink to listen to port 5001
> Client runs 2 Iperf TCP connections and send traffic to
> At HAProxy, run "./haproxy -f ./haproxy2.cfg"
> haproxy2.cfg
> listen webfarm
> mode tcp
> balance roundrobin
> stats enable
> server webA
> server webB
> I can achieve 36Mbps each under the following scenario.
> [client] -> 36Mbps -> [webA]
> |----->36Mbps -> [webB]

36 Mbps ??? You definitely have something wrong in your setup ! This is the bandwidth you could expect from a saturated 100 Mbps HUB at maximal collision rate !!! Please check that all your connections are made to a switch and not a hub, and that all your hosts have negociated full duplex (with ethtool).

> However, when I use HAProxy, I can only achieve 18Mbps each. The utilization of HAProxy machine is low.
> [client] -> [HAProxy] -> 18Mbps -> [webA]
> |--------> 18Mbps -> [webB]
> Is this normal? Is there any way to improve it?

No it's not normal, but expected from the bad numbers above. If you are using a hub which is saturated, then making the traffic pass twice over it will half the per-host bandwidth.

Right now, it does not make sense to use a hub for network testing, not even a 100 Mbps switch. Gigabit switches are very cheap, you can find a 5-port gig switch for less than $50, it could save you a lot of time spent troubleshooting connectivity issues.

Willy Received on 2009/01/20 05:26

This archive was generated by hypermail 2.2.0 : 2009/01/20 05:30 CET