-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TCP connections much higher than GatewayModeMaxConnectionLimit #1170
Comments
@jesuissur can you try setting the max concurrency on the query to see if it helps reduce the connections? |
At conceptual level each collection data will get sharded/partitioned onto multiple VM's. In Direct mode the SDK will connection to the VM's directly where the data resides, where as in Gateway mode served by an intermediary proxy VM's. Hence Gateway mode can get better connection sharing. For functions/app-services our recommendation is use plan/offer which doesn't have connection limits for better performance (i.e. Direct access) or use Gateway mode. |
@j82w Each one of our query goes to one and only partition, so we guess the max concurrency would not have any effect. And the documentation also states the default value would not do any parallelism |
@kirankumarkolli we already use the Gateway mode. The Azure's plan/offer without outbound connections limit seems overkill for our needs and quite pricey to have the same performance |
@jesuissur stepping through the code it looks like it should be honoring the limit. Can you please answer the following questions.
|
@j82w here are our facts
.Net core 2.2
Windows on Azure App service Plan P2v2 and P3v2. I don't know the specific windows version behind those plans
It is the highest concurrent TCP outbound connections at one moment in time. More info here: https://azure.github.io/AppService/2018/03/01/Deep-Dive-into-TCP-Connections-in-App-Service-Diagnostics.html
We cannot get those stats without the Azure Diagnostic tools because we cannot detect those peaks moment in advance. But pretty sure the Diagnostics tools use something similar to get those in (almost) real time (15 minutes delay) Thanks again |
Hi there We still got massive problem with our connections count above the 500 limit we set as the Gateway's max connections limit. Looking at the SDK code, the only (relevant) place the max connections limit seems to be used is at this place: Does the new Cosmos SDK use the legacy ServicePoint mechanism to connect to Cosmos? |
Are you creating a single CosmosClient for the application or are you creating multiple instances? |
@j82w as we stated in the initial post we create a single CosmosClient through the builder. We've check and recheck this fact.
|
After a few tests from our side, the previous commit indeed fix our problem. This fix is probably not the one you would like in the official release because we use a Gateway setting directly into the CosmosClient. Nonetheless, something like this is missing Thanks |
@jesuissur thanks for investigating. I'll try to get a PR out with a fix before the next release. |
There seems to be a bug for .NET Framework using ServicePointManager. I'm not sure if it's impact .net core. |
Do we have an idea on which release this is slated for? So glad you guys found this. We have been struggling with this for a while. We have tried so many things on the consumer end to fix and could never figure out a solution. |
This PR #1548 needs to go in first. Then this fix can be added. |
Further update, while this did help in some scenarios, it did not help in all. There is still another client being used by the sdk which seems to be making more connections. |
Sweet! Thank you @j82w |
@vsadams and @jesuissur 3.12.0 is released with the fixes. Please create a new issue if you are still seeing an issue. |
Describe the bug
In Gateway mode with
GatewayModeMaxConnectionLimit
around 500, TCP connections used by our Azure App service towards our Cosmos DB goes far beyond the 500 limit.To Reproduce
new CosmosClientBuilder(endpoint, authKey).WithConnectionModeGateway(500).Build()
)client.GetContainer(config.OurDatabase, config.OurDataCollection)
container.GetItemQueryStreamIterator
or write to withawait container.UpsertItemStreamAsync
Our app is living alone on an app service plan ("server")
Expected behavior
We expect to have at most 500 TCP connections towards our Cosmos DB but under some load (5K Cosmos request under 1 minute) we get to the app service's TCP connections limit (in our case, ~4K)
Actual behavior
We got many SocketExceptions resulting in faulted Cosmos Queries.
One of our TCP peak problems:
Environment summary
SDK Version: 3.5.0
OS Version: Windows App service P2v2
Thanks a lot
Phil
The text was updated successfully, but these errors were encountered: