Seperate pgbouncer per postgres pod and using haproxy as a load balancer



I’ve deployed Postgres on Kubernetes via the Percona operator. After a while, I see that the memory usage difference between primary and secondary pods is huge ( 6GB for primary and 700 MB for secondary). And apparently, the load balancing has not been implemented in Pgbouncer.
So, my question is:
can we have a Pgbouncer pod or cluster per each pod of Postgres? and then adding a HAproxy to load balance between them?



1 Like

Hello @Ahmad_Abdolmaleki ,

thank you for bringing this up.

  1. Yes, we have it in our roadmap: [K8SPG-154] pgbouncer - leverage multiple standby nodes for reads · Issue #96 · percona/roadmap · GitHub (please add your thumbs up there)
  2. You are the first user that has asked for it, so I’m curious about your use case. Is it the difference in memory requirements that bothers you or is there more?

Thanks for letting me know about it on the roadmap.

And yes, I want to have a balance between resource usage of pods. I have 10-20 DBs, As they grow and require more memory, I increase all pods’ memory and there is a waste of free memory on secondary pods.

My colleague developers want me to bring up PgBouncer for them, which doesn’t have any load balancers.