Skip to content

Sub-minute rollback on PaaS: sticky vs auto-replace, what to keep warm

Sub-minute rollback is a property of what you kept warm, not of the rollback button. If the previous build's pods are gone, your rollback is 'redeploy' — and redeploys are not sub-minute.

You ship at 11:50 PM. Twelve minutes after deploy, error rate triples. Somebody hits the “Rollback” button in the PaaS console. The console says “rolling back” for nine minutes. Customers are seeing 500s the entire time. The rollback is not failing — it’s pulling the old image from the registry, building a new pod, waiting for the readiness probe, then doing the same for three more pods. That’s a redeploy, not a rollback. Sub-minute rollback only exists if you kept the old version warm.

What’s happening

Rollback on managed PaaS comes in two shapes that look identical in the UI but behave very differently under pressure:

  • Auto-replace rollback. The current build’s pods are destroyed and the previous build’s pods are spun up from scratch. Time = pull-image + cold-start + readiness-warmup, typically 2–10 minutes per pod, run rolling. Acceptable for non-customer-facing failures. Unacceptable when revenue is on the line.
  • Sticky rollback (warm-pool rollback). The previous build’s pods are kept running on a “stable” pool behind the same LB. Rollback is an LB target swap — usually under 10 seconds end-to-end, plus drain. The cost is twice the running compute during the window where both versions are live.

If your SLA tolerates ten minutes of degradation, auto-replace is fine and your bill stays small. If you need sub-minute, you must keep the previous version warm — and you must keep it warm for long enough that a delayed-onset bug (memory leak, cron-job-triggered failure, queue backlog) is caught while the warm pool still exists.

How to verify

Check whether your PaaS currently keeps a warm pool, and if so for how long:

# Inspect post-deploy pool state
curl -sS -H "Authorization: Bearer ${PAAS_TOKEN}" \
  "https://app.paas.example.com/1.0/environment/control/rest/getenvinfo?envName=app-prod" \
  | jq '.pools[] | {name: .name, version: .imageDigest, active: .isActiveTarget, ttl_seconds: .keepWarmUntil}'

# Expected after a deploy (warm-pool model):
# {"name": "blue",  "version": "sha256:OLD", "active": false, "ttl_seconds": 86400}
# {"name": "green", "version": "sha256:NEW", "active": true,  "ttl_seconds": -1}

If both pools are reported but keepWarmUntil is 0 or already expired, you have an auto-replace rollback regardless of what the UI labels it.

Measure how fast a real rollback would be:

# Dry-run rollback (most managed PaaS expose this; if not, document the procedure)
curl -sS -X POST -H "Authorization: Bearer ${PAAS_TOKEN}" \
  -d "envName=app-prod&dryRun=true" \
  "https://app.paas.example.com/1.0/environment/control/rest/rollback" \
  | jq '{strategy: .strategy, estimatedSeconds: .estimatedDurationSeconds}'

# strategy: "swap_active_pool"  → sub-minute
# strategy: "redeploy_previous" → not sub-minute, period

The fix

Pattern — keep the previous version warm in a stable pool for 24 hours after each deploy.

# rollback-policy.yaml
warm_pool:
  enabled: true
  keep_warm_seconds: 86400          # 24h after the new version goes live
  min_replicas: 2                   # keep at least 2 pods of the old version
                                    # (1 is a single point of failure during rollback)
  shutdown_after_window: true       # auto-tear-down after 24h with no rollback
  pool_label: "previous"

active_pool:
  label: "current"
  health_gate_before_swap: true     # never swap to a pool with failing health

Step 1 — Configure the deploy to leave the old pool warm.

# .github/workflows/deploy-with-warm-rollback.yaml
name: deploy
on:
  workflow_dispatch:
    inputs:
      image_digest:
        required: true
        type: string

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy new pool, KEEP old pool warm
        run: |
          curl -fsS -X POST \
            -H "Authorization: Bearer ${{ secrets.PAAS_TOKEN }}" \
            -d "envName=app-prod&imageRef=registry.example.com/app@${{ inputs.image_digest }}\
              &strategy=blue_green&keepPreviousWarmSeconds=86400" \
            https://app.paas.example.com/1.0/environment/control/rest/deployimage

      - name: Verify both pools exist and old pool is held warm
        run: |
          PREV_TTL=$(curl -fsS -H "Authorization: Bearer ${{ secrets.PAAS_TOKEN }}" \
            "https://app.paas.example.com/1.0/environment/control/rest/getenvinfo?envName=app-prod" \
            | jq -r '.pools[] | select(.isActiveTarget==false) | .keepWarmUntil')

          if [ -z "${PREV_TTL}" ] || [ "${PREV_TTL}" = "null" ]; then
            echo "Previous pool not held warm — rollback would be slow."
            exit 1
          fi
          echo "Previous pool warm until: ${PREV_TTL}"

Step 2 — Rollback runbook (the operator runs this when an incident is called).

#!/usr/bin/env bash
# /opt/runbooks/paas-rollback.sh
# Usage: paas-rollback.sh <env-name> [reason]
set -euo pipefail

ENV="${1:?env name required}"
REASON="${2:-no reason given}"

START=$(date -u +%s)

