Running Out of Connections

When all of the database connections are in use, PostgreSQL is not able to serve more requests. This is a severe problem that you’ll want to avoid. What sorts of processes can use up connections?

Ruby on Rails applications that scale horizontally run more server processes. For multithreaded servers like Puma,[266] threads open database connections to perform work. Background job processing frameworks like Sidekiq[267] are commonly deployed next to Rails applications.

Puma and Sidekiq processes each have multiple execution threads, and each thread uses a connection.

When scaling up processes, carefully monitor the number of active client connections being opened to avoid exceeding the maximum allowed number. If that ...

Get High Performance PostgreSQL for Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.