Shutdown specific replicas/ deploy old replicas without redeploying whole service.
cmanna75
PROOP

25 days ago

Hi reached out the other day about querying and deploying replicas for a specific instance. Got that to work thanks to you all!
I have a follow-up question: when I call serviceInstanceDeployV2 after updating the replica count does that restart all replicas or only the ones being added/removed? For instance if I change the replica count from 2-3 and trigger the deploy, do the 2 instances currently running get redployed as well? And if it does redeploy all replicas is there a workaround to only deploy the new instance on a scale up or only shutdown the specific instance on a scale down?

$10 Bounty

1 Replies

samiam
PRO

23 days ago

Hi - based on my testing, Railway doesn't support rolling updates at this point -- if you change the replica count and call serviceInstanceDeployV2, Railway creates a new set of replicas using the new count and shuts down the old set.

As for a workaround: if your goal is to avoid redeploying healthy instances, I was able to do this by using separate services that run the same image and put a load balancer in front of them.

  • to scale up, you'd create a new service running the same app and add it to the load balancer

  • to scale down, you'd remove a service from the load balancer and destroy it

This approach does require maintaining separate variables/config for each service and may come with additional tradeoffs (you are running separate instances of the same app), but it does give you fine-grained control over which instances restart.

Can you describe a little more about what you are trying to accomplish?
In the example shown here, I have 4 replicas running, and if I wanted to go down to 3, I'd remove service-a from my load balancer and shut down the service. If I wanted to go up to 5 from here, I could spin up service-c with another instance of the app and add it to the loadbalancer service.

Attachments


Loading...