Re: HAPROXY & pool of keep-alive connections to backend

From: Willy Tarreau <>
Date: Sun, 12 Sep 2010 22:13:56 +0200

Hello Maciej,

On Wed, Sep 08, 2010 at 08:01:42PM +0200, Maciej Bednarz wrote:
> Hello,
> I have a problem with haproxy configuration. First let me explain my scenario. I have two hardware servers:
> Server A runs a HAPROXY 1.4 and is accessible by HTTP clients
> Server B runs two instances of HTTP backend software (two sockets) and is only accessible by HAPROXY
> When now "thousands" of "crazy" clients access HAPROXY (500 mixed non keep-alive and keep-alive requests/second), all requests are forwarded 1:1 to my backend. If I have on Server A 100.000 sockets in TIME_WAIT, the same amount of sockets are also in the same state on Server B.

Why is that a problem ? 100000 TIME_WAITs are not much at all. Sites running at 20000 connections per second generally have over one million. TIME_WAITs are very cheap (just a few bytes). I could reach 4 millions once during a test, they have almost no measurable impact on performance.

> What I need is some kind of rewirte / multiplexing / pooling mechanizm to achive the following:
> HAPROXY keeps 100 keep-alive connections to the backend and uses them as a pool. No new connections are opened. When now a client will access the HAPROXY its request should be distributed to one of the allready existing connections without opening a new connection to the backend.

This mechanism (connection multiplexing) will be worked on once we have server-side keep-alive. There are several issues doing this. HTTP only allows you to send an idempotent request over a keep-alive connection, because if the connection closes while you're sending, you have to re-emit the request without knowing if it was processed or not. So basically you must not send POSTs nor any request looking like a dynamic request, which limits the feature to static files. I know that some vendors tend to do that on anything because it looks better. Just ask them what customers use that on your payment requests ;-)

Anyway, I agree that multiplexing is important. In fact, in my opinion, server-side keep-alive can only be useful with multiplexing. Without multiplexing, server-side keep-alive is useless and can only increase the server's load and reduce its capacity. That's why I'd really like to implement this just after we have keep-alive.

Willy Received on 2010/09/12 22:13

This archive was generated by hypermail 2.2.0 : 2010/09/12 22:30 CEST