SomeAssembelyRequired
SomeAssembelyRequired

Reputation: 61

HAProxy Keep-Alive - 1.5-dev21

We are running HAProxy V1.5 as described above. I am trying to enable Keep-Alive and have noticed the response headers do not contain the Connection: Keep-Alive header.

Our haproxy.cfg contains the following defaults which I believe should enable keep alive:

    mode http
    timeout connect 15000ms
    timeout client 50000ms
    timeout server 30000ms
    timeout http-keep-alive 10s
    option http-keep-alive

I notice if I get rid of option http-keep-alive then the Connection: Close response header is being returned. Can anyone tell me is HAProxy not returning the Keep-Alive header as it's technically not requires in http 1.1 forward or is it that HAProxy simply isn't enabling Keep-Alive.

If it is the latter can anyone tell me why it wouldn't be working?

Upvotes: 4

Views: 1297

Answers (1)

liquidity
liquidity

Reputation: 1323

From HAProxy's documentation:

By default HAProxy operates in keep-alive mode with regards to persistent connections: for each connection it processes each request and response, and leaves the connection idle on both sides between the end of a response and the start of a new request.

And from the wikipedia article about Keep-Alive:

In HTTP 1.1, all connections are considered persistent unless declared otherwise

So to answer clearly to your question: Haproxy doesn't send Connection: Keep-Alive since it is not required with HTTP 1.1, since all connections are considered persistent unless declared otherwise.

You would probably see a Connection: Keep-Alive header if you connected with an HTTP 1.0 client.

Upvotes: 2

Related Questions