You ship a new auth library to one canary pod at 5% weight on the shared LB. The error rate looks fine for ten minutes. You ramp to 25%. Now the error rate jumps — but only for traffic from one large enterprise customer whose SSO flow exercises a code path the other 90% of traffic never touches. You roll back, but in those four minutes 600 of their users hit the broken path, and the support tickets are already arriving. Weight-based canary is a sampling tool, not a coverage tool. If you needed coverage of that customer’s traffic before broad ramp, header-based was the canary you should have shipped.
What’s happening
Canary on the shared PaaS LB has two mechanics. They are not interchangeable — they answer different questions.
- Weight-based split. The LB sends N% of incoming requests to the canary pool and (100−N)% to stable. Useful when you want a statistical sample of real traffic against the new build. The risk is that small N means small sample, and rare-but-important code paths may not be exercised at low weights. Ramp typically goes 1% → 5% → 25% → 50% → 100% with a soak at each step.
- Header-based split. The LB inspects an HTTP header (custom header, cookie, or a feature-flag header set by an upstream service) and routes requests carrying that header to the canary pool. Useful when you want deterministic canary coverage — your own QA team, one internal account, one beta customer, traffic from one geographic region. Risk is zero from the public-traffic perspective, but you only see what the header-carrying traffic exercises.
The practical pattern is to use header-based first (internal team + one consenting beta customer), then weight-based for the broad ramp. If you skip the header phase, you’ve moved the first observation of the new build into production traffic — which is fine for low-risk changes and reckless for anything touching auth, payments, or data writes.
How to verify
Confirm the LB exposes both routing modes on your managed PaaS:
# Inspect the LB's current routing rules
curl -sS -H "Authorization: Bearer $PAAS_TOKEN" \
"https://app.paas.example.com/1.0/lb/rest/getroutingrules?envName=app-prod" \
| jq '.rules[] | {match: .match, target: .targetPool, weight: .weight}'
# Expected (during a canary):
# {"match": {"header": "X-Canary", "value": "true"}, "target": "canary", "weight": 100}
# {"match": {"default": true}, "target": "stable", "weight": 95}
# {"match": {"default": true}, "target": "canary", "weight": 5}
Verify per-pool error rate is being observed separately. If your logs aren’t tagged by pool, you can’t tell whether the canary is failing more than stable:
# Logs should carry the pool label injected by the LB or set by the app from
# an env var that differs between pools
curl -sS "https://logs.example.com/api/v1/query?\
query=rate(http_errors_total{pool=\"canary\"}[5m]) \
/ rate(http_requests_total{pool=\"canary\"}[5m])"
curl -sS "https://logs.example.com/api/v1/query?\
query=rate(http_errors_total{pool=\"stable\"}[5m]) \
/ rate(http_requests_total{pool=\"stable\"}[5m])"
If the canary error rate is statistically worse than stable for more than two consecutive minutes, abort the ramp.
The fix
Phase 1 — header-based canary (deterministic). Deploy the new build to a canary pool sized at one pod minimum. Configure the LB to route requests with X-Canary: true to that pool, regardless of weight.
# canary-header-routing.yaml
lb_rules:
- name: canary-by-header
priority: 100 # higher priority than weight rules
match:
header:
name: X-Canary
value: "true"
target_pool: canary
weight: 100 # 100% of header-matching traffic
- name: stable-default
priority: 1
match:
default: true
target_pool: stable
weight: 100
How to test:
# Direct internal QA against canary
curl -H "X-Canary: true" https://app.example.com/api/v1/login
# Verify it's actually hitting canary by reading the response's pool header
# (LB-injected, common pattern)
curl -sS -I -H "X-Canary: true" https://app.example.com/healthz \
| grep -i "x-served-by-pool"
# Expected: X-Served-By-Pool: canary
Have the internal QA team exercise the new build for 30 minutes. Open it to one consenting beta customer by giving them an account flag that sets X-Canary on outbound requests from your auth gateway. Watch the per-pool error metrics. If the canary holds against that bounded traffic for 60 minutes of business hours, move to Phase 2.
Phase 2 — weight-based ramp (representative). Once header-based has cleared, ramp the weight from 1% → 5% → 25% → 50% → 100% with a soak at each step. The soak is what catches the rare-path regressions weight-based sampling can find.
# canary-weight-ramp.yaml
ramp_schedule:
- weight_percent: 1
soak_minutes: 15
abort_conditions:
- canary_error_rate_above: 0.5 # absolute % error rate
- canary_p99_above_stable_by: 50 # ms
- weight_percent: 5
soak_minutes: 30
abort_conditions:
- canary_error_rate_above: 0.5
- canary_error_rate_above_stable_by: 0.2 # relative — canary should not be 0.2pp worse than stable
- weight_percent: 25
soak_minutes: 60
abort_conditions:
- canary_error_rate_above_stable_by: 0.1
- weight_percent: 50
soak_minutes: 60
- weight_percent: 100
soak_minutes: 0 # full cutover, then keep stable pool warm for rollback
Driver script that walks the ramp and aborts on regression:
#!/usr/bin/env bash
set -euo pipefail
ENV="app-prod"
CANARY_POOL="canary"
STABLE_POOL="stable"
RAMP=(1 5 25 50 100)
SOAK_MINUTES=(15 30 60 60 0)
ABORT_RATE_PP=0.2 # canary must not be more than 0.2pp worse than stable
for i in "${!RAMP[@]}"; do
W=${RAMP[$i]}
SOAK=${SOAK_MINUTES[$i]}
echo "==> Setting canary weight to ${W}%"
curl -fsS -X POST \
-H "Authorization: Bearer ${PAAS_TOKEN}" \
-d "envName=${ENV}&canaryPool=${CANARY_POOL}&stablePool=${STABLE_POOL}&canaryWeight=${W}" \
https://app.paas.example.com/1.0/lb/rest/setweightedsplit
echo "==> Soaking for ${SOAK} minutes"
for m in $(seq 1 "$SOAK"); do
CANARY_ERR=$(curl -sS "https://metrics.example.com/api/v1/query?\
query=rate(http_errors_total{pool=\"${CANARY_POOL}\"}[1m])/rate(http_requests_total{pool=\"${CANARY_POOL}\"}[1m])" \
| jq -r '.data.result[0].value[1]')
STABLE_ERR=$(curl -sS "https://metrics.example.com/api/v1/query?\
query=rate(http_errors_total{pool=\"${STABLE_POOL}\"}[1m])/rate(http_requests_total{pool=\"${STABLE_POOL}\"}[1m])" \
| jq -r '.data.result[0].value[1]')
# Convert to percentage points and compare
DELTA=$(echo "(${CANARY_ERR} - ${STABLE_ERR}) * 100" | bc -l)
echo "minute ${m}/${SOAK}: canary=${CANARY_ERR}, stable=${STABLE_ERR}, delta_pp=${DELTA}"
if (( $(echo "${DELTA} > ${ABORT_RATE_PP}" | bc -l) )); then
echo "ABORT — canary error rate exceeded stable by ${DELTA}pp"
curl -fsS -X POST \
-H "Authorization: Bearer ${PAAS_TOKEN}" \
-d "envName=${ENV}&canaryWeight=0" \
https://app.paas.example.com/1.0/lb/rest/setweightedsplit
exit 2
fi
sleep 60
done
done
echo "Ramp complete at 100%. Keep stable pool warm for at least 24h."
Health-check tuning matters more during canary, not less. A sticky session that lands on a canary pod and survives a transient failure shouldn’t be counted as “canary works” — the LB should mark the pod down briefly, drain it, route the next request to stable:
# canary-pool-healthcheck.yaml
healthcheck:
path: /healthz/deep
interval_seconds: 3 # tighter than stable — canary is the experiment
timeout_seconds: 2
healthy_threshold: 2
unhealthy_threshold: 2 # fail fast — we want canary anomalies to trip the check
drain_seconds: 30
Header-based first, weight-based second. Anything touching identity, billing, or data mutation should never see weight-based ramp without a header-phase precursor.
For canary releases run as part of an environment, Stack Harbor wires the LB routing, ramp schedule, and abort metrics into our deployment management plane on top of managed Cloud PaaS — book a release-pipeline review.