HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMajor

What limits the number of connections?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
numberthewhatlimitsconnections

Problem

As per https://devcenter.heroku.com/articles/heroku-postgres-legacy-plans the connection limit is 500

As per https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server "Generally, PostgreSQL on good hardware can support a few hundred connections"

What are the determining factors in this limit? #CPU cores? RAM? OS?

Solution

First of all, the GUC¹ setting max_connections in postgresql.conf limits connections. It can only be set at server start.

Heroku obviously limits this to 20 for the "Starter Tier" and 500 for the "Production Tier".

The maximum number is not limited by Postgres itself, but by available system resources. Typically, performance degrades with too many concurrent connections, so even if you can set max_connections = 1000, it's probably unwise. Idle sessions don't matter much. But concurrently active sessions compete for resources, the bottleneck typically being I/O.

Here is a blog with instructions by someone who did.

¹ Grand Unified Configuration, the PostgreSQL subsystem that handles server configuration

Context

StackExchange Database Administrators Q#95736, answer score: 25

Revisions (0)

No revisions yet.