Scaling Connections in Postgres

Scaling Connections in Postgres

There are a number of applications out there that have a high number of connections to Postgres. What’s high? That all depends on your application, but generally, when you get to the few hundred connections area in Postgres, you’re on the higher end. Anything in the thousands is definitely in the high territory, and even several hundred can put a strain on your application. Generally, a safe level for connections should be somewhere around 300-500 connections. This may seem low if you’re already running with thousands of connections, but it’s likely perfectly fine with pgBouncer taking care of the heavy lifting for you. Let’s drill into why a bit further.

Connection Basics in Postgres

Each new connection to Postgres is a forked process. This process comes with its own memory allocation of roughly 10 MB with at least some load for the query. In this sense, every new connection is already consuming some of those precious resources you want processing queries. For 300 database connections, this is 3 GB of memory going just to managing those connections — memory which could be better used for caching your data.


via Feed

May 19, 2017 at 07:09PM


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s