How to change the number of replicas via API?
honzasterba
PROOP

2 years ago

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"

0 Replies

brody
EMPLOYEE

2 years ago

will get you this tomorrow


brody
EMPLOYEE

2 years ago

Endpoint

https://backboard.railway.app/graphql/internal

Query

mutation serviceInstanceUpdate($serviceId: String!, $environmentId: String, $input: ServiceInstanceUpdateInput!) {
  serviceInstanceUpdate(serviceId: $serviceId, environmentId: $environmentId, input: $input)
}

Variables

{
  "serviceId": "",
  "environmentId": "",
  "input": {
    "numReplicas": 2
  }
}

brody
EMPLOYEE

2 years ago

let me know if you need help with anything else, and sorry this took so long


honzasterba
PROOP

2 years 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
EMPLOYEE

2 years ago

yeah you can't update the replica value with the public endpoint


brody
EMPLOYEE

2 years ago

internal endpoint accepts the same token though


honzasterba
PROOP

2 years ago

that was my next question, if the auth is the same, thanks!
I suspect the internal may change more frequently 🙂


brody
EMPLOYEE

2 years ago

yes it would


honzasterba
PROOP

2 years 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
EMPLOYEE

2 years ago

doing that mutation should trigger a re-deploy


brody
EMPLOYEE

2 years ago

I mean it did it my tests, well now I'm second guessing myself


brody
EMPLOYEE

2 years ago

I'm probably wrong, you'd want the serviceInstanceRedeploy mutation in that case then


honzasterba
PROOP

2 years ago

it does not for me, the dashboard changes showing new number of replicas, but redeploy does not happen


honzasterba
PROOP

2 years ago

just a side note, the internal endpoint does not seem to support introspection, not sure if that is intentional


brody
EMPLOYEE

2 years ago

yes that's definitely intentional


honzasterba
PROOP

2 years ago

thanks a lot, I think I have all I need now


brody
EMPLOYEE

2 years ago

no problem, if you need anything else don't be afraid to ask


fp
EMPLOYEE

2 years ago

I think this not being in the public api is an oversight.


fp
EMPLOYEE

2 years ago

The internal api is… well, internal.


fp
EMPLOYEE

2 years ago

I’ll try to fix this soon.


macwilko
HOBBY

2 years ago

I should proably start using this


macwilko
HOBBY

2 years ago

When a store installs my app, initially there's a burst of activity, I need to sync a bunch of data


macwilko
HOBBY

2 years ago

for small stores this is handled with the worker I use for most tasks


macwilko
HOBBY

2 years ago

but for a large store, it's not enough


macwilko
HOBBY

2 years ago

I'de like to maybe play with this API if it's available?


brody
EMPLOYEE

2 years ago

theres no auto scaling, even with the api, the original poster intended to roll their own auto scaler


macwilko
HOBBY

2 years ago

yeah I could do that


macwilko
HOBBY

2 years ago

if (new_store_is_large)
  add_worker_replica(2, for: 3.hours)

brody
EMPLOYEE

2 years ago

new_store_is_large 🤣


macwilko
HOBBY

2 years ago

hehe


macwilko
HOBBY

2 years ago

i mean I just had to handle 35k records added to the DB >.<


macwilko
HOBBY

2 years ago

that was heavy when you're using an ORM like ActiveRecord


macwilko
HOBBY

2 years ago

and my web process getting pinged hard from all the webhook events for this store … groans in developer


samoriental
PRO

a year ago

any headwind on this?


samoriental
PRO

a year ago

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


samoriental
PRO

a year ago

i can only see numreplicas in the service instance


Loading...