question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TCP connections much higher than GatewayModeMaxConnectionLimit

See original GitHub 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

  1. We got a single CosmosClient built like that (new CosmosClientBuilder(endpoint, authKey).WithConnectionModeGateway(500).Build())
  2. We use a single Container, hence a single database and collection. Code looks like that client.GetContainer(config.OurDatabase, config.OurDataCollection)
  3. From there, we use the container in 2 ways. Either we read from with container.GetItemQueryStreamIterator or write to with await 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: image

Environment summary SDK Version: 3.5.0 OS Version: Windows App service P2v2

Thanks a lot Phil

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
j82wcommented, Jul 9, 2020

This PR https://github.com/Azure/azure-cosmos-dotnet-v3/pull/1548 needs to go in first. Then this fix can be added.

1reaction
j82wcommented, Feb 19, 2020

@jesuissur thanks for investigating. I’ll try to get a PR out with a fix before the next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do high traffic sites service more than 65535 TCP ...
But a server can (theoretically) serve 65535 simultaneous connections per client. So in practice the server is only limited by how much CPU ......
Read more >
EC2 Tuning for +1M TCP Connections using Linux
However it is possible to achieve greater than +10 million connections by moving TCP into User Space using Raw Sockets. TCP / IP...
Read more >
Limiting maximum number of concurrent outgoing TCP/HTTP ...
The system 'outgoing' ports is significantly higher than 65k, you generally should not worry on outgoing connections.
Read more >
Is there a Limit to Number of Connections a Backend can ...
Someone asked me a question and I felt its interesting to make a video about, is there a limit to the maximum number...
Read more >
Unable to open more than ~50k connections between two ...
I have two linux instances in my custom VPC, and I'm trying to test to see how many concurrent TCP connections I can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found