Designing a Safe Release and Reliability Plan for a Fleet Event Pipeline
System DesignModel answerLast updated
Design an end-to-end reliability plan for an event-ingestion service: guarded dependency calls, SLO-based alerting, reversible schema changes, and a canary pipeline with automatic rollback.
Context
You own a service that ingests a continuous stream of events from a large fleet of connected cars: diagnostics, position, battery state and similar. For each event the service:
- validates it against a schema,
- looks up extra vehicle information from a separate metadata service,
- stores the enriched record in a primary database.
Two things can hurt this system badly: a faulty release that reaches every instance at once, and a prolonged outage of the metadata service. Either one can lead to lost data and a flood of alerts.
What to produce
Write up a design that connects the four areas below into one coherent reliability and delivery approach. Prefer concrete mechanisms (specific status codes, timeouts, percentages, migration phases) over general definitions.
1. Protecting the metadata dependency
- Describe how the service calls the metadata service.
- Define the circuit breaker's
Closed,OpenandHalf-Openstates, including trip thresholds, timeouts, recovery behavior and what happens to events while the dependency is unhealthy.
2. Monitoring that leads to action
- Propose 2-3 SLIs with matching SLOs for the pipeline.
- Explain which symptoms should wake someone up and which should only produce low-urgency diagnostics, so that on-call does not suffer alert fatigue.
3. Schema changes that allow rollback
- Describe how database migrations are sequenced relative to application releases.
- Walk through the expand-and-contract pattern so that the previous application version keeps working after a rollback, with no runtime errors or data corruption.
4. Delivery pipeline and canary checks
- Outline a pipeline that uses canary or blue/green stages.
- State the metrics, baseline comparison method and automatic rollback conditions applied during the canary period, before a full rollout.
State your assumptions about scale and latency up front and explain why you chose your numbers.
Hints
Hint 1
Start by stating assumptions (event rate, baseline latency of the metadata service, idempotency key). Derive timeouts and bulkhead sizes from them rather than picking arbitrary values.
Hint 2
Decide what the fallback does with data: the safest choice is to degrade (cached or un-enriched records flagged for later backfill) rather than drop, and to reserve the dead-letter queue for genuinely invalid events.
Hint 3
Link the areas: the SLOs define paging and also feed the canary gates, and expand-and-contract is what makes an automatic rollback safe. Make each link explicit.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Framing
The four areas depend on one another. The breaker's fallback decides which signals deserve a page. The SLOs supply the canary's pass/fail criteria. Backward-compatible migrations are what allow an automated rollback to be trusted. I would say this at the start and then commit to numbers.
Assumptions
- Around 1M vehicles, one event per 10 s each, so about 100k events/s at peak.
- Vehicles hit a gateway that writes to a durable log (Kafka). Workers consume, validate, enrich and write to the datastore.
- The metadata service has a p99 of roughly 50 ms.
- No silent loss. Writes are idempotent, keyed by
event_id. - Safety-critical events (crash, thermal, airbag) bypass enrichment entirely, so a sick dependency can never delay them.
1. Dependency protection
Call policy
- Timeout 150 ms, about 3x the downstream p99. Never rely on library defaults.
- At most one retry, with 20-50 ms jittered backoff, only for connection errors,
503and429(honoringRetry-After). Do not retry other4xxresponses: they are deterministic. Cache a404as a negative entry. - Bulkhead of around 200 concurrent calls per instance, so a slow dependency cannot exhaust threads or stall consumer polling.
Breaker states
| State | Behavior | Transition |
|---|---|---|
| Closed | Calls pass. Track a 10 s sliding window, minimum 100 calls. | Open when failures (5xx, 429, timeouts) reach 50%, or slow calls (>150 ms) reach 80%. |
| Open | Short-circuit directly to the fallback. | After 30 s go Half-Open. Repeated trips lengthen the wait exponentially up to about 5 min. |
| Half-Open | Allow 10 probe calls. | Close if at least 9 succeed, otherwise reopen. |
Fallback: degrade, don't drop
- Serve from a local LRU cache keyed by VIN (1 h TTL, stale entries allowed up to 24 h) and mark the record
enrichment_status=stale. - On a cache miss, store the raw event anyway with
enrichment_status=pendingand publish the VIN to are-enrichtopic. A low-priority consumer backfills later. - The dead-letter queue is only for poison data (schema-invalid events), never for dependency failures.
2. Monitoring
SLIs/SLOs (28-day window)
- Durability: valid events committed / valid events received, at least 99.95%.
- Freshness: fraction committed within 5 s of gateway receipt, at least 99%.
- Enrichment completeness: fraction fully enriched within 15 min, at least 99.5%.
Paging on error-budget burn (multi-window)
- Page: burn above 14.4x over both 1 h and 5 min (2% of budget per hour).
- Page: burn above 6x over both 6 h and 30 min.
- Ticket: burn above 1x over 3 days.
Diagnostics only (no page): breaker open (the fallback absorbs it; it matters only if the enrichment SLO burns), single pod restarts, high CPU, slowly growing DLQ, a rising schema-reject rate (ticket to the producing team). Paging on user-visible symptoms and leaving causes to dashboards is the main defense against alert fatigue.
3. Expand and contract
Rules
- Migrations ship as their own pipeline stage and artifact, and run before the code that needs them.
- Every migration must work with release N and N-1.
- CI lints DDL and rejects
DROP,RENAME, type narrowing andNOT NULLwithout a default in a single step.
Example: replace battery_pct INT with battery_soc NUMERIC.
| Phase | Change | Safe rollback target |
|---|---|---|
| Expand | Add nullable battery_soc using online DDL. | Any release |
| Dual-write (N+1) | Write both, read old. | N |
| Backfill | Throttled idempotent batches (~5k rows). | N |
| Switch reads (N+2) | Read new, still write both. | N+1 |
| Stop old writes (N+3) | Old column stays nullable; bake one release cycle. | N+2 |
| Contract | Separate migration drops the old column. | Any release still deployed |
Rollback is always a code rollback. Schema is only rolled forward, so there are no down-migrations racing live traffic. Apply the same discipline to event schemas with a registry set to FULL_TRANSITIVE compatibility.
4. Pipeline and canary
commit -> build + unit + DDL lint + schema compat check
-> ephemeral env: integration + fault injection
(metadata 503s/latency -> breaker opens, zero loss)
-> staging soak: 1 h replay of sampled traffic
-> canary 5% (30 min) -> 25% (30 min)
-> region-by-region to 100%
Evaluation
- Compare against a freshly deployed baseline of the current version with the same age and traffic share, not against long-running pods (avoids warm-up bias).
- Per-metric nonparametric test (e.g. Mann-Whitney U), at least 10k events per arm, evaluated every 5 min.
Immediate rollback: any OOMKill or crash loop; datastore write errors above baseline.
Rollback after 2 consecutive failing intervals:
- Processing error rate: more than +0.5 percentage points, or more than 1.5x baseline.
- Latency: p95/p99 above 1.2x baseline and more than 30 ms worse in absolute terms (the floor avoids noise trips).
- Schema-reject rate above 2x baseline.
- Stale/pending enrichment fraction above 1.5x baseline, or breaker open only on canary pods.
Global guard: a fleet-wide fast-burn alert freezes all rollouts.
On abort: shift traffic back, pin the prior image and block the pipeline, notify the owner, and page only if the rollback itself fails.
Common mistakes
- Default or very long timeouts, and retrying on every error, which amplifies outages.
- Sending dependency failures to the DLQ, or dropping events when the breaker is open.
- Paging on causes (CPU, breaker state) instead of SLO burn.
- Rename or drop in a single migration, which makes rollback unsafe.
- Comparing the canary to old long-running pods, or judging on too little traffic.
- Rollback gates that use only absolute thresholds and ignore baseline noise.
Trade-offs
Stale cache serving improves availability at the cost of freshness. Tighter canary thresholds catch more regressions but raise false aborts, and longer canary windows slow delivery. Expand-and-contract costs several releases per schema change in exchange for rollback safety.