Scale an app
Fixed replicas, autoscaling on CPU, memory, requests or latency, and scale-to-zero
Goal. api runs two instances, then autoscales between one and three instances on CPU.
Fixed replicas
pier set app api --replicas 2
Changes:
~ update app "api" in prod
replicas: 1 → 2 (scaling — applied immediately)
→ Updated pier.yaml
→ Waiting for infrastructure provisioning...
OK Infrastructure ready
OK Updated app "api" in prod
A replica change is applied immediately. The existing container image is reused, so no build is required and the running instance is not rolled.
pier ls apps
NAME STATUS REPLICAS AUTOSCALE IMAGE PORT UPDATED
api running 2/2 - zot.pier-registry.svc.cluster.local:5... 8080 2m ago
Autoscale
pier set app api --autoscale 1-3 --trigger cpu:70
Changes:
~ update app "api" in prod
replicas: 2 → 0 (scaling — applied immediately)
autoscale: off → 1-3 on cpu>70 (policy — applied immediately)
→ Updated pier.yaml
→ Waiting for infrastructure provisioning...
OK Infrastructure ready
OK Updated app "api" in prod
--autoscale min-max replaces the fixed count (the two are exclusive). Triggers, repeatable:
cpu:70, memory:80 (percent of the plan), rps:50 (requests per second per
instance), latency:250ms.
Back to fixed
pier set app api --autoscale off --replicas 1
Changes:
~ update app "api" in prod
replicas: 0 → 1 (scaling — applied immediately)
autoscale: 1-3 on cpu>70 → off (policy — applied immediately)
→ Updated pier.yaml
→ Waiting for infrastructure provisioning...
OK Infrastructure ready
OK Updated app "api" in prod
What changed
targets:
- name: primary
plan: app-s
autoscale:
min: 1
max: 3
triggers:
- type: cpu
target: 70pier set app --stage writes this without applying; pier apply applies it later.
Variations
- Scale to zero:
--autoscale 0-3 --idle-after 10mstops the last instance after ten minutes without traffic; the next request starts one. - A larger instance instead of more instances:
--plan app-m(Plans). A plan change rolls the target. - Per target:
pier set app api/canary --replicas 1scales one target.
See also
Apps · pier set ·
pier monitor