Multiple replicas based on time
rpuig2001
HOBBYOP

21 days ago

Hello,
Not an issue, but a possible enhancement for my service 🙂
I have a nestjs service running with 3 replicas.
I would like to enable the 3 replicas only during afternoon times and during the morening and night times, keep a signle replica.

Would that be possible?

Solved$10 Bounty

12 Replies

https://github.com/railwayapp/cli/blob/master/src/commands/scale.rs
Think you can use the Railway CLI to modify the amount of replicas


Status changed to Solved brody • 21 days ago


noahd
EMPLOYEE

21 days ago

On that, the CLI interacts via graphql so you are able to do it that way too


rpuig2001
HOBBYOP

21 days ago

Thanks a lot for your suggestions!


rpuig2001
HOBBYOP

20 days ago

I checked and indeed can be manually triggered from the CLI. But is it possible to do it automatically?


noahd
EMPLOYEE

20 days ago

There is no first party way to do this right now. You would have to set up an automation with the graphql public api


rpuig2001
HOBBYOP

20 days ago

Unfortunately, I could not find any similar implementation, documentation or example to scale replicas.

Do you have any info for the same?


brody
EMPLOYEE

20 days ago

Pepper has linked the source code for the scale command above.


rpuig2001
HOBBYOP

20 days ago

But it is not yet clear for me how to practically use it…


brody
EMPLOYEE

20 days ago

The code shows you how to use the API to scale up or down a Railway service. You can take that code, rewrite it into a language you are comfortable with, mix in your own business logic, and you will eventually come to the solution you want.


You can probably spin up a secondary service in Railway where it only calls the CLI/GraphQL endpointse periodically based on cron jobs


rpuig2001
HOBBYOP

20 days ago

And here comes my point. Which is the endpoint for scaling?

I could not find any reference…


brody
EMPLOYEE

19 days ago

The CLI is open source; you can see what GQL calls it makes and to where.


Loading...