Nick
Nick

Reputation: 930

Haproxy close connections to backup hosts when primary comes back

Question

Can I get haproxy to close all connections to backup hosts when a primary host becomes available after being down?

Context

I am using HAproxy to do failover for pubsub.

The haproxy backend config looks something like this:

listen pubsub 0.0.0.0:1234
    mode tcp

    server primary primary.x.com:1234 weight 1 inter 500 rise 10 fall 5 check
    server backup backup.x.com:1234 weight 1 inter 500 rise 10 fall 5 check backup

I make long lived connections for both the publish and the subscribe sides.

the problem is in the scenario that:

The best solution to this problem that I can see is to have haproxy forcibly close all connections to backup hosts when a primary becomes available again.

Upvotes: 7

Views: 4591

Answers (1)

Anthony Fammartino
Anthony Fammartino

Reputation: 83

I know this is an older question, and you've probably found a solution by now, but if you haven't then I think the answer you are looking for is the on-marked-up server option. This is a new server option as of version 1.5.

According to the documentation, you can provide an action to perform when a server is marked as "up". Currently, the only action is:

shutdown-backup-sessions: Shutdown sessions on all backup servers...

server primary ... on-marked-up shutdown-backup-sessions

Upvotes: 7

Related Questions