PostgreSQL Connection Limits
By default, all PostgreSQL deployments on Compose start with a connection limit that sets the maximum number of connections allowed to 100. If your deployment is on PostgreSQL 9.5 or later you can control the number of incoming connections allowed to the deployment, increasing the maximum if required.
Before increasing your connection count you might need to scale up your deployment. But before you scale up your deployment, you should consider whether you really need an increased connection limit.
Each PostgreSQL connection consumes RAM for managing the connection or the client using it. The more connections you have, the more RAM you will be using that could instead be used to run the database.
A well-written app typically doesn't need a large number of connections. If you have an app that does need a large number of connections then consider using a tool such as pg_bouncer or a PostgreSQL driver, either of which can pool connections for you. As each connection consumes RAM, you should be looking to minimize their use. You should also check that your application is not holding connections open unnecessarily.
Changing the connection limit
To increase the connection limit:
- From your Deployment Overview view, click Settings to open the Settings view.
- In the Set Connection Limit panel click the arrow to display the available connection limit choices.
- Set your preferred connection limit value.
Setting the connection limit triggers a rolling restart
Clicking Set Connection Limit triggers a rolling restart on your PostgreSQL deployment: if you have a busy database, you might want to choose a quiet period to perform this operation.
- Click Set Connection Limit. The Compose console takes you to the Jobs view where you can view the progress of the rolling restart.
You can also reduce the number of connections. If you've found a particularly greedy client you've been working around that you've now fixed, for example, you can now bring the connection limit back down if you needed to increase it while solving the problem.
Increasing the maximum available limit
You might find that when you try to increase the connection limit you are not able to select a higher value.
In this situation, you can scale up your deployment to make a higher maximum connection limit available.
- From your Deployment Overview view, click Resources to open the Deployment Resources view.
- Click Scale in the bottom-right of the Nodes panel to open the Scale Nodes view.
- Increase your scaling by moving the slider to the right. As the database is scaled up, we add 100 connections to the maximum number of connections for every two units of scale. Two units of scale is equivalent to 2GB of disk storage and 204MB of RAM; on a 1GB PostgreSQL deployment you would add two units by setting the slider at 3GB, at 10GB you would have five units.
- Click Confirm to trigger the rescaling.
For more information on Scaling PostgreSQL deployments, see PostgreSQL Resources and Scaling.
Still Need Help?
If this article didn't solve things, summon a human and get some help
Updated over 3 years ago