skip to Main Content

I have installed Postgres cluster using zalando operator.
Also enabled pgbouncer for replicas and master.
But I would like to combine or load balance replicase and master connections,
So that read requests can be routed to read replicas and write requests can be routed to master.

Can anyone help me out in achieving this.

Thanks in advance.

Tried enabling pgbouncer.
pgbouncer is getting enabled either to master or to slave.

But I need a single point where it can route read requests to slaves and write requests to master.

2

Answers


  1. There is no safe way to distinguish reading and writing statements in PostgreSQL. pgPool tries to do that, but I think any such solution is flaky. You will have to teach your application to direct reads and writes to different data sources.

    Login or Signup to reply.
  2. I don’t think Pgbouncer provides any out of the box way to load balance read and write queries. An alternative to that is the use of pgpool as a connection pooler. Pgpool provides a mode known as load_balance_mode which you can turn it on and it will try to load balance queries and send write queries to master and read queries to replica. You can read more about the load_balance_mode here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search