Sharing is (not always) caring. PgBouncer pooling modes in practice

  • Published on Oskar Dudycz
  • Curated on
Sharing is (not always) caring. PgBouncer pooling modes in practice - Oskar Dudycz
Image: Oskar Dudycz

The sad thing about programming is that eventually we reach production; the closer we get, the nastier things get. Some people start asking, Will it scale?, and some even run performance and load tests. Then outcomes can bring all hands on deck.

I’ve been there, done that, and one common struggle I saw was connection management. It all starts with putting high, concurrent traffic on our services; then our database starts to run out of connections. Typically, each instance of your service has its own connection pool. Each pool keeps its connections open so it can reuse them for upcoming queries. But if you set it up wrong, multiplying your service instances can exhaust database connections just by keeping them open. Typically that’s not an issue, as if they’re not used, they will be killed, but in high-concurrency traffic? Gulp.…