R
Railway•9mo ago
honzasterba

How to change the number of replicas via API?

1) the API introspection in postman does not seem to know about the possibility of updating numReplicas (parsed from dashboard requests 2) I am new to gql so I tried a req that would work: mutation serviceInstanceUpdate { serviceInstanceUpdate( serviceId: "ID", input: { healthcheckTimeout: 300 } ) } but doing the same for numReplicas fails: mutation serviceInstanceUpdate { serviceInstanceUpdate( serviceId: "ID", input: { numReplicas: 5 } ) } with "message": "Problem processing request"
Solution:
Endpoint
https://backboard.railway.app/graphql/internal
https://backboard.railway.app/graphql/internal
Query...
Jump to solution
20 Replies
Brody
Brody•9mo ago
will get you this tomorrow
Solution
Brody
Brody•9mo ago
Endpoint
https://backboard.railway.app/graphql/internal
https://backboard.railway.app/graphql/internal
Query
mutation serviceInstanceUpdate($serviceId: String!, $environmentId: String, $input: ServiceInstanceUpdateInput!) {
serviceInstanceUpdate(serviceId: $serviceId, environmentId: $environmentId, input: $input)
}
mutation serviceInstanceUpdate($serviceId: String!, $environmentId: String, $input: ServiceInstanceUpdateInput!) {
serviceInstanceUpdate(serviceId: $serviceId, environmentId: $environmentId, input: $input)
}
Variables
{
"serviceId": "",
"environmentId": "",
"input": {
"numReplicas": 2
}
}
{
"serviceId": "",
"environmentId": "",
"input": {
"numReplicas": 2
}
}
Brody
Brody•9mo ago
let me know if you need help with anything else, and sorry this took so long
honzasterba
honzasterba•9mo ago
ooh, so I have to go through the internal API, ok I was using the public API endpoint https://backboard.railway.app/graphql/v2
Brody
Brody•9mo ago
yeah you can't update the replica value with the public endpoint internal endpoint accepts the same token though
honzasterba
honzasterba•9mo ago
that was my next question, if the auth is the same, thanks! I suspect the internal may change more frequently 🙂
Brody
Brody•9mo ago
yes it would
honzasterba
honzasterba•9mo ago
I can see that just updating the numreplicas has no effect (other than changing the setting), so I have to trigger a deploy to make it actually stick, right?
Brody
Brody•9mo ago
doing that mutation should trigger a re-deploy I mean it did it my tests, well now I'm second guessing myself I'm probably wrong, you'd want the serviceInstanceRedeploy mutation in that case then
honzasterba
honzasterba•9mo ago
it does not for me, the dashboard changes showing new number of replicas, but redeploy does not happen just a side note, the internal endpoint does not seem to support introspection, not sure if that is intentional
Brody
Brody•9mo ago
yes that's definitely intentional
honzasterba
honzasterba•9mo ago
thanks a lot, I think I have all I need now
Brody
Brody•9mo ago
no problem, if you need anything else don't be afraid to ask
Faraz
Faraz•9mo ago
I think this not being in the public api is an oversight. The internal api is… well, internal. I’ll try to fix this soon.
macwilko
macwilko•9mo ago
I should proably start using this When a store installs my app, initially there's a burst of activity, I need to sync a bunch of data for small stores this is handled with the worker I use for most tasks but for a large store, it's not enough I'de like to maybe play with this API if it's available?
Brody
Brody•9mo ago
theres no auto scaling, even with the api, the original poster intended to roll their own auto scaler
macwilko
macwilko•9mo ago
yeah I could do that
if (new_store_is_large)
add_worker_replica(2, for: 3.hours)
if (new_store_is_large)
add_worker_replica(2, for: 3.hours)
Brody
Brody•9mo ago
new_store_is_large 🤣
macwilko
macwilko•9mo ago
hehe i mean I just had to handle 35k records added to the DB >.< that was heavy when you're using an ORM like ActiveRecord and my web process getting pinged hard from all the webhook events for this store ... groans in developer
Linear
Linear•9mo ago
Issue PRO-1274 created.
PRO-1274 - Add numReplicas to public API
Status
Triage
Assignee
Faraz Patankar
Product