0

I am not using any sort of ORM just the mongo node.js driver in express. Currently I wrap every request in a promise that creates a new mongo client and closes the connection when the promise either succeeds to fails. I am only allowed 750 connections so during a spike if I hit this amount then new requests could not open new connections and so the requests would fail.

I thought a solution to this would be to create a single client connection when the node server starts and set a connection pool to something like 650 (since some of the 750 is reserved for internal stuff.) This way each request no longer created/closed a connection and they just used from the pool, the pool would grow as needed to the 650 number but then just reuse from that pool during a spike.

That was my theory but it seems like somehow the connection got closed (I am guessing a timeout) and since it was just creating a single connection now on server start it never re-opened a new connection after this so it brought my service down.

I have since reverted back to my original strategy. Just wondering if there are some insights here to what I could be doing better?

Your Answer

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

Browse other questions tagged or ask your own question.