Multiple replicas based on time
rpuig2001
HOBBYOP

4 months 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 • 4 months ago


4 months ago

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


rpuig2001
HOBBYOP

4 months ago

Thanks a lot for your suggestions!


rpuig2001
HOBBYOP

4 months ago

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


4 months 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

4 months ago

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

Do you have any info for the same?


4 months ago

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


rpuig2001
HOBBYOP

4 months ago

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


4 months 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

4 months ago

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

I could not find any reference…


4 months ago

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


Loading...