R
Railway•15mo 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
21 Replies
Brody
Brody•15mo ago
will get you this tomorrow
Solution
Brody
Brody•14mo 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•14mo ago
let me know if you need help with anything else, and sorry this took so long
honzasterba
honzasterbaOP•14mo 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•14mo ago
yeah you can't update the replica value with the public endpoint internal endpoint accepts the same token though
honzasterba
honzasterbaOP•14mo ago
that was my next question, if the auth is the same, thanks! I suspect the internal may change more frequently 🙂
Brody
Brody•14mo ago
yes it would
honzasterba
honzasterbaOP•14mo 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•14mo 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
honzasterbaOP•14mo 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•14mo ago
yes that's definitely intentional
honzasterba
honzasterbaOP•14mo ago
thanks a lot, I think I have all I need now
Brody
Brody•14mo ago
no problem, if you need anything else don't be afraid to ask
Faraz
Faraz•14mo 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•14mo 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•14mo ago
theres no auto scaling, even with the api, the original poster intended to roll their own auto scaler
macwilko
macwilko•14mo 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•14mo ago
new_store_is_large 🤣
macwilko
macwilko•14mo 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•14mo ago
Issue PRO-1274 created.
PRO-1274 - Add numReplicas to public API
Status
Triage
Assignee
Faraz Patankar
Product
sam.oriental
sam.oriental•5mo ago
any headwind on this? serviceInstance(environmentId: $environmentId, serviceId: $serviceId) {\n __typename\n buildCommand\n builder\n createdAt\n cronSchedule\n deletedAt\n # domains\n environmentId\n healthcheckPath\n healthcheckTimeout\n id\n isUpdatable\n # latestDeployment\n nextCronRunAt\n nixpacksPlan\n numReplicas\n railwayConfigFile\n region\n restartPolicyMaxRetries\n restartPolicyType\n rootDirectory\n serviceId\n sleepApplication\n # source\n startCommand\n updatedAt\n upstreamUrl\n watchPatterns\n }\n}", "variables": "{\n\t"environmentId": null,\n\t"serviceId": null\n}"}}, "url": {"raw": "https://backboard.railway.app/graphql/v2", "protocol": "https", "host": ["backboard", "railway", "app"], "path": ["graphql", "v2"]}, "description": "Get a service instance i can only see numreplicas in the service instance
Want results from more Discord servers?
Add your server