Hi Dmitry,
On Thu, Apr 08, 2010 at 01:44:09PM +0400, Dmitry Sivachenko wrote:
> Hello!
>
> I am tasting version 1.4.3 of haproxy and I am getting a bit confused with
> HTTP keep-alive support status.
>
> 1) Is server-side HTTP keep-alive supported at all?
Not at all.
> The existence of option http-server-close makes me beleive that it is
> enabled unless that option is used.
What happens when you don't specify anything is that haproxy will not affect the request nor the response. As such it will work in "tunnel" mode, in which it only sees the first request of each connection and considers the rest are pure data and will not see nor touch them. That means keep-alive will often work but then haproxy is of limited use between the client and server (just a layer4 LB).
When you specify "option http-server-close", it enables connection-close on the server side only, which makes it possible to support keep-alive on the client side at the same time.
> 2) Is it true that client side HTTP keep-alive is also enabled by default unless
> option httpclose is used?
same as above, by default it's a tunnel mode, so keep-alive should work in the tunnel but second and ongoing requests will not be interpreted. Option httpclose only sets the "Connection: close" headers in requests and responses so that both client and server agree on the mode to use (close on both sides).
> 3) I have sample configuration running with option http-server-close and
> without option httpclose set.
>
> I observe the following at haproxy side:
>
> Request comes:
>
> GET /<some-url> HTTP/1.1
> Host: host.pp.ru
> User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.2) Gecko/20100326 Firefox/3.6.2
> Accept: */*
> Accept-Language: en-us,ru;q=0.7,en;q=0.3
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 115
> Connection: keep-alive
>
> So client requests keep-alive. I suppose that haproxy should send request to
> backend with Connection: close (because http-server-close is set) but
> send response to client with keep-alive enabled.
Exactly.
> But that does not happen:
>
> HTTP/1.1 200 OK
> Date: Thu, 08 Apr 2010 08:41:52 GMT
> Expires: Thu, 08 Apr 2010 08:42:52 GMT
> Content-Type: text/javascript; charset=utf-8
> Connection: Close
>
> jsonp1270715696732(["a", ["ab", "and", "a2", "ac", "are", "a a", "ad", "a b", "a1", "about"]])
>
>
> Why haproxy responds to client with Connection: Close?
Because the server did not provide information required to make the keep-alive possible. In your case, there is no "content-length" nor any "transfer-encoding" header, so the only way the client has to find the response end, is the closure of the connection.
An exactly similar issue was identified on Tomcat and Jetty. They did not use transfer-encoding when the client announces it intends to close. The Tomcat team was cooperative and recently agreed to improve that. In the mean time, we have released haproxy 1.4.4 which includes a workaround for this : combine "option http-pretend-keepalive" with "option http-server-close" and your server will believe you're doing keep-alive and may try to send a more appropriate response. At least this works with Jetty and Tomcat, though there is nothing mandatory in this area.
I don't know what server you're using, but you should probably give 1.4.4 a try with the option above.
Regards,
Willy
Received on 2010/04/08 11:58
This archive was generated by hypermail 2.2.0 : 2010/04/08 12:00 CEST