deploy.autoscaling.put

Turn on or change an app's replica autoscaling

PUT /deploy/api/apps/{id}/autoscalingIAM deploy:PutAutoscalingChanges stateDestructive

The app scales between minReplicas and maxReplicas machines on one metric: cpu (% of each machine, from the provider, 1–2 min behind), memory (% of each machine) or requests (per second per machine), both measured by the app machine’s agent each minute, or queue (messages waiting in queueId per machine). Target tracking: machines = ceil(measured machines × reading / target); scale-in only below 90 % of target, one machine at a time, never while a machine is younger than 3 minutes. Cooldowns: scaleOutCooldownSeconds since the last scale-out (60), scaleInCooldownSeconds since any change (300). Scale-in takes the newest machine out of the load balancer, waits until its proxy reports no request in flight (or drainSeconds, 30), then deletes it. An app with maxReplicas > 1 sits behind its own load balancer at every size. While on, replicas belongs to the controller (PATCH replicas is 409); off keeps the current count.

Request syntax

PUT /deploy/api/apps/{id}/autoscaling
{
  "minReplicas": "number",
  "maxReplicas": "number",
  "policies": "array of json",
  "scaleOutCooldownSeconds": "number",
  "scaleInCooldownSeconds": "number",
  "drainSeconds": "number"
}

Path parameters

  • idRequired

    string

    Constraints: uuid

Request body

  • minReplicasRequired

    number

    Fewest machines

    Constraints: integer, 1-10

  • maxReplicasRequired

    number

    Most machines; above 1 puts the app behind its load balancer at every size

    Constraints: integer, 1-10

  • policiesRequired

    array of json

    The scaling policy, a list of exactly one

  • scaleOutCooldownSecondsOptional

    number

    Seconds after a scale-out before the next one

    Constraints: integer, 0-3600

    Default: 60

  • scaleInCooldownSecondsOptional

    number

    Seconds after any change before a scale-in

    Constraints: integer, 0-3600

    Default: 300

  • drainSecondsOptional

    number

    Most seconds a machine out of the load balancer may finish its requests before it is deleted

    Constraints: integer, 0-600

    Default: 30

Response

200 with `data`: the app’s autoscaling. 409 for a pooled app or a preview environment; 404 when queueId is not a queue of the organization. The first pass runs at once.

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Fields of data

  • appIdAlways

    string

    The app
  • configAlways

    object, may be null

    null: replicas are fixed
  • config.​minReplicasAlways

    number

    Fewest machines
  • config.​maxReplicasAlways

    number

    Most machines; above 1 puts the app behind its load balancer at every size
  • config.​policiesAlways

    array of object

    The scaling policy, a list of exactly one
  • config.​policies[].​metricAlways

    one of cpu, memory, requests, queue

    What is read per machine: cpu or memory (%), requests (per second), queue (messages waiting)
  • config.​policies[].​targetAlways

    number

    The reading per machine to hold: a percentage (≤ 100), requests per second, or messages
  • config.​policies[].​queueIdWhen present

    string, may be null

    The queue whose backlog is read; only and always for metric queue
  • config.​scaleOutCooldownSecondsWhen present

    number

    Seconds after a scale-out before the next one
  • config.​scaleInCooldownSecondsWhen present

    number

    Seconds after any change before a scale-in
  • config.​drainSecondsWhen present

    number

    Most seconds a machine out of the load balancer may finish its requests before it is deleted
  • stateAlways

    object

    What the controller remembers
  • state.​lastScaleOutAtWhen present

    string, may be null

    The last scale-out
  • state.​lastScaleInAtWhen present

    string, may be null

    The last scale-in
  • state.​lastReadingWhen present

    object, may be null

    The last check
  • state.​lastReading.​atAlways

    string

    When the check ran
  • state.​lastReading.​metricAlways

    one of cpu, memory, requests, queue

    The metric read
  • state.​lastReading.​valueAlways

    number, may be null

    The reading per machine; null when there was none
  • state.​lastReading.​machinesAlways

    number

    Machines measured
  • state.​lastReading.​desiredAlways

    number

    Machines the check asked for
  • state.​lastReading.​noteAlways

    string

    The decision, in a sentence
  • state.​drainingWhen present

    object, may be null

    A machine out of the load balancer, finishing its requests before it is deleted
  • state.​draining.​instanceIdAlways

    string

    The machine
  • state.​draining.​sinceAlways

    string

    When it left the load balancer
  • replicasAlways

    number

    Machines the app runs on now (the controller owns it while on)
  • loadBalancedAlways

    boolean

    Whether the app sits behind its own load balancer
  • machinesAlways

    array of object

    The app’s machines, oldest first
  • machines[].​instanceIdAlways

    string

    The machine’s instance id
  • machines[].​nameAlways

    string, may be null

    Its name
  • machines[].​createdAtAlways

    string

    When it was bought
  • machines[].​drainingAlways

    boolean

    Out of the load balancer, about to be deleted
  • machines[].​requestsInFlightAlways

    number, may be null

    Requests it was serving on its last report; null before its agent sent one
  • metricsAlways

    array of one of cpu, memory, requests, queue

    Metrics an app can scale on
  • historyAlways

    map

    Per-minute series recorded by each pass, oldest first
  • eventsAlways

    array of object

    The 50 newest autoscaling decisions, newest first
  • events[].​atAlways

    string

    When
  • events[].​levelAlways

    string

    info, warn or error
  • events[].​messageAlways

    string

    What was decided or done, and why

Checked against the handlers: every route test validates their answers against this schema.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow deploy:PutAutoscaling on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud deploy autoscaling put id --min-replicas 1 --max-replicas 1 --policies '["example"]'

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_deploy_autoscaling_put.