echo "==> [$(date -u -Iseconds)] Rollback initiated on ${ENV}: ${REASON}"

# 1. Confirm a warm previous pool exists
PREV_POOL=$(curl -fsS -H "Authorization: Bearer ${PAAS_TOKEN}" \
  "https://app.paas.example.com/1.0/environment/control/rest/getenvinfo?envName=${ENV}" \
  | jq -r '.pools[] | select(.isActiveTarget==false) | .name')

if [ -z "${PREV_POOL}" ] || [ "${PREV_POOL}" = "null" ]; then
  echo "No warm previous pool. Falling back to redeploy_previous. This will NOT be sub-minute."
  curl -fsS -X POST -H "Authorization: Bearer ${PAAS_TOKEN}" \
    -d "envName=${ENV}&strategy=redeploy_previous" \
    "https://app.paas.example.com/1.0/environment/control/rest/rollback"
  exit 0
fi

# 2. Pre-swap health gate on the previous pool
PREV_HEALTH=$(curl -fsS -H "Authorization: Bearer ${PAAS_TOKEN}" \
  "https://app.paas.example.com/1.0/environment/control/rest/getpoolhealth?envName=${ENV}&pool=${PREV_POOL}" \
  | jq -r '.healthyPodPercent')

if (( $(echo "${PREV_HEALTH} < 100" | bc -l) )); then
  echo "Previous pool is not 100% healthy (${PREV_HEALTH}%). Aborting."
  echo "Operator decision required: degrade to redeploy_previous OR fix forward."
  exit 2
fi

# 3. Swap the LB target pool
curl -fsS -X POST \
  -H "Authorization: Bearer ${PAAS_TOKEN}" \
  -d "envName=${ENV}&targetPool=${PREV_POOL}" \
  https://app.paas.example.com/1.0/lb/rest/setactivepool

# 4. Confirm cutover
for i in $(seq 1 30); do
  ACTIVE=$(curl -fsS -H "Authorization: Bearer ${PAAS_TOKEN}" \
    "https://app.paas.example.com/1.0/lb/rest/getactivepool?envName=${ENV}" \
    | jq -r '.activePool')
  [ "${ACTIVE}" = "${PREV_POOL}" ] && break
  sleep 1
done

END=$(date -u +%s)
echo "==> [$(date -u -Iseconds)] Rollback complete in $((END-START))s"
echo "==> Active pool is now: ${PREV_POOL}"
echo "==> KEEP the failed pool warm for forensics. Do NOT redeploy on top until root cause is known."

Step 3 — Extend the warm window for risky deploys. A first-of-its-kind release (new framework version, schema-impacting change, dependency major bump) deserves a longer warm window. Memory leaks take hours to manifest; queue-backed bugs only show up when the queue backs up.

# risky-deploy-policy.yaml
deploy_risk_tiers:
  routine:
    keep_warm_seconds: 86400        # 24h
  high_risk:                        # framework major, dep major, schema-impacting
    keep_warm_seconds: 259200       # 72h
  emergency_hotfix:
    keep_warm_seconds: 43200        # 12h (acceptable — hotfix already validated)

  triggers:
    - tag: "high-risk"
      override: high_risk
    - paths: ["package.json", "go.mod", "Cargo.lock", "pyproject.toml"]
      hint: high_risk

Step 4 — Don’t let the warm pool starve the active pool. Both pools draw from the same compute budget on most PaaS. If you halve the active pool’s capacity to fund the warm pool, you’ve introduced a different problem. The cost of sub-minute rollback is honest: you need 2x the headroom of normal steady state for the duration of the warm window.

# capacity-policy.yaml
capacity:
  steady_state_replicas: 4
  warm_window_replicas:
    active: 4                       # full capacity
    warm: 2                         # half of active — enough to handle traffic after swap,
                                    # not enough to handle peak. The first action after rollback
                                    # is to scale the now-active (formerly warm) pool back to 4.
  post_swap_autoscale: true         # auto-scale the (just-promoted) warm pool to full size

Common failure modes you’ll meet:

  • The warm pool went stale. Background data migrations, config rotations, or feature-flag changes happened on the new version. After rollback, the previous version can’t talk to the migrated schema. Mitigation: rollback compatibility on schema (additive-only migrations, no destructive drops within the warm window), and treat feature flags as part of the deployment artifact.
  • Stateful connections. Long-lived WebSockets or SSE connections on the old pool don’t migrate to the new pool — and vice versa during rollback. Mitigation: drain the LB on swap so clients reconnect to the now-active pool. For very long-lived connections, accept that rollback drops them; the alternative is connection-pinning, which limits which pool you can swap to.
  • Database long-running migration. Rolling back the app doesn’t roll back the schema. Mitigation: any schema change ships before the app change, in a backwards-compatible way (add column, dual-write, deploy app, stop writing old column, drop column — never bundled with app deploy).

Sub-minute rollback is operational discipline, not a button. Keep the previous version warm. Make rollback a routine, not a rescue.

For warm-pool capacity, rollback runbooks, and the operator on-call to actually run them, Stack Harbor wires this on top of managed Cloud PaaS with monitoring and on-call — request a release-readiness review.