Scale Node+express
Having issues with handling large amount of incoming requests as server responds 504 soon, Currently running pm2 to handle multiple of them at same time where single user will have multiple requests sent over period of time.
Is there way to queue these incoming request and guaranteed consume them in order (Also need to keep the order each users requests in mind like A1, A2, A3 should be ordered from user A but B1. B2, B3 can be processed in parallel)
15 Replies
Where’s your bottleneck
The answer also depends on what you’re app is doing
Bottle neck will be we are not able to process all the incoming messages at once, as it could be 20/msgs or more but if that happens it should not just start breaking and keep process those messages
Right but what does processing entail
Even a single node instance should be able to handle 20 msg/s
Is your db slow? Is you’re node doing a bunch of blocking cpu work?
Do the messages need to return a result to the caller straight away or does it not care
(Processing will take time) just want to ensure all of its done and nothing misses and its order is kept
Then just have the handler store the request info in a db
Then a different process can do the processing
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Profiling seems to be a better longer term solutions which we will soon do but for now need to do it quickly
Already using pm2, how is it different? I can see the article suggest pm2
You need to determine where your bottleneck is, is it cpu, db, network, memory?
Ive seen people using profiler to do this, any good article that explain all of this maybe?
As it would be better for longer time
If your issue is db contention, adding more servers won't help, in fact it could make it worse
OpenTelemetry for JavaScript | Honeycomb
OpenTelemetry makes it easy to instrument your code with support for automatic and manual instrumentation.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Mongo
But we dont see any spikes in db uses at all
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Not sure the codebase is pretty old and written in js