R
Railway•2y ago
vas

Will NodeJS 'cluster' package for scaling clash with Railway autoscale?

If I wrap my express code in cluster code starting multiple workers to utilise the CPUs available, will this have any detrimental effects in relation to / will it clash with the general Railway setup and any Railway autoscaling capabilities?
10 Replies
Percy
Percy•2y ago
Project ID: 71f5f58c-00cc-432f-abe7-316387a73153
Brody
Brody•2y ago
it shouldn't, try it out
vas
vasOP•2y ago
Thanks, will do. But in terms of the Railway autoscale capability (and I'm not completely sure what the right question to ask is here...) -> I'm trying to figure out how much I can load up with workers without breaking without actually breaking anything...of course I'll be doing some tests but I'd like to have a little bit of clarity beforehand if possible. for example, what's the worker pool in the default Railway Mongo setup, it looks like I can't change it via the UI, is it the default 5? And assuming I/O loads (not compute loads), and 8vCPUs, would you say >8 workers on the machine would utilise the Railway scaling successfully or would it actually cause problems?
Brody
Brody•2y ago
railway doesnt have autoscale yet, its only a fixed number you define. you cant replicate databases yet. the math for the max amount of workers is (2 * num_cpu) + 1 so 17 workers on the dev plan. but using the max amount of workers is not the right approach, you want to keep cpu usage to a max of 80% (6.4 vcpu) before you add a railway replica. you could reach 80% cpu use with 2 workers, i dont know, its something you will have to play around with, num of workers per replica vs num of replicas
vas
vasOP•2y ago
makes sense, thanks so much, this was very helpful!
Brody
Brody•2y ago
no problem 🙂
luna
luna•2y ago
If you can I would highly suggest using replicas over cluster as this prevents a single node of the cluster taking the whole app down.
vas
vasOP•2y ago
Thanks for the suggestion @ImLunaHey ! That's definitely something I'm looking to do. For now looking to at least utilise each single node a bit more before I use replicas -> do you have any tips on how I can set up (++/--) the replica count programmatically during runtime e.g. through an env var (rather than from the railway cli) ?
luna
luna•2y ago
maybe have a look at the railway API? you might be able todo something with that to automatically scale but im not certain since replicas are a new feature.
Brody
Brody•2y ago
auto scaling is on the to-do list anyway, so personally I wouldn't bother rolling my own solution in favour of waiting for when railway adds a checkbox that says "enable auto replication"
Want results from more Discord servers?
Add your server