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
Scot
Scot3y ago
Where’s your bottleneck The answer also depends on what you’re app is doing
sen.py
sen.pyOP3y ago
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
Scot
Scot3y ago
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
sen.py
sen.pyOP3y ago
(Processing will take time) just want to ensure all of its done and nothing misses and its order is kept
Scot
Scot3y ago
Then just have the handler store the request info in a db Then a different process can do the processing
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
sen.py
sen.pyOP3y ago
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
Scot
Scot3y ago
You need to determine where your bottleneck is, is it cpu, db, network, memory?
sen.py
sen.pyOP3y ago
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
Scot
Scot3y ago
If your issue is db contention, adding more servers won't help, in fact it could make it worse
Scot
Scot3y ago
OpenTelemetry for JavaScript | Honeycomb
OpenTelemetry makes it easy to instrument your code with support for automatic and manual instrumentation.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
sen.py
sen.pyOP3y ago
Mongo But we dont see any spikes in db uses at all
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
sen.py
sen.pyOP3y ago
Not sure the codebase is pretty old and written in js
Want results from more Discord servers?
Add your server