RDSProxy:数据库'mydb'的连接池已耗尽
RDSProxy: Connection pool exhausted for database 'mydb'
ID: cloud/aws-rds-proxy-connection-pool-exhausted
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| RDS Proxy 1.0 | active | — | — | — |
| Aurora MySQL 8.0 | active | — | — | — |
| Aurora PostgreSQL 15 | active | — | — | — |
| RDS for MySQL 8.0 | active | — | — | — |
根因分析
RDS Proxy针对目标数据库的最大连接池大小已满,通常是由于并发连接过多或长时间运行的查询占用连接未释放。
English
RDS Proxy's maximum connection pool size for the target database is reached, often due to too many concurrent connections or long-running queries holding connections open.
官方文档
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.html#rds-proxy-connection-pool解决方案
-
Increase RDS Proxy's MaxConnectionsPercent and SessionPinningFilters in the proxy target group: `aws rds modify-db-proxy-target-group --db-proxy-name my-proxy --target-group-name default --connection-pool-config MaxConnectionsPercent=90,SessionPinningFilters=["EXCLUDE_VARIABLE_SETS"]`. Also increase database max_connections: `aws rds modify-db-instance --db-instance-identifier my-db --db-parameter-group-name custom-params` with max_connections=500.
-
Optimize application code to close connections promptly using connection pooling libraries (e.g., HikariCP with maxLifetime=300000 and idleTimeout=600000). Set connection timeout in AWS Lambda: `import pymysql; conn = pymysql.connect(..., connect_timeout=5, read_timeout=30)`.
无效尝试
常见但无效的做法:
-
80% 失败
RDS Proxy pool size is limited by the database's max_connections; increasing proxy percent alone does not help if the database limit is reached.
-
90% 失败
Restarting clears the pool temporarily, but the application will quickly exhaust it again if connections are not closed properly.
-
75% 失败
Multiple proxy endpoints share the same underlying database connection limit; this only distributes load but does not increase total pool size.