How do I manage database connection pooling in Porter?

Last updated: April 15, 2025

Context

When running applications on Porter that connect to a PostgreSQL database, you may receive warnings from Amazon RDS about connection management, particularly when dealing with high numbers of database connections. AWS may recommend using RDS Proxy for connection pooling.

Answer

While AWS RDS Proxy is one solution for connection pooling, Porter recommends using PgBouncer for managing database connections. PgBouncer is a lightweight connection pooler for PostgreSQL that helps manage and optimize database connections.

To implement connection pooling:

  1. Set up a PgBouncer container in your Porter dashboard

  2. Configure your application to connect through the PgBouncer instance instead of connecting directly to the database

  3. Adjust your connection pool settings based on your application's needs

This approach helps prevent connection-related issues and optimizes database performance by:

  • Reducing the number of direct connections to the database

  • Managing connection pooling efficiently

  • Preventing connection exhaustion