System Reliability and Availability Questions
Engineering systems to stay available and recover from failure. Covers redundancy, failover, graceful degradation, availability targets, and reliability trade-offs and safety. Includes SRE fundamentals and capacity-aware reliability design. Frames reliability as a property designed in, not bolted on.
Design a resilience testing program for a globally distributed service handling 1M requests per minute. Describe the testing categories (unit, integration, chaos/fault-injection), environments to run them in, safety limits, telemetry to collect, and how to report and act on findings to improve reliability.
Sample Answer
Requirements & goals:
- Validate correctness, performance, and resilience of a globally distributed service at 1M RPM under real-world failure modes while protecting customers and production SLAs.
- Measure impact against SLOs/error budget and reduce mean time to detect/repair (MTTD/MTTR).
High-level program:
- Testing categories
- Unit & component tests: fast, deterministic; simulate network/storage via mocks; run on every PR.
- Integration & load tests: functional + load/end-to-end (E2E) in pre-prod and dedicated performance envs; include multi-region failure scenarios (region failover, DB primary failover, increased latency).
- Chaos / fault-injection: controlled chaos experiments (latency, packet loss, instance termination, throttling, disk full, DNS failure) in staging and progressively in production with constrained blast radius.
- Environments
- Local/CI: units, lint, static analysis, contract tests.
- Staging (multi-region, production traffic shadowing): integration, performance, chaos experiments that can be safely reverted.
- Canary/Prod with shadow traffic & feature flags: limited-production chaos after passing staging, under strict safety limits.
- Dedicated performance lab: synthetic load to validate 1M RPM capacity and scaling.
- Safety limits and guardrails
- Start with conservative blast radius (single AZ, 1% of traffic); escalate based on success metrics.
- Automated circuit-breakers: global kill-switch, experiment timeouts, auto-rollback, capacity/reservation checks.
- SLO/error-budget gate: no production chaos if error budget exhausted.
- Run experiments in maintenance windows; require on-call and incident response readiness.
- Telemetry to collect
- Business metrics: RPS, success rate, latency P50/P95/P99, error types, user-visible errors.
- Infra metrics: CPU, memory, queue lengths, connection counts, DB replication lag.
- Distributed traces (sampled) with service, region, and request-id; logs correlated with traces.
- Health checks, circuit-breaker state, autoscaling events.
- Experiment metadata: start/end, parameters, blast radius, hypothesis.
- Reporting & action
- Automated dashboards per experiment: pre/post comparison, statistical significance (A/B style), error budget impact.
- Post-experiment report: hypothesis, steps, telemetry snapshots, root cause, remediation actions, risk level.
- Integrate findings into backlog: prioritized fixes, SLO adjustments, runbook updates, automation (e.g., better retries, backpressure).
- Postmortems for failures with RCA, owners, and deadlines; verify fixes with regression chaos tests.
- Quarterly reliability review: trends, recurring failure modes, capacity planning.
Why this works:
- Progressive risk escalation protects customers.
- SLO-driven gating aligns tests to business impact.
- Telemetry + automated analysis turns experiments into actionable engineering work items, continuously improving reliability.
You inherit a legacy service with flaky CI, minimal tests, and frequent production rollbacks. As the technical lead, outline a three-month plan to improve reliability that includes immediate triage steps, medium-term refactors, CI and pipeline changes, test-strategy additions, and metrics to track such as flakiness rate and mean time to recovery (MTTR).
Sample Answer
Month 0 (Immediate triage — first 1–2 weeks)
- Stabilize deploys: enforce a temporary freeze on non-critical releases; require PR sign-off for hotfixes.
- Run a “blast radius” audit: identify top 10 most frequent rollback-causing changes (by service, PR, or owner).
- Add emergency safeguards: enable feature flags for risky features, disable flaky scheduled jobs, turn on read-only mode for failing subsystems if available.
- Triage incidents: create a short runbook template (detection, rollback, communication, owner). Assign a reliability champion for on-call coordination.
Month 1 (Quick wins & CI hygiene)
- Flakiness reduction sprint (2 weeks): identify flaky tests via prior CI logs; quarantine flaky tests in a “flaky/” suite and mark them with tickets to fix.
- Enforce fast feedback: require unit tests + linting to pass locally with pre-commit hooks; fail fast in CI (lint/unit before integration tests).
- Add parallelization and caching to CI to reduce runtime and encourage more frequent builds.
- Introduce basic monitoring dashboards (errors, latency, deployment status) and alerting for high-severity regressions.
Month 2 (Medium-term refactors & pipeline hardening)
- Refactor hotspots: schedule refactors for the top 3 modules responsible for rollbacks — break large deploys into smaller, decoupled components or extract stable APIs.
- Improve CI pipelines: add staged pipelines (build → unit → integration → canary → prod), promote artifact immutability (build once, deploy many).
- Add automated canary/rollback: deploy to small % traffic and use health checks to auto-rollback.
- Implement contract tests for critical service boundaries.
Month 3 (Test strategy, automation, and operational maturity)
- Expand test pyramid: increase fast unit tests, add targeted integration tests, and introduce e2e tests only for critical flows; remove brittle end-to-end coverage for low-value paths.
- Add regression tests tied to every rollback incident (test == incident reproduction) and require a passing regression before re-release.
- Strengthen observability: distributed tracing, request-level logs, SLOs, and runbooks integrated in alerts.
- Knowledge sharing: brown-bag on testing best-practices, pair-programming for refactors, and update onboarding docs.
Metrics to track (baseline + targets)
- Flakiness rate: % of CI runs failing due to non-deterministic tests — aim to reduce by 80% in 3 months.
- Mean Time to Recovery (MTTR): time from incident detection to full recovery — target 50% reduction.
- Change Failure Rate: % of deployments causing rollback — target <5% within 3 months.
- Deployment Frequency: number of successful deploys/week — increase as reliability improves.
- Test coverage (meaningful): % of code covered by fast unit tests for critical modules — target +20% where it matters.
- Pipeline lead time: build → prod time — reduce to enable faster fixes.
Roles & ownership
- Assign reliability champion, CI owner, and module owners for each hotspot. Weekly syncs to review metrics, incidents, and progress.
Why this works
- Immediate controls stop bleeding; short-term fixes reduce noise and speed feedback; medium-term refactors reduce systemic risk; robust CI/pipeline and test strategy prevent regressions; metrics provide objective progress and prioritize work.
What is the difference between liveness and readiness probes in containerized applications? Provide examples of checks you would put in each probe for a service that depends on a database and a message queue, and explain why the checks differ.
Sample Answer
Liveness vs readiness probes: liveness answers "Is this container alive or stuck?" — if it fails, Kubernetes restarts the container. Readiness answers "Is this container ready to serve traffic?" — failing readiness removes the pod from the service load balancer but does not restart it.
Examples for a service that depends on a database and a message queue:
-
Liveness checks (detect deadlocks, hung processes):
- Simple HTTP /healthz that verifies the main thread event loop and that the process responds within a tight timeout.
- Internal self-check: confirm critical worker thread is running and memory/CPU aren’t exhausted.
- Avoid expensive external calls (DB/MQ) because transient external failures shouldn’t cause restarts.
-
Readiness checks (ensure external dependencies are available):
- Lightweight DB connectivity check: perform a quick ping or a simple SELECT 1 with a short timeout.
- MQ connectivity: verify ability to open a channel/connection or check consumer group status.
- Feature flags or migrations: ensure schema version is compatible before marking ready.
Why they differ:
- Liveness focuses on container-internal health (recover by restart). Readiness ensures dependent systems are reachable so traffic isn’t routed to a pod that would fail requests. External, transient dependency failures belong in readiness; persistent internal failures belong in liveness.
How would you design an automated chaos engineering experiment to validate the resilience of a service under partial network partitions and pod evictions while ensuring it is safe to run in production? Include blast radius design, monitoring/rollback hooks, steady-state verification, and success/failure metrics.
Sample Answer
Requirements & constraints:
- Target: validate resilience of a Kubernetes service against partial network partitions and pod evictions in production with zero/controlled user impact.
- Non-functional: must limit blast radius, provide automated rollback/abort, verify steady-state before/after, and produce clear pass/fail metrics aligned to SLOs.
High-level approach:
- Create an automated, orchestrated chaos experiment that:
- Runs in a "canary" slice of real traffic (traffic steering) and on a small % of pods.
- Gradually increases the fault intensity if metrics remain healthy.
- Has automated abort (kill switch) triggers and remediation hooks.
Components:
- Orchestrator: Chaos tool (Chaos Mesh / Litmus / Gremlin) integrated with a pipeline (Argo Rollouts or Jenkins).
- Traffic controller: Service mesh (Istio/Linkerd) or gateway to shift X% of production traffic to an isolated canary namespace.
- Safety & policies: PodDisruptionBudgets, Resource quotas, Admission/NetworkPolicies.
- Observability: Prometheus + Alertmanager, Grafana, distributed tracing (Jaeger/Tempo), logs (ELK/Hosted).
- Automation: Runbook automation (Orchestrator will call remediation scripts), webhook endpoints for abort.
Experiment design (safe-by-default):
-
Steady-state verification (baseline):
- Capture baseline metrics for t0 = 15–30 minutes: request rate, p95/p99 latency, error rate (4xx/5xx), CPU/memory, concurrency, downstream queue lengths, business KPIs (checkout rate).
- Define acceptable thresholds: e.g., error rate < 0.5% AND p95 latency increase < 20% AND throughput decline < 5% relative to baseline. Map to SLOs.
-
Blast radius strategy:
- Traffic-level: shift 1% of production traffic to canary namespace with identical service manifest.
- Pod-level: target up to 1 pod (or 5% of replicas capped at N) initially for eviction/partition.
- Timebox: each stage 2–5 minutes, pause and evaluate.
- Progressive ramp: 1% traffic / 1 pod → 5% / 2 pods → stop if thresholds violated.
-
Fault scenarios:
- Partial network partition: use chaos tool to inject network latency, packet loss, or iptables drop between canary pods and selected downstream services (simulate dependency outage).
- Pod eviction: force podTerminated via kubectl drain-like eviction or kill signal to simulate scheduler preemption.
-
Automation / rollback hooks:
- Abort triggers (immediate rollback if any):
- Error rate > 2× SLO breach OR absolute error rate > X% (e.g., 2%).
- p99 latency > baseline × 2 OR p95 degradation > 50%.
- Throughput drop > 20% or business KPI (checkout/min) drop > 10%.
- Operator manual abort or on-call acknowledgement failure window.
- On abort:
- Orchestrator stops fault injection, reverses traffic shift to 0% canary, and triggers remediation: restart evicted pods, re-open network routes, scale up healthy replicas.
- Create incident with context (metrics, traces, logs) and attach experiment run artifacts.
- Safety interlocks:
- Run only in approved windows (low-traffic), require on-call ACK for production experiments beyond trivial scope.
- Enforce max concurrent experiments per cluster/team.
- Abort triggers (immediate rollback if any):
-
Steady-state verification after experiment:
- Re-measure same baseline metrics for the same duration. Verify metrics returned to within threshold (e.g., within 5% of baseline). Confirm no resource leaks, error spikes settled, and traces show successful retries/backoffs functioning.
Success/failure metrics:
- Success (must meet all):
- Business KPI change ≤ allowable delta (e.g., checkout rate drop ≤ 2%).
- Error rate during experiment ≤ SLO breach threshold and returns to baseline within 5 minutes.
- p95 latency increase ≤ defined threshold (e.g., 20%) and p99 not exceeding catastrophic bound.
- No cascading failures in downstream services (downstream error rate increase limited).
- Recovery time objective (RTO) for evicted pods or partitioned routes ≤ defined RTO (e.g., 2 minutes).
- Failure if any abort trigger fires or recovery fails to meet post-check thresholds.
Observability & diagnostics:
- Dashboards for baseline vs experiment overlays (requests/sec, errors, latency histograms, resource usage).
- Tracing: highlight increased retries, timeouts, or circuit-breaker openings.
- Logs: correlate pod evictions, kubelet/kube-proxy events, network policy denials.
- Post-run report: timeline of injections, metric deltas, traces, decision points, and recommended fixes.
Trade-offs & considerations:
- Smaller blast radius increases safety but may not expose system-wide weaknesses. Use staged progression and targeted chaos to balance.
- Business KPI selection matters. For critical services, prefer heavier simulation in staging with traffic mirroring for production validation.
- Some faults (e.g., large-scale network partition) should be tested in non-production or with synthesized load due to risk.
Example run sequence:
- Approve run, ensure on-call ACK, shift 1% traffic to canary.
- Verify steady-state for 15m.
- Inject 100ms latency + 1% packet loss between canary and DB for 2m.
- Evaluate metrics; if within thresholds, proceed to evict one canary pod.
- Monitor for 5m. If safe, increment traffic to 5% and repeat.
- Finish, stop faults, shift traffic back, verify post-steady-state, and publish report.
This design ensures controlled, observable, and automatable chaos experiments that validate resilience while limiting production risk and providing immediate rollback and remediation when needed.
From the perspective of a software engineer responsible for a small service, describe concrete production-readiness criteria across testing (unit, integration), observability (logs, metrics), performance, security, documentation, runbooks, and deployment pipelines that you would insist on before rolling to production.
Sample Answer
Situation: As the engineer owning a small service, I require concrete production-readiness criteria across testing, observability, performance, security, documentation, runbooks, and deployment before rolling out.
Testing
- Unit tests: ≥80–90% coverage on critical modules; fast (<100ms) and deterministic; run on every PR.
- Integration tests: CI job that spins test DB/mocks external dependencies; exercises major flows (auth, persistence, third‑party calls).
- End-to-end/smoke: lightweight smoke suite that runs post-deploy to staging and after canary.
- Test quality: CI fails on flaky tests; tests assert behavior not implementation.
Observability
- Logs: structured JSON logs (timestamp, trace_id, level, user_id, request_id); log levels and redaction of PII.
- Metrics: request rate, latency (p50/p95/p99), error rate, capacity (concurrency), resource usage (CPU/mem).
- Tracing: distributed traces for request paths with sampling; trace IDs propagated in logs.
- Alerts: alerts for error rate spike, SLO breaches, sustained latency > threshold; alert runbooks linked.
Performance
- Baseline: define acceptable p95 latency and throughput targets.
- Load test: simple load and soak tests in CI/CD or staging that validate targets and memory/leak behavior.
- Resource limits: CPU/memory requests/limits defined; autoscaling rules if applicable.
Security
- Authentication/authorization enforced; least privilege for service accounts.
- Secrets: no secrets in repo; use vault/KMS; environment-based secrets management.
- Dependencies: CVE scan on builds; patch critical vulnerabilities before ship.
- Static analysis: SAST/linter rules in pipeline; rate-limit public endpoints; input validation.
Documentation & Runbooks
- README: service purpose, API contract, config, environment variables, dependencies, data stores, owner.
- Runbook: how to identify incidents, common remediation steps, how to roll back, service-specific diagnostics, links to dashboards and logs.
- On-call notes: escalation path and contact info.
Deployment pipeline
- CI gating: tests, linters, security scans must pass before merge.
- CD policy: deploy to staging -> canary (small % traffic) -> gradual rollout with health checks.
- Rollback: automated or one-click rollback; deployment must be idempotent.
- Deployment visibility: deploy events logged and notify channel.
Acceptance criteria before production: passing CI, defined SLOs and dashboards, runbook available, automated rollback, secrets secured, basic load test green, and at least one on-call person assigned.
Unlock Full Question Bank
Get access to all 6 System Reliability and Availability interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.