Connection limits per plan for Aiven for PostgreSQL®
Find the default max_connections value for each Aiven for PostgreSQL® plan, and learn
how to change it for your service.
By default, Aiven for PostgreSQL® instances limit the number of allowed connections to make sure that the database is able to serve them all.
max_connections defaults
Default values of the max_connections setting vary according to the service plan:
| Plan | Max connections |
|---|---|
| Developer | 15 |
| Free | 20 |
| Hobbyist | 25 |
| Startup/Business/Premium-4 | 100 |
| Startup/Business/Premium-8 | 200 |
| Startup/Business/Premium-16 | 400 |
| Startup/Business/Premium-32 | 800 |
| Startup/Business/Premium-64 and above | 1000 |
Aiven for PostgreSQL doesn't apply a fixed per-GiB connection formula (for example, 100
connections per GiB of RAM). The plan-based defaults in the preceding table are the only
default values, and there's no separate max_connection_limit setting.
max_connections is the only parameter that controls the total number of connections
for your service.
During a connection-exhaustion incident, use an AI assistant connected to Aiven MCP to check current connection usage against the configured limit. For example:
Show the current connection count on
my-pg-service, grouped by role and state, and compare the total withmax_connections.
Reserved connections
Your service does not make all max_connections connections available to your
applications. Aiven reserves some of them for database maintenance and monitoring.
Every Aiven for PostgreSQL service reserves three connections for superuser access,
which Aiven uses to manage the service. Depending on the PostgreSQL version and the
service, Aiven reserves three more connections for monitoring, for a total of six.
Changing max_connections does not change the number of reserved connections.
For example, on a plan with the default max_connections of 100:
- When three connections are reserved, at most 97 remain for your applications.
- When six connections are reserved, at most 94 remain for your applications.
Reserved connections guarantee that Aiven always has capacity available, but Aiven is not limited to them. Monitoring and service management can also use non-reserved connections. The remaining capacity is therefore an upper limit, not a guarantee for your applications.
When you size connection pools, subtract
six from max_connections. This keeps the combined pool size within the limit on any
service.
Increase or decrease max_connections
To increase or decrease the number of allowed connections for your service, set the
max_connections
parameter, which accepts a value from 25 to 60000.
Changing max_connections causes a service restart. If your service has a read
replica, increase the replica's value first. After that change is applied, increase the
primary service's value.
- Console
- CLI
- Terraform
- API
- Log in to Aiven Console, and go to your organization > project > Aiven for PostgreSQL service.
- On the Overview page of your service, select Service settings from the sidebar.
- On the Service settings page, go to the Advanced configuration section, and select Configure.
- Select Add configuration options, add the
max_connectionsparameter, set the value, and select Save configuration.
Run the service update command:
avn service update SERVICE_NAME -c pg.max_connections=VALUE
Set max_connections in the pg_user_config.pg block of the
aiven_pg
resource:
resource "aiven_pg" "example" {
# ...
pg_user_config {
pg {
max_connections = 1000
}
}
}
Call the ServiceUpdate endpoint:
curl --request PUT \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME \
-H 'Authorization: Bearer BEARER_TOKEN' \
-H 'content-type: application/json' \
--data '{
"user_config": {
"pg": {
"max_connections": 1000
}
}
}'
Use connection pooling
When several clients or client threads are connecting to the database, Aiven recommends using connection pooling to limit the number of actual backend connections. Connection pooling is available in all Aiven for PostgreSQL Startup, Business, and Premium plans, and can be configured in the console.
Related pages