3

We created a PostgreSQL production database in AWS RDS a few months back and now we have received a requirement from the application team to install a connection pooler - PgBouncer in it.

I couldn't see any proper document from the AWS team showing the steps to install a PgBouncer and configure it in the AWS RDS PostgreSQL DB instance.

Is it possible to install PgBouncer in the AWS RDS PostgreSQL DB instance? If yes, can someone help me and share the steps to install and configure PgBouncer in the AWS RDS PostgreSQL?

Thank you!

  • Why don't you try RDS Proxy for your connection? – aspdeepak Feb 07 '23 at 15:15
  • @aspdeepak Is RDS proxy the only option for AWS RDS PostgreSQL connection pooling? Or is it possible to use PgBouncer with AWS RDS? – Enthusiastic learner Feb 07 '23 at 16:35
  • 1
    You can't install PgBouncer (or anything else) on an RDS instance; it's completely managed by AWS. Depending on _why_ you're using PgBouncer, you could run it as a service, using ECS or another compute platform. But in my experience people use PgBouncer rather than an in-app-server connection pool, and in that case it's far better to run it on the app-serverbox, (because then it's accessed via localhost rather than the network. This is especially true with a lift-and-shift deployment where the app-servers are still running on-prem. – kdgregory Feb 07 '23 at 17:50
  • 3
    [RDS Proxy](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.html) provides similar functionality to PgBouncer, running as a manage service. It would be better than a self-managed PgBouncer service, as long as everything is running inside the VPC. It would not be good in the lift-n-shift environment I described earlier. – kdgregory Feb 07 '23 at 17:53
  • @kdgregory Thanks for your guidance. Let me have a discussion with my app team on this. – Enthusiastic learner Feb 08 '23 at 02:30
  • 1
    @kdgregory I have one question: Here the application is VBA macros, so it is client-server in nature. Each user would have the web app on their system, and they would connect to the common AWS RDS database. Because we lack an app-server box here and our database is on AWS RDS, do you think the only option here is to install PgBouncer in AWS ECS? Or do you have any other recommendations? – Enthusiastic learner Feb 08 '23 at 10:24
  • The other option is RDS Proxy. It's easier to set up, but can only be accessed from within the VPC. Not a problem if you have a VPN connecting your local network to the VPC. However, exposing _any_ database to the Internet is generally a bad idea, so you should probably set up a VPN. These are all things that have no right answer; you need to do some background reading and experimentation. – kdgregory Feb 08 '23 at 13:15
  • Note that RDS Proxy won't work with prepared statements as it will do connection pinning @kdgregory – Eran Medan Jul 05 '23 at 23:28
  • @EranMedan - you might be using "prepared statement" in a different way than I do, but I don't see why RDS Proxy would have any effect on using them. What SDK, and what is the exact issues? – kdgregory Jul 06 '23 at 11:48
  • 2
    @kdgregory “Prepared statements cause the proxy to pin the session.” It works, but it’s just not effective. See the AWS docs: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy-managing.html see here also https://medium.com/@andre.decamargo/rds-proxy-and-connection-pinning-d26efcadb53c – Eran Medan Jul 08 '23 at 05:01

0 Answers0