How is these TCP limits documented in App Service plan Limit? I did not see Max Connection limit in the Azure Subscription limit document for App Service.
AppService TCP connections
There is a limitation on number of TCP connections for an AppService instance depending on its pricing tier. Currently to achieve the higher number of TCP connections for applications, increasing the number of AppService instances. Doing this doesn't look like a cost optimal solution, as most of the other AppService resources are pretty much underutilized. Is there any workaround/solution to handle this in a better way? Anything coming up sooner or later?
Sign in to comment
Sort by: Most helpful
Thanks for asking question! Yes you are correct there is a limitation on number of TCP connections for an AppService instance depending on its pricing tier.
The maximum connection limits are the following:
• 1,920 connections per B1/S1/P1 instance
• 3,968 connections per B2/S2/P2 instance
• 8,064 connections per B3/S3/P3 instance
• 64K max upper limit per App Service Environment
Applications that “leak” connections invariably run into these connection limits and will start intermittently failing because calls to remote endpoints fail, with the failures sometimes correlating closely to periods of higher application load.
The likelihood of running into this problem can be substantially mitigated with a few best practices:
- For .NET applications using ADO.NET/EF, use database connection pooling.
- For php/mySql, use persistent database connections.
- For Node.js applications making outbound HTTP/HTTPS calls, configure keep-alives so that outbound connections are reused.
Check: My node application is making excessive outbound calls
- For .NET applications making outbound HTTP/HTTPS calls, pool and reuse instances of System.Net.Http.HttpClient or use Keep-alive connections with System.Net.HttpWebRequest.
Note: Remember to increase the System.Net.ServicePointManager.DefaultConnectionLimit because you’ll otherwise be limited to two concurrent outbound connections to the same endpoint.
Check article which is helpful in minimizing the number of outbound connections using HttpClient
To add avoiding the outbound TCP limits is easier to solve, as the limits are set by the size of your worker. You can see the limits in Sandbox Cross VM Numerical Limits - TCP Connections To avoid outbound TCP limits, you can either increase the size of your workers, or scale out horizontally.
You can also refer to blog on How to deal with the limits of Azure SQL Database maximum logins
Refer: Deep Dive into TCP Connections in App Service Diagnostics
Also, Check out the TCP Connections added to App Service diagnostics for analyzing unhealthy TCP connections.
Let us know how it goes.