aws resource_error ai_generated true

FATAL: sorry, too many clients already (RDS Proxy connection limit exceeded)

ID: aws/rds-proxy-connection-limit-exceeded

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
1Evidence
2024-01-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
RDS Proxy 1.0.0 active — — —
PostgreSQL 13.7 active — — —
MySQL 8.0.33 active — — —

Root Cause

The RDS Proxy has reached its maximum concurrent connections limit, often due to connection leaks or insufficient proxy capacity.

generic

中文

RDS Proxy 已达到最大并发连接数限制,通常是由于连接泄漏或代理容量不足。

Official Documentation

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.html

Workarounds

  1. 85% success Increase the RDS Proxy's MaxConnectionsPercent in the proxy settings (console or CLI with 'aws rds modify-db-proxy --db-proxy-name myproxy --max-connections-percent 100'). This allows more connections proportional to the database instance's max_connections.
    Increase the RDS Proxy's MaxConnectionsPercent in the proxy settings (console or CLI with 'aws rds modify-db-proxy --db-proxy-name myproxy --max-connections-percent 100'). This allows more connections proportional to the database instance's max_connections.
  2. 90% success Fix connection leaks in the application: ensure database connections are properly closed in all code paths (e.g., using connection pools with 'maxLifetime' and 'idleTimeout' settings). Implement a connection pool library like HikariCP (Java) or pgBouncer (PostgreSQL).
    Fix connection leaks in the application: ensure database connections are properly closed in all code paths (e.g., using connection pools with 'maxLifetime' and 'idleTimeout' settings). Implement a connection pool library like HikariCP (Java) or pgBouncer (PostgreSQL).

中文步骤

  1. 在代理设置中增加 RDS Proxy 的 MaxConnectionsPercent(控制台或使用 CLI 'aws rds modify-db-proxy --db-proxy-name myproxy --max-connections-percent 100')。这允许代理根据数据库实例的 max_connections 按比例处理更多连接。
  2. 修复应用程序中的连接泄漏:确保在所有代码路径中正确关闭数据库连接(例如,使用连接池,设置 'maxLifetime' 和 'idleTimeout')。使用像 HikariCP(Java)或 pgBouncer(PostgreSQL)这样的连接池库。

Dead Ends

Common approaches that don't work:

  1. 60% fail

    Increasing the database instance max_connections without adjusting RDS Proxy's MaxConnectionsPercent parameter still leaves the proxy as the bottleneck.

  2. 40% fail

    Restarting the RDS Proxy doesn't solve the underlying issue of connection leaks from the application; connections will quickly exhaust the limit again.