System Design Interview Questions
Practice clarifying requirements, estimating load, selecting data and cache strategies, and reasoning about reliability and security trade-offs.
Explained System Design questions
How do you turn an open-ended system-design prompt into requirements and an initial capacity estimate?
Clarify users, core operations, data boundaries, consistency needs, latency targets, availability expectations, and constraints before drawing components. Estimate order-of-magnitude traffic and storage from explicit assumptions—for example, requests per second and bytes retained—then identify the likely bottleneck. State uncertainty and revisit estimates rather than presenting guessed numbers as facts.
Example
Assumption: 100,000 daily active users × 20 writes/day = 2,000,000 writes/day.
Average write rate ≈ 2,000,000 / 86,400 ≈ 23 writes/second.
If peak is 5× average, plan to discuss roughly 115 writes/second before replication or retry overhead.
Why it works
A transparent estimate exposes peak-load and retention assumptions. It guides API shape and storage discussion without implying that an early estimate is a production benchmark.
Common mistakes
- Choosing a database or cache before clarifying consistency and access patterns.
- Ignoring peak traffic, retries, payload size, and data retention.
- Treating arithmetic estimates as precise predictions.
Follow-up questions
- How would you estimate storage after one year?
- Which requirements can be relaxed if the budget is constrained?
Real-world use
Use explicit assumptions in design reviews so capacity planning can be updated when real traffic and telemetry become available.
Further reading: Google SRE: Service Level Objectives · AWS Well-Architected Framework
How would you design an API and choose storage, caching, load balancing, and horizontal scaling?
Define resources and operations with explicit validation, pagination, authorization, and idempotency behavior. Choose storage from the consistency model, query patterns, data relationships, and operational constraints. Add a cache only for a measured read path with a freshness and invalidation strategy. A load balancer distributes traffic across stateless application instances; horizontally scaling those instances still requires attention to database capacity, session state, and downstream limits.
Example
GET /v1/orders?cursor=opaque-token&limit=25
POST /v1/orders
Idempotency-Key: client-generated-operation-id
Return a stable page cursor and an operation result that can be safely
retrieved again for the same idempotency key.
Why it works
Stable pagination and idempotent write semantics make retries more predictable. Stateless application instances can scale independently, while identifying shared bottlenecks prevents a load balancer from merely shifting overload downstream.
Common mistakes
- Using a cache to hide a slow database without addressing invalidation or stale reads.
- Assuming more app instances always improve throughput.
- Putting secrets or sensitive data in URLs and cache keys.
Follow-up questions
- What invalidation strategy fits this data's update pattern?
- How would you handle a hot key or database connection limit?
Real-world use
Start with a simple architecture and add replicas, indexes, and cache layers in response to workload evidence and explicit service objectives.
Further reading: AWS: Caching best practices · Google SRE: Handling overload
When would you use a queue, and how do rate limiting and idempotency protect asynchronous workflows?
A queue decouples a request from work that can finish later, absorbs bursts, and supports retryable processing. It introduces delivery semantics, ordering, and duplicate-delivery concerns. Make consumers idempotent, use bounded retries with backoff, route persistent failures for inspection, and expose queue age and depth. Rate limits should be applied at the boundary appropriate to the abuse or capacity risk, with a clear response and retry policy.
Example
POST /exports -> 202 Accepted { "jobId": "..." }
Consumer:
1. Claim a job with a lease.
2. Check whether its idempotency key is already complete.
3. Perform the side effect once or record its result.
4. Acknowledge only after durable completion.
Why it works
Acknowledging after durable completion allows redelivery without losing work. The idempotency key makes repeated delivery converge on one recorded outcome.
Common mistakes
- Assuming a queue provides exactly-once effects.
- Retrying permanent errors indefinitely.
- Letting a queue grow without alerts, quotas, or backpressure.
Follow-up questions
- How would you handle poison messages?
- Where should the idempotency record live and how long should it be retained?
Real-world use
Queues work well for reports, notifications, and media processing when the user experience can acknowledge a job and track its status.
Further reading: AWS: Queue-based architecture · Google SRE: Addressing cascading failures
How do you balance consistency, security, observability, and fault tolerance in a distributed design?
Choose consistency per operation: an account balance may need an atomic authoritative update, while a search index can often be eventually consistent. Define failure boundaries, timeouts, retry budgets, and fallback behavior; retries without limits can amplify an outage. Authenticate callers, authorize each resource action, minimize sensitive data, and encrypt traffic. Instrument user-visible latency, errors, saturation, and dependency health, and test the recovery path rather than assuming redundancy is sufficient.
Example
For an order workflow, persist the order and an outbox event in one database transaction. A relay publishes the event; consumers deduplicate by event ID. Track publish lag, consumer lag, retries, and dead-letter volume.
Why it works
The transactional outbox avoids committing an order without recording its event for delivery. Deduplication and lag metrics make asynchronous consistency observable and recoverable.
Common mistakes
- Promising global strong consistency without stating its availability and latency costs.
- Retrying non-idempotent writes with no deduplication.
- Logging authentication tokens, personal data, or full request bodies.
Follow-up questions
- What happens if the relay publishes but crashes before recording progress?
- How would you restore service after a dependency outage or data-region failure?
Real-world use
Document invariants and recovery objectives, then validate them with failure tests, alerts, access reviews, and rehearsed incident procedures.
Further reading: OWASP: Logging Cheat Sheet · Google SRE: Monitoring Distributed Systems
How would you keep a service responsive when a downstream dependency is slow or unavailable?
Set deadlines at the request boundary and propagate shorter timeouts to dependencies so work does not outlive the caller. Bound concurrency and queues, use retries only for transient failures with a budget and jitter, and make retried operations idempotent. A circuit breaker can temporarily fail fast when a dependency is unhealthy, but its fallback must preserve the system's correctness and security requirements.
Example
Request deadline: 2 seconds
Dependency timeout: 600 ms
Retry: at most once for a transient, idempotent read
Concurrency: bounded per dependency
Fallback: return clearly labeled cached data only if its freshness is acceptable
Metrics: timeout rate, in-flight calls, retry count, and tail latency
Why it works
Deadlines and concurrency limits prevent slow dependencies from consuming all request capacity. A bounded retry policy can recover brief faults without multiplying load during a sustained outage.
Common mistakes
- Retrying every error or retrying without a total deadline.
- Using stale or partial data without telling callers when it may be incorrect.
- Adding a circuit breaker without monitoring its state or testing recovery.
Follow-up questions
- How do you distinguish a transient failure from a permanent one?
- Which operations are safe to retry, and how do you prove that?
Real-world use
Use these controls at service boundaries, then validate them with dependency-failure tests and dashboards for saturation, errors, and recovery time.
Further reading: Google SRE: Addressing Cascading Failures · AWS Builders' Library: Timeouts, retries, and backoff with jitter