Skip to content
Scale instead of stop

Scale instead of stop

Partially Docker compatiblePartially Docker Swarm compatiblePartially Kubernetes compatiblePartially Podman compatibleProxmox LXC incompatible

Exampleexamples/scale-mode

This guide shows you how to scale a workload down instead of stopping it, using the sablier.idle.replicas and sablier.active.replicas labels:

# compose.yml
services:
  myapp:
    image: myapp:latest
    labels:
      - "sablier.enable=true"
      - "sablier.group=myapp"
      - "sablier.idle.replicas=1"
      - "sablier.active.replicas=2"

Scale mode is an alternative to stopping containers: instead of shutting down and restarting the workload, Sablier scales down the replica count when the session expires and restores it when a new session is requested.

Optionally, when sablier.idle.replicas >= 1, the workload keeps running at the idle replica count with throttled resources (CPU, memory, and block I/O on Docker), and the resources are restored when a new session arrives. This eliminates cold-start latency at the cost of keeping the workload alive.

    flowchart LR
    active["Active<br/>active replicas and resources"]
    idle["Idle<br/>fewer replicas, throttled CPU and memory"]
    active -->|session expires| idle
    idle -->|new request| active
  

Idle and active profiles

Every scale-mode label comes in an idle and an active variant:

  • idle.* is applied when the session expires.
  • active.* is restored when a new session is requested.
LabelFormatDefaultExample
sablier.idle.replicasInteger0 (stop)"1"
sablier.active.replicasInteger1"2"
sablier.idle.cpu / sablier.active.cpusee Scale CPUnone"0.1", "500m"
sablier.idle.memory / sablier.active.memorysee Scale memorynone"64m", "128Mi"
sablier.idle.blkio-* / sablier.active.blkio-*see Scale block I/Onone"100", "/dev/sda:10m"

When sablier.idle.replicas is 0 (the default), Sablier stops the workload on session expiry and restarts it on demand. Set it to 1 or higher to keep the workload running with optional resource throttling.

A limit set on the idle profile is not cleared automatically on wake-up. Set the corresponding active label to restore it.

Provider specifics

See Applying labels for how each provider expresses labels; below are this feature’s values.

CPU is decimal cores ("0.5" = half a core); memory uses Docker suffixes (b, k, m, g). On session expiry Sablier runs the equivalent of docker update with the idle limits and restores the active limits on wake-up. The container is never stopped.

Per-resource guides