Skip to content
Stackship documentation Svenska

Container instancesUsers

Scale a component

Set how many replicas a component runs, let it autoscale on CPU, or give it a bigger compute plan.

Requires: containerinstance/write

Every component is scaled on its own, in its edit sheet: on the Components tab choose Edit in the component's menu (…), change Replicas, Compute Plan or Scaling, and choose Save changes.

Set the replica count

Replicas is how many copies of the component run, from 0 to 10. 0 stops the component; the instance still reports Running while its other components run, and Stopped once none do. Changing only the count starts or removes pods and leaves the running ones alone.

A component with a persistent volume runs 0 or 1 replicas: its disk can be attached to one pod only.

Autoscale on CPU

Set Scaling to Autoscale (HPA) — scale on CPU usage and fill in:

  • Min replicas — at least 1.
  • Max replicas — at least the minimum and at most 10.
  • Target CPU % — the average CPU use, as a percentage of the compute plan's CPU, that the autoscaler aims for: 1 to 100, 80 to begin with.

While autoscaling is on, the autoscaler owns the replica count and Replicas cannot be edited. Autoscaling follows CPU only; a component that runs short of memory needs a bigger compute plan, not more replicas. It is not offered for a component with a persistent volume.

Important

Stopping the instance removes its autoscalers and sets their components to 0. Start creates the autoscalers again, but an autoscaler does not scale up a component that is at 0, so the component stays stopped. Set its Scaling to Manual — fixed replica count with a count above 0, save, and then turn autoscaling on again.

Set Scaling back to Manual — fixed replica count to return to a fixed count.

Change the compute plan

Compute Plan sets the CPU and memory of the whole component. Changing it replaces the component's pods with pods that have the new limits. The plans are listed in Compute plans.

  • A plan is shared by the component's containers: it is divided evenly between its main containers, and each init container gets the whole plan while it runs.
  • A container gets exactly its share — what it may use is what it is given.
  • When the boundary allows only some plans, the others are shown but cannot be chosen, with the reason. A component already running on a plan that is no longer allowed keeps it until you change it; the platform refuses a change to a plan that is not allowed.

With the CLI

stsh ci scale sets every component of the instance to the same replica count, and needs containerinstance/scale:

bash
stsh ci scale worker -g my-resource-group --replicas 3
stsh ci scale worker -g my-resource-group

Without --replicas it shows the largest replica count among the components. A count above 1 is refused when a component has a persistent volume. To scale components differently, update the instance's components through the API — see Add volumes and files.