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.