I have 7 NodeJS with Mongoose webservices running in a small instance on Amazon AWS and a MongoDB in another small instance.
Everything works with low usage (both cpu, memory and network traffic), without any high peaks.
But some times it seems that these NodeJS services loses connection with MongoDB. All methods from services that do not use Mongoose keep working normally. The ones that uses Mongoose keep in an endless call without any response. I need to restart the services to they respond again.
It happens randomly and there is no pattern I could figure out.
Another strange thing is that in average all services stop together. It`s rare to happen with just one, but happens.
I could try separating all services into a single server each, but it would be very expensive. But first I would like to find out what is happening and fix it up.
Can someone help me?
Trying adding option '?auto_reconnect=true' to the connection string may be solve your problem.
But, according to the documentation Mongoose enables auto_reconnect by default.
There is may be more chance to understand what happens, if you post logs of your node.js and mongodb servers.