Duplicate Services
charlie
PROOP

2 years ago

How do you duplicate services? I have a setup of a single Background Worker, I want to be able to duplicate this service so when I deploy it, my worker requests will go to the duplicate (i.e. backup) server so no jobs get interrupted due to deployment.

16 Replies

charlie
PROOP

2 years ago

Project ID: c61c1785-a8d8-43d0-9d8b-6bd1f69aa3bf


2 years ago

You unfortunately can't duplicate services, although you might find the RAILWAY_DEPLOYMENT_OVERLAP_SECONDS [Railway provided variable]() useful


2 years ago

also the RAILWAY_DEPLOYMENT_DRAINING_SECONDS so that your old deployment can know not to accept any new jobs


charlie
PROOP

2 years ago

Will the old deployment still run in progress jobs? Say I have a job that take 30 minutes


2 years ago

that's completely up to you to design it that way, railway will send a sigterm signal and then your app should finish the jobs it already has and not accept any new jobs, then exit so the new deployment can take over


charlie
PROOP

2 years ago

So I understand, if I have Job X that runs for 30 minutes and at minute 10 I trigger a new deployment the old deployment will continue running Job X (but not accept any new jobs) while in parallel the new deployment will accept new jobs (even though Job X is still running on the old deployment)?


charlie
PROOP

2 years ago

(if that makes sense 😅 )


2 years ago

by default, that's probably not how it's going to work, you would be responsible for correctly configuring those two variables and your worker configuration to behave as mentioned


charlie
PROOP

2 years ago

Which 2 variables are you referring to?


2 years ago

give this thread another slow read over please


charlie
PROOP

2 years ago

(I don't have the context you have which is why I'm trying to understand how Railway is working under the hood)


2 years ago

we have mentioned the two variables and have even linked to the docs page that explains them


charlie
PROOP

2 years ago

Ok the RAILWAY_DEPLOYMENT_OVERLAP_SECONDS and RAILWAY_DEPLOYMENT_DRAINING_SECONDS (I've not used these before, I thought you were referring to length of the jobs)


charlie
PROOP

2 years ago

I think I will have to play around with Railway in a test environment to test this use case as not super clear how this is working and feels a bit black boxy, appreciate your help and sending me in the right direction wrt. the environment variables, thanks!


2 years ago

no problem!


quentin-danjou
PRO

a month ago

Hey @charlie I know it has been quite a while (2 years) but I was wondering if you remember the specificities around these two variables. I think I understand RAILWAY_DEPLOYMENT_OVERLAP_SECONDS being the total time the previous deploy stays alive before getting terminated but the RAILWAY_DEPLOYMENT_DRAINING_SECONDS is still obscure to me in what it does.

EDIT: I found the answer to my question here (for anybody passing by like me): https://station.railway.com/questions/need-clarification-on-the-relationship-b-9532e04c


Loading...