Re: HAProxy: listening port set up and performance

From: Willy Tarreau <w#1wt.eu>
Date: Tue, 20 Jan 2009 22:10:14 +0100


Hi,

On Tue, Jan 20, 2009 at 09:45:32AM -0800, Hsin, Chih-fan wrote:
> About 2) TCP testing, you are right. When I was doing the basic functional testing, I used a 100Mbps hub. That is why.

OK.

> About 1), when the client browses to http://192.168.5.3, it got a "page cannot be displayed" error. When the client browses to http://192.168.5.3:80, it got the correct Apache default index.html page. I think that the reason is in the HAProxy (with ip 192.168.5.3) configuration file, it listens to 192.168.5.3:80, this specific port.

I don't understand what you mean. When you send your browser to "http://192.168.5.3/", it specifically connects to port 80. So it is normal that you configure port 80 in haproxy config file. What is not expected is that when you don't specify the port it does not work. I think that your "host:" field is different between both cases and that your apache makes a specific case for one of these. Most likely it tries to perform a redirect to a wrong address, or something like this. Also, I see that you never write the trailing "/" after your addresses above, you should make sure that you put it, as some browsers behave badly when it is not set (as it is not a valid syntax, they are fixing it for you).

Once again, I really think that you have some strange virtual hosting config on your apache. Could you check the exact message that is returned to your browser ? "page cannot be displayed" is not a valid error, it's some cross-dressing performed by internet explorer to hide real errors not to scare users.

Also, have you enabled the logs as I asked you to ? The response to your problem is there. If you see that you don't receive the request, you'll know that your browser is not sending it. If you see a 302 response, you'll know that apache is doing a redirect to a wrong address. If you see 4xx or 5xx, you'll know that something else goes wrong either with the request or the response.

> Suppose that the client does not know what port HAProxy is
> listening to.

HTTP is on port 80 when unspecified.

> Client usually only connects to the ip address, not the ip+port,

Huh ??? What are you talking about ?

TCP is a transport protocol. It implies a port. It is not possible to connect to an IP address and does not make any sense. You connect to ip+port, period. The client must select a default port when you don't set it, but every browser I have seen always use port 80. You have never seen a commercial ad asking you to connect to http://www.domain.com:80/, have you ? That's because the browser will connect to port 80 unless specified otherwise.

> similar to client browsing to http://192.168.5.3. In this case,
> how should I configure the listening part (only listening to ip
> address?) at HAProxy?

No no no. Your client connects to port 80 and haproxy will listen to an IP+port couple. If it works with http://IP:80/, it works with http://IP/ as it's the same.

It would be interesting to check with tcpdump (or wireshark) on the client what is been sent on the wire, and what is received.

Last, you can also test this from your client :

# telnet 192.168.5.3 80
Trying 192.168.5.3...
Connected to 192.168.5.3.

Escape character is '^]'.
GET / HTTP/1.0 HTTP/1.0 200 OK
...
Connection closed.
# telnet 192.168.5.3 80
Trying 192.168.5.3...
Connected to 192.168.5.3.

Escape character is '^]'.
GET / HTTP/1.0
Host: 192.168.5.3:80

HTTP/1.0 200 OK
...
Connection closed.

# telnet 192.168.5.3 80
Trying 192.168.5.3...
Connected to 192.168.5.3.

Escape character is '^]'.
GET / HTTP/1.0
Host: 192.168.5.3

HTTP/1.0 200 OK
...
Connection closed.

If all above work, the problem is on your client. If only the second one works, the problem is on your apache configuration (the only one to consider the Host: field).

Hoping this helps,
Willy

> Chih-fan Hsin
> -----Original Message-----
> From: Willy Tarreau [mailto:w#1wt.eu]
> Sent: Monday, January 19, 2009 8:26 PM
> To: Hsin, Chih-fan
> Cc: haproxy#formilux.org
> Subject: Re: HAProxy: listening port set up and performance
>
> Hi,
>
> 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 1.3.15.7 from http://haproxy.1wt.eu/<blocked::http://haproxy.1wt.eu/> to /home/user/Tool
> > Unpacked it by "tar xopf name.tar.gz.tar"
> > Run "make TARGET=linux26"
> >
> > 1) Apache HTTP testing
> > Servers webA (192.168.5.4) and webB (192.168.5.5) have Apache server started.
> > Client (192.168.5.1) sends http requests to webA (192.168.5.4:80) and webB (192.168.5.5:80), and can get valide http response (default Apache response).
> > [client] -> [webA],[webB]
> >
> > Now, the HAProxy does not have Apache server and has IP address 192.168.5.3.
> > 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 http://192.168.5.3. 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 http://192.168.5.3:80. 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 192.168.5.3:80 <- How do I decide the correct port number to make http://192.168.5.3 work?
>
> This is the correct form.
>
>
> > mode http
> > balance roundrobin
> > cookie SERVERID insert indirect
> > stats enable
> > server webA 192.168.5.4:80 cookie A check
> > server webB 192.168.5.5:80 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 127.0.0.1 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 (192.168.5.4) 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 192.168.5.3:80
> > At HAProxy, run "./haproxy -f ./haproxy2.cfg"
> > haproxy2.cfg
> > listen webfarm 192.168.5.3:80
> > mode tcp
> > balance roundrobin
> > stats enable
> > server webA 192.168.5.4:5001
> > server webB 192.168.5.5:5001
> > 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.
>
> Regards,
> Willy
>
Received on 2009/01/20 22:10

This archive was generated by hypermail 2.2.0 : 2009/01/20 22:15 CET