Scaling Django/Postgres with PgBouncer on Heroku

By Stefan Ukena | June 9, 2020

Do you have an app on Heroku using Postgres? Are you running out of database connections? Maybe you’ve already tried setting CONN_MAX_AGE, but that only helped for a while. It’s time for PgBouncer, the de facto standard for Postgres connection pooling.
In this article, we’ll look at how to use PgBouncer to scale your app on Heroku. We’ll use Django, a popular python web framework, as an example for the settings. The installation steps for PgBouncer and the concepts, however, should work for any app on Heroku.