Skip to content

Scale CPU

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

Exampleexamples/scale-mode

This guide shows you how to throttle an instance’s CPU when idle and restore it on wake-up, using the sablier.idle.cpu and sablier.active.cpu labels:

# compose.yml
services:
  myapp:
    image: myapp:latest
    restart: unless-stopped
    labels:
      - "sablier.enable=true"
      - "sablier.group=myapp"
      - "sablier.idle.replicas=1"
      - "sablier.idle.cpu=0.1"
      - "sablier.active.cpu=2.0"

In scale mode, Sablier can throttle an instance’s CPU when its session expires and restore it when a new session arrives, instead of stopping the workload. This keeps the instance warm (no cold start) while preventing an idle workload from consuming CPU that active workloads need.

On Docker, CPU values are decimal fractions of one core ("0.5" = half a core). When the session expires, Sablier runs the equivalent of docker update --cpus=0.1 myapp; when a new session is requested it restores --cpus=2.0. The container is never stopped.

    flowchart LR
    active["Active<br/>cpu 2.0"]
    idle["Idle<br/>cpu 0.1"]
    active -->|session expires| idle
    idle -->|new request| active
  

Labels

LabelApplied whenFormat
sablier.idle.cpusession expiresdecimal cores (Docker/Swarm/Podman) or Kubernetes quantity
sablier.active.cpusession requestedsame

Both require sablier.idle.replicas >= 1 so the workload keeps running while idle. See Scale instead of stop for the shared idle/active model.

Provider specifics

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

Same decimal-core format as Docker. Sablier updates the service’s task template.

services:
  myapp:
    image: myapp:latest
    deploy:
      replicas: 1
      labels:
        - "sablier.enable=true"
        - "sablier.group=myapp"
        - "sablier.idle.replicas=1"
        - "sablier.idle.cpu=0.1"
        - "sablier.active.cpu=2.0"