Defend the Architecture of a System You Built, End to End
System DesignModel answerLast updated
Walk through a non-trivial system you own, from diagram and invariants to scaling, security, SLOs, a real incident, a 10x plan and a hindsight redesign.
Task
Choose one substantial project you have personally worked on and present it as a deep technical review. Assume the listener will pick any layer and keep asking "why" until you run out of answers, so be ready to sketch the system and defend each choice with concrete numbers and real examples rather than generalities.
Cover these twelve areas:
- Architecture sketch. Show the components, data stores and the interfaces between them (REST, gRPC, streaming, WebSocket, queues).
- Flows and invariants. Describe the main data flows and list the correctness rules the system must never break, for example "at most one active owner per resource".
- Read and write paths. Trace one read and one write hop by hop, including caching, idempotency handling and a latency budget.
- Storage. Explain the schema, your choice of relational, NoSQL, cache or cold storage, and your partition keys and indexes.
- Decisions and trade-offs. Justify major technology choices and name what you gave up (consistency vs. availability, push vs. poll, write-through vs. write-behind, and so on).
- Scale and capacity. Provide rough QPS, message rates and storage figures, name the bottlenecks and describe how you plan capacity.
- Consistency and reliability. State your consistency model, delivery guarantees, failure handling (retries, sagas, circuit breakers) and disaster-recovery targets (RPO/RTO).
- Security. Cover authentication, authorization, service-to-service trust, encryption, PII handling and compliance.
- Observability. Describe logs, metrics and traces, plus concrete SLIs, SLOs, alerts and runbooks.
- An incident or hard decision. Give the root cause, impact and mitigation of something that really happened.
- Two changes for 10x traffic. Propose two specific modifications and quantify why each helps.
- Redesign with hindsight. Say what you would do differently today and why.
What a good answer looks like
Be specific and quantitative. Tie later sections back to the invariants from section 2. For every choice, mention the alternative you rejected. Aim for a presentation that fits roughly 45 minutes.
Hints
Hint 1
Pick a system of moderate size that you can fully explain, with every box and arrow justified, rather than a famous system you only touched briefly.
Hint 2
State your invariants early and, for each one, name the exact mechanism that enforces it (unique constraint, conditional update, transactional outbox, consumer dedupe). Reuse them as the thread through reliability and incident discussion.
Hint 3
Attach a number to every claim: latency budget per hop, QPS at average and peak, bytes per message, storage per day, SLO targets, RPO/RTO. Then derive the bottleneck from those numbers and propose 10x changes that attack it directly.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
What the interviewer is testing
This format checks whether you truly owned the system. Strong answers show four qualities:
- Ownership. You quote numbers, schemas and failure modes without hedging.
- Correctness thinking. You name each invariant and the mechanism that enforces it.
- Trade-off maturity. For each decision you name the rejected alternative and the cost you accepted.
- Operational realism. You can talk about SLOs, alerts, a real incident and what you would change.
Pick a system you can defend end to end. A mid-scale system you owned beats a famous one you only observed.
Suggested pacing (about 45 minutes)
- Context (2 min): problem, your role, team size, scale.
- Diagram (5 min): clients, edge, services, stores, async pipeline; label each arrow with its protocol.
- Invariants (3 min): state them before diving in.
- Read and write paths (8 min): hop-by-hop with latency figures.
- Storage, scale, reliability, security, observability (15 min): let the interviewer steer.
- Incident, 10x plan, redesign (10 min).
Template using an example: a ride-hailing-style matching and live-tracking service
Swap in your own project; the level of specificity is what matters.
Architecture. Driver app to gateway over HTTPS for accept/decline. Driver app to a location ingest service over gRPC streaming, one ping every 4 s. Rider app to a tracking service over WebSocket. Ingest publishes to Kafka keyed by driver ID. A matcher consumes it and calls the assignment service. Assignment writes to Postgres and emits events through a transactional outbox. Latest location lives in Redis, history in object storage as Parquet.
Invariants and enforcement.
- At most one active assignment per request: partial unique index on the request ID for statuses
offeredandaccepted. - Only the intended driver can accept, and only before expiry: a conditional
UPDATE ... WHERE status='offered' AND driver_id=$2 AND expires_at > now(); zero rows updated returns 409. - Each state change yields exactly one downstream event in effect: outbox row written in the same transaction, plus consumer-side dedupe on event ID.
Write path (accept), p99 budget 300 ms. JWT verification at the gateway (~5 ms), then a gRPC call with an idempotency key (replays return the stored response from Redis, 24 h TTL), then one DB transaction doing the conditional update plus outbox insert (~20 ms). A relay publishes to Kafka asynchronously, outside the budget.
Read path (tracking), p99 150 ms. The WebSocket node reads the latest location from Redis (<2 ms, 30 s TTL) and pushes every 4 s. On a miss, fall back to the last persisted row and flag the location as stale.
Storage. Postgres for assignments because the invariants need constraints and transactions; monthly partitions; indexes on (driver_id, status) and a partial index on expiry for the sweeper. Redis for hot, small, loss-tolerant data. Object storage for history, cheaper than a time-series DB at low query rates. Kafka partitioned by driver ID to preserve per-driver order.
Trade-offs.
- Push over poll: polling 100k riders every 4 s is about 25k req/s; push trades that for connection state.
- CP for assignment (fail closed), AP for location (serve stale).
- Write-behind to cold storage accepts minutes of lag in history.
Capacity. 600k orders/day is about 7/s average and 35/s at peak. 50k active drivers every 4 s is 12.5k msg/s, at about 150 B that is roughly 1.9 MB/s, or about 160 GB/day raw and about 30 GB/day as Parquet. The bottleneck is WebSocket fan-out (about 20k connections per node). Plan for 50% headroom over the trailing peak and load test at 2x before seasonal peaks.
Reliability. At-least-once Kafka with idempotent consumers; jittered exponential backoff with idempotency keys on mutations; a circuit breaker around the external maps/ETA provider with a straight-line fallback; reassignment as a saga (release, re-offer, compensating notification). Multi-AZ Postgres with a synchronous standby gives RPO near 0 and RTO under 2 min; cross-region async replicas give RPO under 1 min.
Security. OAuth/JWT with ownership checks (drivers act only on their own offers; riders see only their own order). mTLS between services. TLS 1.2+ in transit, KMS-managed encryption at rest. Location is PII: visible only while the order is active, reduced precision in analytics, raw history deleted after 30 days, audited access, GDPR/CCPA alignment.
Observability. Structured logs with request and trace IDs, OpenTelemetry traces across gateway, service and DB, RED metrics per endpoint. Example SLOs: accept success at least 99.95%, accept p99 under 300 ms, location freshness within a few seconds for 99% of active orders. Alert on error-budget burn rate, each with a runbook.
Incident, 10x plan, redesign
Incident. Use a real one in the form: symptom, detection, root cause, mitigation, permanent fix. For example, a hot Kafka partition from a skewed key caused consumer lag and stale locations; mitigation was to rebalance with a salted key, and the fix added lag alerts and a per-partition load dashboard.
Two 10x changes, quantified.
- Shard WebSocket fan-out by region and add a pub/sub layer, so 10x connections (200k to 2M) spread across about 100 nodes at 20k each instead of overloading a single tier.
- Batch and coalesce location writes (for instance, send every 8 s or on movement thresholds), cutting ingest from 12.5k to about 6k msg/s so 10x load lands near the original footprint.
Redesign. Name one real regret, such as adopting a heavy mesh too early, or keeping history in an unpartitioned table, and say what you would do now and what it would cost.
Common mistakes
- Choosing a project you cannot explain below the box-and-arrow level.
- Listing invariants without saying how they are enforced.
- Giving technology names without the rejected alternative.
- Quoting no numbers, or numbers that do not reconcile (QPS vs. storage).
- Telling an incident with no root cause or no lasting fix.
- Proposing "add more servers" as a 10x plan without identifying the actual bottleneck.