I'm developing a real-time notification service using Node.js with Express, MongoDB for data storage, and Socket.IO for real-time communication. The service is intended to be integrated into various websites. However, when I integrate this service into a website with over 100,000 users, the backend experiences performance issues and struggles to handle the high number of connections.
Here's an overview of my setup:
Despite this configuration, the backend experiences performance degradation under heavy loads. What optimizations can I implement to improve the backend's ability to handle a large number of connections efficiently?
I've considered potential solutions such as load balancing, optimizing database queries, and scaling horizontally. However, I'm unsure about the best approach and would appreciate any insights or recommendations from the community.
Thank you in advance for your help!
your first step should be to find out specifically where the performance degradation is happening, try to setup monitoring and timing to figure out where your bottleneck is happening, otherwise it will be difficult for anyone to give you meaningful advice.
Generally horizontal scaling and load balancing are never bad ideas, but you will incur additional server costs. Optimizing your queries will only increase performance if your issue is a mongoDB throughput bottleneck. Node.js is also single threaded, to take full advantage of all of your cores and threads, you'll either need worker threads, child processes, or multiple node.js servers on your box.
But again, I wouldn't advise doing anything until you can figure out precisely where your issue is