Control the scope
Turn an ambiguous prompt into testable functional and quality requirements.
Foundation · Interview method
A repeatable 45-minute framework for clarifying a prompt, estimating scale, defining contracts and data, tracing the architecture, and defending it under failure.
Turn an ambiguous prompt into testable functional and quality requirements.
Use estimates and access patterns to decide when architecture must evolve.
Walk through normal requests, failures, recovery, and the cost of every trade-off.
A system design interview is not a contest to draw the most boxes. The interviewer is evaluating whether you can turn an ambiguous product into explicit constraints, choose components for reasons, and discover where the design breaks. Begin with the simplest design that satisfies the stated requirements, then evolve it only when evidence exposes a limit.
Do not solution before you know the problem
Active Recall Checkpoint
When should you introduce sharding in an interview design?
Hint: Name the measured or estimated limit first.
Introduce it when one database cannot satisfy the estimated write rate, storage size, or operational isolation requirement. State the bottleneck, select a shard key from access patterns, and acknowledge cross-shard query and transaction costs.
Separate functional requirements—what users can do—from non-functional requirements—how safely and quickly the system must do it. A useful requirement changes a design decision or can be verified. “Highly scalable” is not testable; “sustain 20,000 writes per second while keeping p99 latency below 200 ms” is.
| Question | Why it changes the design |
|---|---|
| Who reads and writes? | Defines authentication, tenancy, abuse controls, and traffic shape |
| What may be stale? | Determines cache, replica, and consistency options |
| What may be lost? | Determines durability, acknowledgement, and recovery requirements |
| What is the peak, not the average? | Determines capacity, queues, and overload protection |
| Which operations must be ordered? | Determines keys, partitions, and coordination scope |
| What is explicitly out of scope? | Protects the interview from uncontrolled breadth |
Use it when
Use a short requirement table when the prompt is broad or stakeholders value different outcomes.
Reconsider when
Do not spend ten minutes collecting every possible feature. Confirm the two or three flows that drive architecture, state exclusions, and proceed.
Back-of-the-envelope estimates establish order of magnitude. Write units on every value, keep one significant digit, distinguish average from peak, and explain the decision the estimate informs. Precision without defensible assumptions is false confidence.
| Estimate | Useful formula | Decision it informs |
|---|---|---|
| Average requests/s | monthly operations ÷ seconds per month | Baseline service and database load |
| Peak requests/s | average × stated or assumed peak factor | Headroom, autoscaling, and overload policy |
| Storage/year | objects/s × bytes/object × seconds/year | Retention, partitioning, and cost |
| Bandwidth | responses/s × response bytes | Network, CDN, and fan-out pressure |
| Concurrent work | arrival rate × average time in system | Connection pools, worker count, and queue bounds |
Say what would invalidate the estimate
An API names the work the system promises; the data model makes its dominant access patterns efficient and its invariants enforceable. Define the contract before selecting a database brand. For each operation, write its key, query shape, result size, rate, latency goal, and consistency expectation.
Operation: getOrder(orderId)
Peak rate: 20,000 reads/second
Result size: under 20 KB
Latency objective: p99 under 80 ms
Consistency: read-your-writes for the buyer
Query shape: point lookup by primary key
Retention: seven yearsA diagram becomes a design only when you can narrate state changes through it. Trace a successful write, a successful read, and one dependency failure. At each hop, state ownership, timeout, retry behavior, persistence, and the signal that proves success.
| Boundary | Questions to ask |
|---|---|
| Client → edge | Authentication, rate limit, request size, idempotency, timeout |
| Service → cache | Source of truth, stale-data limit, stampede behavior, outage fallback |
| Service → database | Transaction boundary, index, isolation, pool limit, failover |
| Producer → queue/log | Acknowledgement, ordering scope, duplicates, retention, backpressure |
| Region → region | Replication lag, RPO/RTO, fencing, conflict policy, failback |
Every mitigation spends something
Scope the first version to creating short links, redirecting a code, optional custom aliases, expiration, and asynchronous click analytics. Redirects are public; creation is authenticated and rate-limited. The mapping must never resolve to the wrong destination, while analytics may lag.
| Requirement | Decision |
|---|---|
| Redirect availability | Prefer a bounded stale mapping over a failed redirect |
| Redirect latency | Target p99 below 100 ms at the service boundary |
| Custom alias | Enforce uniqueness in the authoritative database |
| Analytics | Publish asynchronously with at-least-once delivery and deduplication |
| Abuse response | Allow rapid disablement and cache invalidation |
Assume 10 million new links per month and a 100:1 redirect-to-create ratio. That is roughly 4 creates/s and 400 redirects/s on average. Designing for a 10× peak gives 40 creates/s and 4,000 redirects/s. At about 500 bytes per mapping, one year adds roughly 60 GB before indexes and replicas. This estimate does not justify sharding on day one.
POST /v1/links
Idempotency-Key: 0b8d...
Content-Type: application/json
{"url":"https://example.com/long/path","customAlias":"docs"}
201 {"code":"docs","shortUrl":"https://sho.rt/docs"}
409 when a requested custom alias already exists
GET /docs
302 Location: https://example.com/long/path
404 when absent; 410 when known but expiredUse 302 while destinations may change. Use 301 only when permanent intermediary and browser caching is intended. Store Link(code PK, destinationUrl, ownerId, createdAt, expiresAt, status) and add (ownerId, createdAt) only if owner-history queries are required.
Active Recall Checkpoint
Why is a relational database a reasonable starting point here?
The estimated write rate and storage fit one database, point lookup by code is easy to index, and a unique constraint provides correct custom-alias reservation. Sharding would add routing and migration complexity before an identified bottleneck requires it.
Correctness
Which invariant prevents two meanings for one short code?
Scale
What changes first at one million redirects per second?
Consistency
How quickly must a disabled malicious link stop resolving?
Recovery
How are mappings restored and how is restore time verified?
Operations
Which metric proves the cache, database, and analytics pipeline are healthy?
Security
How are dangerous destinations, enumeration, and abusive creation controlled?
End by restating the most important trade-off and the first production measurement you would validate. A strong answer is explicit about uncertainty: it distinguishes what the requirements proved, what the estimates assumed, and what operational evidence would trigger the next architectural change.
Pace your FAANG interview, evade examiner traps, and demonstrate staff-level insights.
1. Clarify Scope & Requirements — 05:00 remaining in this phase
Establish functional & non-functional requirements, traffic shape, and explicit exclusions.
Compute QPS, bandwidth, replicated storage, and RAM caching requirements live.
701.4Kreq/s
2.1Mreq/s
41.67 MB/s
0.33 Gbps
4166.67 MB/s
33.33 Gbps
1.9 PB
~398 TB / year
5.8 PB
3 Availability Zones / Replicas
279 GB
Estimated Daily Unique Data: 1.1 TB
Includes 25% metadata and capacity headroom
Multi-axis engineering evaluation and FAANG interview rules of thumb.
Relational ACID Store
Structured schema, relational joins, ACID transactions, and strict foreign keys.
Distributed Non-Relational Store
Horizontal partition keys, denormalized documents/wide-columns, and tunable consistency.
| Evaluation Axis | SQL (Postgres / MySQL) | NoSQL (Cassandra / DynamoDB) | Details |
|---|---|---|---|
Latency | Moderate | Strong | |
Throughput | Moderate | Strong | |
Scalability | Moderate | Strong | |
Consistency | Strong | Moderate | |
Complexity | Strong | Moderate | |
Cost | Moderate | Strong |
Choose SQL when ACID guarantees are non-negotiable (financial ledgers, payment processing, inventory checkout) or when query access patterns are unpredictable and require ad-hoc analytical joins.
Choose NoSQL when write volume exceeds single-node capacity (>20K writes/sec), data is unstructured/hierarchical (logs, telemetry, user feeds), or multi-region active-active replication is mandatory.
Never say "NoSQL is faster than SQL" without qualification. SQL with proper B-Tree indexes on indexed primary keys is lightning fast. NoSQL wins on horizontal write scaling, not inherent single-row read speed.