Max Connections for a Postgres Service

Once in a while, it’s useful to know how many connections your Postgres service can support. For example, at Heroku we use this information to help alert us when any of our production-critical databases are approaching their connection limit.

Inspecting a Postgres configuration file will reveal a setting that specifies the maximum number of connections that its associated service will allow:

max_connections = 20

As with other settings, this can be checked by connecting to any running Postgres and executing the following query:

select name, setting from pg_settings where name = 'max_connections';

Protip: you’ll notice that for all our Postgres services at Heroku, from Dev to Ronin, and all the way to Mecha, the response will be 500.

Posted on September 2, 2012 from San Francisco

About

My name is Brandur. I'm a polyglot software engineer and part-time designer working at Heroku in San Francisco, California. I'm a Canadian expat. My name is Icelandic. Drop me a line at brandur@mutelight.org.

Aside from technology, I'm interested in energy and how it relates to our society, travel, longboarding, muay thai, symphonic metal, and the guitar.

If you liked this article, consider finding me on Twitter.