Reputation: 2459
We are migrating our website to azure and sometimes have an problem now with the following exception:
An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full
We developed a search engine for long-distance-buses in germany and make thousands of requests to external services per day:
I guess, it are about 250.000 calls per day. More or less all of time are fast an very short. We have a timeout for all external apis with 8sec or less to prevent hanging requests.
The external apis are mostly accessed with the following class: http://pastebin.com/evNUVMXp
It worked fine so far, but everything was running on one machine only. At the moment I have 2 vms for mongodb
and a website for 3 large instances running.
Any ideas what I can do to solve the problem?
Thank you for your help: Sebastian
Upvotes: 3
Views: 5469
Reputation: 12925
Main problem, I had, was with the with CosmosDB client instances. It is recommended that it is used as a static within application.
So, I would suggest to introduce data client to be used as a Singleton.
So usage of it in application would be then like:
DataClientFactory<EntityData>.Instance.DocumentDbRepository
Where DataClientFactory
, implements Singleton patteren, and DocumentDbRepository
implements repository patteren around CosmosDB client API (or your data client, that you are using).
CosmosDB client (and as seems also some others) seems to be designed to be quite aggressive with parallel requests.
Upvotes: 2
Reputation: 27
I believe the server that hosts the database(s) needs to increase the limit of dynamic ports it can allow. The solution is described here.
Best of luck to you.
Upvotes: -1
Reputation: 150
You can try to set
ServicePointManager.DefaultConnectionLimit
to a higher number like 100 for example and test that out.
Here is the documentation:
ServicePoint Manager Class [MSDN]
Upvotes: 0