Hi Alex, On Sun, Oct 02, 2011 at 06:44:43PM +0200, Piavlo wrote: > > Hi, > > There is a client which establishes a persistent tcp connection to the > server, and haproxy in the middle which has a main server and backup server. > Then main server goes offline , the connections are reestablished to the > backup server just fine. The problem is that once main server is back > the already established connections should be restablished to the main > server. Is there a clean way to do it in haproxy?
No, I see no way to do that. In fact, there are also many people who would like the behaviour you observe to work also with non-persistent connections :-) > Since there is a lot of data sent over the connections the client/server > timeout is never reached ,so established connections continue forever > stay on the backup server. The way I see it is to trigger a reconnect > by haproxy automatically tearing the already established connections to > backup server then main server is back online. I see. The problem is that in many environments, it is just not acceptable to break established TCP connections when a server goes back up, as it means that repairing a server will disturb traffic. I think we could implement an option for this, but we need to limit it to very specific cases. What I'm thinking about is the following : when an active server comes up : - if it is the only active server, then it should kill all backup servers' connections ; - if there are backup servers associated to it (eg: by sharing a cookie), then it should kill their connections even if it's not alone. - later when we support spare and buddy servers, it should do the same. It's not something obvious to do, but should not be too much difficult either. I can add this to the roadmap. Regards, Willy