0

I'm building a patroni postgres cluster, however, I can't decide which is better architecture

App > HAproxy > Pgbouncer > PostgreSQL (patroni)

App > PGBouncer > HAproxy > PostgreSQL (patroni)

I can't seem to get an answer upon my search and a lot of conflicted answers. Some say its better to have haproxy in front and others say the opposite .

I would appreciate your opinion on this matter

1 Answers1

0

First option is what you want, because pgBouncer is a connection pooler for PostgreSQL. It needs to be close to DBMS and be one2one connected each one to its own Postgresql instance. As for HAProxy it is a load balancer, you can have HAProxies' number different than a number of Postgre\Patroni\pgBouncer instances. Plus it will give you an option to separate read and write requests to different ports\databases.

here is an article which will be helpful https://medium.com/@nicola.vitaly/setting-up-high-availability-postgresql-cluster-using-patroni-pgbouncer-docker-consul-and-95c70445b1b1