I am currently working on a Node.js application used by more than 25,000 people, we primarily use the Sails.js environment, and we got MongoDB. The application runs on an EC2 instance with 30 GB of RAM, the database runs on a Mongolab AWS cluster in that same zone as EC2. We even have an instance of Elastic Cache Redis with a memory capacity of 1.5 GB.
Thus, the main and enormous problem we are facing is LATENCY . When we reach the peak of concurrent users requesting the application, we get several applications with timeouts and sails reaching more than 7.5 GB of RAM, HTTP requests to the API take more than 15 seconds (which is unacceptable), and when they even receive 502 and 504 replies sent by Nginx.
I can notice that Mongo operations are recorded as the main delay problem, however even GET requests take a long time when there is a peak of demand. I canβt access the working servers, I only have the pm2 key metrics monitoring tool (which is really great) and the New Relic alerts.
So, I would like to know a roadmap to deal with these problems, maybe you will be offered more detailed information, so far I can say that the application seems stable when few users are present.
What are the main factors and settings to consider?
I still know what I should do, but I'm not sure about the details or how.
IMHO:
- Cache as much as possible.
- Delay write operations MongoDB.
- Separate Mongo databases with higher write requirements.
- virtualization?
- Configure node settings.
While optimizing the code, I posted another question using stackoverflow with one example code template that I am following .
What are your recommendations and opinions for production applications?
diegoaguilar
source share