HTTP 503
cloud
resource_error
ai_generated
true
System.Net.Http.HttpRequestException:主机的连接数限制已超出
System.Net.Http.HttpRequestException: The connection limit for the host was exceeded
ID: cloud/azure-app-service-connection-limit-exceeded
82%修复率
82%置信度
1证据数
2024-06-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Azure App Service Windows 2022 | active | — | — | — |
| .NET 8.0 | active | — | — | — |
根因分析
Azure应用服务计划有默认连接限制(如每个实例300个),因扩展不足或长连接耗尽。
English
Azure App Service plan has a default connection limit (e.g., 300 per instance) that is exhausted due to insufficient scaling or long-lived connections.
官方文档
https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs#connection-limits解决方案
-
Scale out the App Service plan to more instances (e.g., increase instance count from 1 to 3) to distribute connections
-
Enable Always On in App Service settings to prevent idle connection drops and reduce churn
-
Set `ServicePointManager.DefaultConnectionLimit = int.MaxValue` in Global.asax.cs to increase outbound connection limit (if error is outbound)
无效尝试
常见但无效的做法:
-
80% 失败
This only affects outgoing HTTP connections; the error is about incoming connections to the App Service, not outbound.
-
90% 失败
Restart resets connections temporarily but does not address the root cause; connections quickly rebuild and exceed the limit again.
-
70% 失败
Disabling keep-alive may increase connection churn and worsen the issue, as each request opens a new connection.