3

I was running MongoDB 2.4 with a replica set which contains 1 primary, 1 secondary and an arbiter. We were using PyMongo 2.6 and MongoEngine 0.8.2.

Recently, we performed an upgrade to MongoDB 2.6, and also upgraded PyMongo to 2.7.2 and MongoEngine to 0.8.7. This setup worked fine for almost 12 hours, after which we started getting the below error:

[initandlisten] connection refused because too many open connections: 819

The ulimit is 1024 which worked perfectly with MongoDB 2.4* and hence we have not increased it. Increasing it might solve the problem temporarily but we will hit it again in the future. Somehow the root cause seems to be the inability of PyMongo to close the connections. Any pointers why this happens?


*When using MongoDB 2.4 with PyMongo 2.7.2 and MongoEngine 0.8.7, everything works well and the max connections are about 250. It is only with MongoDB 2.6, PyMongo 2.7.2 and MongoEngine 0.8.7 that the number of connections shoots up to 819.

1

So after a lot of struggle and a lot of load testing, we solved the problem by upgrading PyMongo to 2.8.1. PyMongo 2.7.2 is the first version to support MongoDB 2.6 and it sure does have some problems handling connections. Upgrading to PyMongo 2.8.1 helped us resolve the issue. With the same load, the connections do not exceed 250-300.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.