-
Notifications
You must be signed in to change notification settings - Fork 230
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
Socket connection errors #21
Comments
Hi @inancgumus, Have you tuned the mongod connection limits (either in the config or with It seems |
Hi @domodwyer , I didn't try Did you try the above code on your machine? So, maybe you can see the problem directly. These are my config details: ulimit -a:
/usr/local/etc/mongod.conf:
And these are the error messages in mongo log:
|
Now I tried
|
And there are also new errors from
|
Hi @inancgumus I ran your code and I can only reproduce with It's not actually possible to have 500,000 connections as you'll exhaust your ephemeral ports, but your
So you can't open more than 4864 sockets & files combined. When you hit this limit you'll get all sorts of network errors - try checking the number of connections you have open/waiting with This doesn't seem to be a mgo issue - tuning your network stack will help but it really is best to limit concurrent ops in code. Saying that, feel free to reopen if you think it is a mgo issue! Dom |
My DB ops as in the code above and they're very simple and the collection only has a few records. So, I couldn't get what's wrong with them. Is there a problem in the code above? I tried I don't know yet how this is not related to mongo or mgo. I'll investigate the same with other libraries or even directly reaching to mongo. |
The code seems fine, but Running an aggregation (or in this case, loads of parallel aggregations) over all records in your collection obviously takes proportionally long to the number of records, so each query will take longer with every record. This will definitely be holding onto a connection while it completes, meaning you'll need more and more connections to service requests. There might be a more efficient way to do this depending on your needs. Best of luck! |
Actually, all of this investigation started when I was stress testing my web API with |
When
sess.SetPoolLimit(50)
not used many errors are occurring whenmgo
is under stress like 10.000 concurrent connections.When I limit the pool errors went away.
I've created a test-case source-code for this problem below, so you can test it in your own machine easily.
Do you have any suggestions about this behaviour?
The text was updated successfully, but these errors were encountered: