HAProxy + Patroni + pgBouncer High Availability setup - Mailing list pgsql-admin

From Jānis Pūris
Subject HAProxy + Patroni + pgBouncer High Availability setup
Date
Msg-id 6ae63a77-5f9c-4f57-b409-e79a8b0244fb@Spark
Whole thread Raw
List pgsql-admin
Hello,

I have a working HAProxy, Patroni, PG stack and would like to add pgbouncer in the mix.

Current topology descr.
Haproxy is checking Patroni API, if the node it is responsible for is primary, if so, the requests are routed to it's postgresql server. When a failure occurs Patroni would do its magic and a different node in the cluster is promoted, HAProxy sees it via Patroni API checks and requests are rerouted to this new node. It works!

The problem
if I'd deploy pgBouncer between HAProxy and PostgreSQL, it would be a single point of failure. For example, if pgBouncer fails on primary, Patroni would not mind and no other node would take primary to mitigate the disaster.

Topology
[client] <--> [haproxy] <---> [pgbouncer] <---> [postgres]
        |-----------> [patroni] <-------->/

How can I improve the architecture, to avoid single point of failure ? I could of course add watchdog and similar processes, but I would really prefer not too overcomplicate the stack.

P.S. Deploying pgBouncer before client app is not an option, as a lot of different API and clients are talking to the cluster, as well as they are deployed in range of environments, i.e. kubernetes, metal, vms etc and so on.

Best regards, JP.

pgsql-admin by date:

Previous
From: Keith
Date:
Subject: Re: Streaming replication question
Next
From: Mark Steben
Date:
Subject: Re: Streaming replication question