Deployment Observability and Release Health Questions
Instrumenting and monitoring the delivery process and its outcomes: deployment metrics (including DORA-style measures), pipeline monitoring and troubleshooting, and observability wired into continuous delivery to verify release health. Covers confirming a deployment succeeded, detecting regressions post-release, and diagnosing pipeline failures. Focuses on delivery-time signals, not broad production monitoring or incident response.
You are asked to create an automated canary analysis system that decides promotion based on multiple signals (latency, error rate, CPU, and business metrics). Describe the architecture, statistical tests or heuristics you would use to determine canary health, and how you'd avoid false positives due to noise.
Sample Answer
Requirements & constraints:
- Automated decide promote/rollback for a canary based on latency, error rate, CPU, and biz metrics.
- Low false positives, fast decisions (minutes), support for multiple services, explainable decisions and easy rollback.
High-level architecture:
- Metric collectors (Prometheus/Telegraf) → TSDB → Feature pipeline (windowing, aggregation) → Canary Analysis Engine → Decision API + Control plane (orchestration) → Dashboard & Audit logs.
Key components:
- Ingest & baseline store: maintain rolling historical baseline per service/region/time-of-day.
- Signal processor: compute distributions (p50/p95, error counts, CPU mean), apply smoothing (exponential moving average) and de-noising (outlier truncation).
- Statistical engine:
- For continuous metrics (latency, CPU): use non-parametric Mann–Whitney U or Welch’s t-test on recent canary vs baseline windows; compute effect size (Cliff’s delta).
- For rates (errors, business conversions): use proportion z-test or Bayesian A/B (Beta-Binomial) to estimate posterior uplift and credible intervals.
- Sequential / online testing: use alpha-spending (e.g., O’Brien–Fleming) or Bayesian stopping rules to avoid inflated false positives from repeated looks.
- Multiple comparisons: control FDR with Benjamini–Hochberg across many metrics.
- Decision model: weighted scoring combining significance, effect size, business impact weight; rules for immediate fail (e.g., error rate > X% absolute) and guardrails (SLO breach leads to fail).
- Noise mitigation: rolling windows (e.g., 5–15 min), minimum sample size, smoothing, seasonality-aware baselines, adaptive thresholds (based on variance), reject signals with low power.
- Safety: require N consecutive windows pass or a “canary quorum” across regions; automated rollback via orchestration (Kubernetes, CI/CD); human approval for borderline decisions.
- Observability: explainable report with per-metric p-values, effect sizes, and confidence; replay capability.
Trade-offs:
- Faster decisions risk higher false positives; mitigate with sequential tests and stricter thresholds.
- Complex Bayesian models are robust but harder to explain—use hybrid: Bayesian for business metrics, frequentist for infra metrics.
Example heuristics:
- Require p < 0.01 and effect size > threshold for non-biz metrics OR posterior probability of degradation > 95% for biz metrics.
- If >2 critical metrics fail OR weighted score > threshold → fail; otherwise promote after 3 consecutive passing windows.
This design balances statistical rigor, operational safety, and explainability suitable for SRE-run automated canary promotion.
Design an observability-driven canary rollout plan for a network automation feature that adjusts route preferences. Define the metrics and baselines you'll monitor (control vs canary), thresholds and automated decision rules to promote or rollback, and what instrumentation to add to quickly pinpoint root cause if the canary fails.
Sample Answer
Requirements & constraints:
- Goal: Safely roll out route-preference automation that adjusts path selection without causing reachability or performance regressions.
- Rollout must be observable, automatable (promote/rollback), and fast to diagnose.
Rollout plan (phases):
- Canary %: start 1% of routers/prefixes for 15m, then 5% for 30m, then 25% for 60m, then full.
- Comparison model: always compare canary cohort vs control cohort (matching topology/traffic profile).
Metrics & baselines (control vs canary; collect at 1s–1m resolution):
- Reachability: prefix-reachability ratio (expected vs observed). Baseline: >99.99%.
- Traffic shift: % of traffic diverted (NetFlow/sFlow). Baseline: within ±2% of expected.
- Path stability: BGP update rate (updates/min per-prefix) and route-flap count. Baseline: within +10% of control.
- Convergence time: time from config change to steady-state routes per-prefix. Baseline: median within +20% of control.
- Packet loss and latency: tail (p95/p99) latency and packet loss on critical flows (active probes). Baseline: no more than +1% loss and +10ms latency vs control.
- Control-plane health: CPU, mem, BGP session resets. Baseline: no new BGP resets, CPU delta <10%.
- Error/exception counts from automation agent logs (parsing & structured telemetry).
Thresholds & automated decision rules:
- Soft-warning thresholds trigger increased observation and pause rollout:
- Reachability drop: canary < control by 0.1% -> pause and extend observation.
- BGP updates increase: canary > control + 50% -> pause.
- Packet loss: canary p99 loss > control p99 loss + 0.5% -> pause.
- Hard-rollback thresholds (immediate rollback):
- Any prefix unreachable for >60s (loss of critical prefix).
- BGP session resets count > 3x control in 5m or control-plane CPU spike >30%.
- Traffic shift >10% unexpected (blackholing risk).
- Statistical test: use two-sided bootstrap or t-test for key metrics (p<0.01) over sampling window to detect significant regressions.
- Automation: orchestrator evaluates metrics at end of each phase window. If all soft checks pass, proceed; if any soft failure, hold and notify; if any hard threshold breached or statistical regression detected, trigger automated rollback to previous config and open incident.
Instrumentation to add for fast root-cause:
- Per-change tagging: add rollout-id and cohort tag to routes, BGP community, and telemetry so can identify which routes were modified.
- BGP update streamer: capture time-stamped per-prefix updates (before/during/after change).
- Per-prefix diffs: record intended vs applied preference values and route attributes.
- Structured logs from automation agent (JSON) with correlation ids, timestamps, diff summary, and applied device responses.
- Active probing: synthetic probes to representative prefixes with RTT, loss, traceroute path; collect path-level hops to see where traffic diverges.
- Packet sampling: NetFlow/sFlow with cohort tags to see traffic impact quickly.
- Control-plane metrics: fine-grained per-process metrics (BGP RIB/Adj-RIB-in/out sizes).
- Error traces: capture stacktraces and exception counts from the automation subsystem.
Playbook & observability flows:
- Dashboard: side-by-side control vs canary graphs for all key metrics, with automated annotations for rollout-phase and events.
- Alerting: two tiers — paging for hard thresholds, page+Slack for soft thresholds.
- Runbooks: one-click rollback action exposed in the orchestrator that re-applies previous preferences and validates control metrics recover within 2 windows.
- Post-incident capture: upon pause/rollback automatically snapshot BGP updates, config diffs, agent logs, and NetFlow samples to a retention store for RCA.
Example decision pseudocode:
# simplified: inputs are aggregated metrics for window
if canary.reachability < control.reachability - 0.001:
if canary.reachability < control.reachability - 0.01 or canary.bgp_resets > 3:
rollback()
else:
pause_and_notify()
elif statistically_significant_regression(canary.latency, control.latency, p=0.01):
rollback()
else:
promote_to_next_phase()
Rationale & trade-offs:
- Comparing to control reduces noise from network-wide events.
- Phased % ramps limit blast radius; hard thresholds protect availability.
- Per-change tagging + BGP update streaming makes RCA fast (identify affected prefixes, devices).
- Use statistical tests to avoid false positives from transient spikes.
- Keep rollbacks automated but require human confirmation for cross-datacenter/global promotions.
This plan balances safety, automation, and rapid diagnosis: minimal user impact, clear decision rules, and instrumentation targeted at routing-specific failure modes.
Design a Python-based deployment orchestrator that performs staged canary rollouts with automatic rollback on SLO breaches. Describe the architecture, state model, canary analysis criteria, how to store persistent state, and how to ensure idempotent operations across retries and process restarts.
Sample Answer
Requirements & constraints:
- Staged canary rollouts with configurable stages (percentages/time)
- Automatic rollback when SLO breaches or anomaly detection triggers
- Durable state across restarts, idempotent operations, safe retries
- Python-based controller that integrates with container/orchestration (K8s) and monitoring (Prometheus)
High-level architecture:
- Orchestrator service (Python, asyncio): API + controller loop
- Worker / executor: interacts with K8s (kubectl/k8s client) or infra APIs to shift traffic (Service, VirtualService)
- Metrics adapter: pulls metrics from Prometheus/metrics API and runs analysis
- Persistent store: durable state + event log (Postgres + append-only events table or etcd)
- Leader election: use Kubernetes Leases or etcd to ensure single active leader
- Alerting hook: notify Slack/Pager on rollouts/rollbacks
State model:
- DeploymentRun: id, target_version, start_time, current_stage_index, status (PENDING, IN_PROGRESS, PAUSED, ROLLED_BACK, COMPLETED)
- Stage: index, traffic_pct, duration_seconds, success_criteria, created_at
- StageResult: deployment_run_id, stage_index, metrics_snapshot, verdict (PASS/FAIL), reason
- Event log: append-only records of state transitions for replay and auditing
Persist in Postgres (relational consistency) with WAL-based event log. Use optimistic locking (version column) for CAS updates.
Canary analysis criteria:
- Primary SLOs (latency p99, error_rate, availability) with thresholds and burn rate controls
- Short-term anomaly detection: relative change vs baseline (e.g., error_rate increase > X sigma or relative > Y%)
- Use metrics windows: baseline_window (1h median), canary_window (stage duration), compare with statistical test (Welch's t or non-parametric bootstrap) and burn-rate calculation from SRE playbook
- Decision rules:
- PASS if all SLO deltas within tolerance and no anomalies
- FAIL if SLO breach or burn-rate exceeds configured threshold
- PAUSE if inconclusive (requires manual approval or extended observation)
Idempotency & retries:
- All external operations are expressed as declarative desired state + reconciliation loop (controller reconciles current state -> desired).
- Use resource-level annotations/labels and deterministic operations: e.g., create/update K8s VirtualService weight for version X to N%. Applying same desired state is safe.
- Store last-applied desired state in Postgres and in resource annotation (last-applied-hash). Before applying, compare hash; if equal, skip.
- Operations are transactional where possible: update DB record (transaction) before issuing external change. Use two-phase commit pattern simplified: write intent -> apply -> confirm and write completion event. Reconciliation will retry until confirmation.
- Use unique operation IDs (UUID) for every external API call; persist outcomes to avoid double-applying effects.
- Use optimistic concurrency (version number) when advancing stages; failures cause controller to reload latest state and retry.
Failure modes & recovery:
- Controller restart: leader election yields new leader; leader replays event log and reconciles desired states to real-world resources.
- Partial apply: reconciliation detects divergence and re-applies desired state or issues corrective rollback if stage verdict was FAIL.
- Network flakiness: exponential backoff with idempotent retries; mark long-pending operations and alert if exceeding thresholds.
Security & observability:
- RBAC for K8s API usage; secure credentials in vault
- Extensive metrics: rollout success/failure rates, time per stage, analysis decisions, latencies
- Audit trail: event log + resource annotations for compliance
Example flow:
- Start DeploymentRun with stages [1%, 5%, 25%, 100%]
- Leader writes DeploymentRun row + events
- Controller sets VirtualService weights to 1% (persist desired state)
- Wait stage duration; Metrics adapter runs analysis vs baseline
- If PASS, advance stage (CAS version bump), update desired state to 5%, repeat
- If FAIL, set desired state back to 0%/previous stable, apply rollback, mark DeploymentRun ROLLED_BACK, send alerts
Why this design:
- Declarative + reconciliation ensures idempotency and safe retries
- Event log + Postgres gives durable, auditable state and simplifies recovery
- Statistical + burn-rate checks balance sensitivity and noise
- Leader election and optimistic locking prevent concurrent conflicting actions
Implementation notes:
- Use asyncio + aiokubernetes / kubernetes-client for nonblocking ops
- Use SQLAlchemy + Postgres for state and event log
- Implement analyzers as pluggable modules so thresholds/algorithms can evolve
- Add manual override endpoints for on-call intervention and drift correction
Implement a Python function analyze_canary(baseline_latencies, canary_latencies, baseline_errors, canary_errors) intended for CI integration. The function should compute p95 latency and error rate for baseline and canary and return 'PASS' or 'FAIL' using these criteria: canary_p95 <= baseline_p95 * 1.10 and canary_error_rate <= baseline_error_rate + 0.001. Assume inputs are lists of numbers and include basic sample-size checks and comments.
Sample Answer
Approach: compute p95 by sorting latencies and taking the 95th percentile (interpolated via nearest-rank). Compute error rate as total_errors / total_requests. Validate sample sizes (default minimum 30). Compare against thresholds: canary_p95 <= baseline_p95 * 1.10 and canary_error_rate <= baseline_error_rate + 0.001. Return 'PASS' or 'FAIL'.
import math
def analyze_canary(baseline_latencies, canary_latencies, baseline_errors, canary_errors, min_samples=30):
"""
Compute p95 and error rates for baseline and canary and return 'PASS' or 'FAIL'.
- baseline_latencies, canary_latencies: lists of latency samples (ms)
- baseline_errors, canary_errors: lists of error counts per sample or single integer counts
- min_samples: minimum number of latency samples required for meaningful comparison
"""
# Basic input normalization
def sum_errors(e):
return e if isinstance(e, (int, float)) else sum(e)
b_err = sum_errors(baseline_errors)
c_err = sum_errors(canary_errors)
b_n = len(baseline_latencies)
c_n = len(canary_latencies)
# Sample-size checks
if b_n < min_samples or c_n < min_samples:
raise ValueError(f"Insufficient samples: baseline={b_n}, canary={c_n}, need >= {min_samples}")
if b_n == 0 or c_n == 0:
raise ValueError("Latency lists must be non-empty")
# p95 using nearest-rank method
def p95(latencies):
s = sorted(latencies)
idx = max(0, min(len(s)-1, math.ceil(0.95 * len(s)) - 1))
return s[idx]
baseline_p95 = p95(baseline_latencies)
canary_p95 = p95(canary_latencies)
baseline_error_rate = b_err / b_n
canary_error_rate = c_err / c_n
# Decision thresholds
latency_ok = canary_p95 <= baseline_p95 * 1.10
error_ok = canary_error_rate <= baseline_error_rate + 0.001
return 'PASS' if (latency_ok and error_ok) else 'FAIL'
Key points:
- Nearest-rank p95 is simple and deterministic; for smoother estimates use interpolation (numpy.percentile).
- Time: O(n log n) due to sorting; Space: O(n) for sorted lists.
Edge cases: - Very small sample sizes (handled by min_samples).
- Input error counts as single ints or lists (normalized).
Alternatives: - Use reservoir sampling for streaming data, or approximate quantiles (t-digest) for large-scale production telemetry.
That is every published Deployment Observability and Release Health question for Site Reliability Engineer (SRE) so far. Browse the other topics in this category, or practice this one interactively.