Skip to content

Scale memory

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

Exampleexamples/scale-mode

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

# compose.yml
services:
  myapp:
    image: myapp:latest
    restart: unless-stopped
    labels:
      - "sablier.enable=true"
      - "sablier.group=myapp"
      - "sablier.idle.replicas=1"
      - "sablier.idle.memory=64m"
      - "sablier.active.memory=512m"

In scale mode, Sablier can cap an instance’s memory when idle and restore it on wake-up, keeping the workload running instead of stopping it.

On Docker, memory values use Docker-style suffixes (b, k, m, g). On session expiry Sablier runs the equivalent of docker update --memory=64m myapp and restores --memory=512m on wake-up.

    flowchart LR
    active["Active<br/>memory 512m"]
    idle["Idle<br/>memory 64m"]
    active -->|session expires| idle
    idle -->|new request| active
  
Docker requires the memory swap limit to be updated together with the memory limit. Sablier sets MemorySwap equal to Memory automatically, which disables swap for the container.

Labels

LabelApplied whenFormat
sablier.idle.memorysession expiresDocker units (b, k, m, g) or Kubernetes quantity
sablier.active.memorysession requestedsame

Both require sablier.idle.replicas >= 1. See Scale instead of stop for the shared model.

Provider specifics

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

Same units as Docker.

services:
  myapp:
    image: myapp:latest
    deploy:
      replicas: 1
      labels:
        - "sablier.enable=true"
        - "sablier.group=myapp"
        - "sablier.idle.replicas=1"
        - "sablier.idle.memory=64m"
        - "sablier.active.memory=512m"