api resource_error ai_generated true

503 服务不可用:连接池已耗尽。到达后端最大连接数。

503 Service Unavailable: Connection pool exhausted. Maximum connections to backend reached.

ID: api/rate-limit-connection-pool-exhausted

其他格式: JSON · Markdown 中文 · English
78%修复率
85%置信度
1证据数
2023-09-05首次发现

版本兼容性

版本状态引入弃用备注
Python requests 2.31.0 active
Node.js http module 18.x active
Go net/http 1.21 active

根因分析

客户端HTTP连接池(如requests.Session或Node.js http.Agent)因慢响应或泄漏而无可用连接。

English

Client-side HTTP connection pool (e.g., requests.Session or Node.js http.Agent) has no available connections due to slow responses or leaks.

generic

官方文档

https://docs.python-requests.org/en/latest/user/advanced/#transport-adapters

解决方案

  1. Increase connection pool size and add idle timeout. In Python requests: session = requests.Session(); adapter = requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100, max_retries=3); session.mount('https://', adapter); session.mount('http://', adapter)
  2. Enable connection reuse with keepalive and reduce request timeout. For Node.js: const agent = new http.Agent({ keepAlive: true, maxSockets: 25, timeout: 60000 });
  3. Add retry with exponential backoff for 503 errors to allow connections to be released.

无效尝试

常见但无效的做法:

  1. 60% 失败

    Increasing max_connections arbitrarily without addressing slow backend responses leads to memory exhaustion and worse performance.

  2. 70% 失败

    Restarting the application without adjusting timeout settings causes the pool to exhaust again quickly under load.