Backend API response is slow even though not using max limits
Anonymous
TRIALOP

2 years ago

Railway metrics says we have a max of 8 vCPUs. The max we're using is only 2.6 vCPUs. But we're still seeing degraded API performance

27 Replies

Anonymous
TRIALOP

2 years ago

3b58a837-a508-4969-a318-7c37050d177e


2 years ago

is your app a nodejs app?


Anonymous
TRIALOP

2 years ago

yes


2 years ago

then there's your answer, nodejs is single threaded so most of the time it can't reach max CPU utilization


2 years ago

you should take a look at replicas


Anonymous
TRIALOP

2 years ago

there is an endpoint that has a lot of external network calls. i tried disabling that and that seems to have fixed it for now.



Anonymous
TRIALOP

2 years ago

i am assuming the degradation was because there were several requests to that endpoint that were still pending so the newer ones were delayed to get response


Anonymous
TRIALOP

2 years ago

i tried using throng: https://www.npmjs.com/package/throng
with a concurrency worker count of 4, but didnt help


2 years ago

yeah, if you want to handle those requests you'll need to scale because nodejs won't magically work just by throwing more resources at it


2 years ago

my guess is that your worker count is too low and you're doing a lot of resource intensive tasks


2 years ago

if you need something more advanced, see https://github.com/taskforcesh/bullmq


2 years ago

then you can have multiple instances of your nodejs app processing a queue


Anonymous
TRIALOP

2 years ago

yeah we use bullmq for something else. we just had huge traffic last few hrs that was not anticipated


Anonymous
TRIALOP

2 years ago

will try out replicas. how does affect billing?


2 years ago

well get your current service usage times your amount of replicas


2 years ago

replicas is just another instance of your application running


Anonymous
TRIALOP

2 years ago

how would multiple throng workers vs. replicas differ?


Anonymous
TRIALOP

2 years ago

does all the replicas share the same 8 vCPUs or do they each get 8 vCPUs?


2 years ago

replicas is the way if you're planning on scaling more than 8vCPUs (or buy the pro plan for 32vCPUs)
throng will only take you to the max of one service resources (8vCPUS or 32vCPUs)


2 years ago

each


Anonymous
TRIALOP

2 years ago

got it. thanks! i suppose using more throng workers might help use the max of all resources currently available


2 years ago

yeah, for now it might fix but you might want to take a look at replicas soon or later


Anonymous
TRIALOP

2 years ago

gonna try that out first as the max being used is just 2.5 vCPUs without throng and around 5 vCPUs with 4 throng workers


Anonymous
TRIALOP

2 years ago

yup will do


2 years ago

yeah launch 7 throng workers and see how it goes


Anonymous
TRIALOP

2 years ago

got it. thank you so much for the support! 🙏


Loading...