We are in the process of investigating response issues of our, express based, node.js (10.x) app, since customers are indicating our API endpoints don’t always respond in a timely manner and sometimes they get 504s.
Since this first started with an increased request count, we moved from a 1 core VM (Ubuntu Linux in Azure) to a 4 core VM and then switched pm2 to use cluster mode with 4 instances. This seemed to make a difference at lower loads, but then we started getting the same complaints.
Given the issue, it makes me wonder whether moving to have 4 non-clustered instances and with nginx doing the load balancing across would be more beneficial?
For anyone who has dealt with a similar situation, have you seen any performance and responsiveness advantages for each scenario?
Are there any other recommendations (based on good practice and experience) of how we could approach the issue?
BTW as a separate effort we are looking into profiling our app and also our database connections.