When an RDS for PostgreSQL instance reaches its connection limit, new connections fail. Terminate unnecessary connections to restore access, then apply long-term measures to prevent recurrence.
Problem
When connections to an RDS for PostgreSQL instance exceed the limit, clients receive the following error:
FATAL: remaining connection slots are reserved for non-replication superuser connections
Solution
Short-term solution
Terminate unnecessary connections.
Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.
-
In the left-side navigation pane, choose Autonomy Services > Diagnostics.
-
Click the Session Management tab.
-
On the Session Management page, review active sessions and terminate idle connections. Session Management.
Click End Selected Sessions to terminate specific sessions, or End All Sessions to terminate all active connections.
Long-term solutions
-
Optimize slow queries: Identify and optimize long-running queries to free connections and reduce load. Slow queries.
-
Enable connection pooling: Reduces overhead from frequent connection creation and teardown, helping control server load. Enable or disable connection pooling (PgBouncer).
-
Use a database proxy: Simplifies connection management and improves high availability, performance, and maintainability. Recommended for high primary instance load, read/write splitting, large connection counts, or connection isolation. Database proxy.
-
Upgrade the instance type: If connection pooling and database proxy cannot meet your connection demands, upgrade to an instance type with a higher connection limit.
-
Connection limits per instance type are listed in Primary ApsaraDB RDS for PostgreSQL instance types.
NoteView your current instance type in the Configuration Information section of the Basic Information page.
-
Applies to
-
ApsaraDB RDS for PostgreSQL