Horizontal Scaling -- Scaling controls
samoriental
PROOP

a year ago

We're currently using Railway to host a critical node microservice that processes long-running tasks. Our architecture utilizes BullMQ for task distribution from a coordinator across multiple node workers. I would like some guidance on the ability to control how my scaling is done:

When downscaling, we need to ensure that the long tasks are not abruptly terminated, causing a data loss. Is it possible to target and gracefully kill specific replicas? This would allow us to implement a controlled downscaling process where we can ensure all tasks on a replica are completed before it's terminated.

We're considering using process.exit(0) call if it works. Would this approach work within your infra? If so, at what point in the scaling process should we trigger this - before or after making the API call to reduce the number of replicas?

Currently im planning on using the railway API to add and remove replicas but I don't know how to control how these actions are completed. Internally I can track the RAILWAYREPLICAID without an issue but I have no way to target a replica in any of the actions.

Thanks!

25 Replies

samoriental
PROOP

a year ago

5ffdeb0b-59bc-4b91-9046-48f61f35249e


brody
EMPLOYEE

a year ago

question, how much resources does an idle worker use?


samoriental
PROOP

a year ago

prob like 10gb of memory because it has a couple hundred counccurrent ws connections


samoriental
PROOP

a year ago

i guess i could kill those ws connections


brody
EMPLOYEE

a year ago

thats a lot of memory for only a couple hundred connections…


samoriental
PROOP

a year ago

its a lot of data lol


brody
EMPLOYEE

a year ago

yeah but when its idle why would there be data flowing?


samoriental
PROOP

a year ago

because accounts would be marked as inactive but still have running tasks


samoriental
PROOP

a year ago

i could poll prisma and kill on the node


brody
EMPLOYEE

a year ago

respectfully, this sounds like a architecture issue that you are trying to patch with replicas and a home grown autoscaler


brody
EMPLOYEE

a year ago

ideally, you would run say 5 replicas, and each of those replicas would use a small amount of memory at idle and then each scale vertically when needed


brody
EMPLOYEE

a year ago

imo architecting your app to run like this is going to be a far better use of your time


samoriental
PROOP

a year ago

the issue is each nodes operations are statful but i guess keeping 10 - 20 replicas is a good idea


brody
EMPLOYEE

a year ago

and will scale better!


samoriental
PROOP

a year ago

i agree, thanks for the insight


samoriental
PROOP

a year ago

also thanks for the quick support


samoriental
PROOP

a year ago

i just have scaling to zero in my mind too much


samoriental
PROOP

a year ago


samoriental
PROOP

a year ago

i work a lot with stateless infra so im used to doing it this way. but i agree with what your saying and i think thats the best approach


samoriental
PROOP

a year ago

thanks again!


brody
EMPLOYEE

a year ago

you are on the right track, but you want your workers to be able to scale to near zero.. vertically instead


samoriental
PROOP

a year ago

sent over some trains on the site in your bio to comp you for your time! once again i appreciate your help


brody
EMPLOYEE

a year ago

oh wow, thank you very much!!


brody
EMPLOYEE

a year ago

side note, you now have the pro badge


samoriental
PROOP

a year ago

<:ok:1095784853531803700>


Loading...