Opening your learning path
Progress is saved as you study.
Opening your learning path
Progress is saved as you study.
Opening your learning path
Progress is saved as you study.
The 45-minute interview framework, estimation with modern numbers, and CAP theorem.
6 lessons · about 2 hours · Interview Soon · 1 worked case study
Foundations is family 1 of 12 in the Thita system design course. It holds 5 lessons and 1 worked case study, and it is marked Interview Soon — the material that comes up in a standard interview loop.
Each one takes a product brief from this family through the whole worked answer — requirements, estimation, API, data model and trade-offs.
A system design interview is a timed reasoning exercise. Unfinished structure hurts more than imperfect details. Interviewers judge whether you can turn ambiguity into a working architecture, choose the right depth, and explain tradeoffs before time runs out.
Candidates usually fail by spending too long on requirements, drawing half a system, and reaching failure modes with two minutes left.
Start with a working end-to-end design. A request comes in, data is read or written, a response goes back, and the system has a clear scaling path.
Avoid sharding, consensus, queues, and cache invalidation until the problem requires them.
Move in this order:
That order keeps the basic request flow clear before you optimize.
Use this sequence:
A 45-minute interview in five phases: 5 min requirements, 5 min API and data model, 10 min high-level design, 20 min deep dives, 5 min wrap-up. Keep the ratios.
The exact minutes can shift. Keep the ratios. If you spend 15 minutes on requirements, you lose time for bottlenecks, failures, tradeoffs, and recovery.
Use requirements to set boundaries fast. The goal is to design the requested system and avoid solving a larger problem.
Split requirements into two groups:
Ask these early:
| Requirement Area | What to Ask | Why It Matters |
|---|---|---|
| Scale | “What DAU or QPS should we design for?” | Decides whether one database is enough or partitioning is needed. |
| Latency | “What p95 latency should reads and writes meet?” | Redirect systems need fast reads. Analytics writes can often run async. |
| Consistency | “Can reads be eventually consistent, or must writes be immediately visible?” | Decides whether replicas, caches, and async pipelines are safe. |
| Availability | “What uptime target should we meet?” | Drives replication, failover, multi-AZ, and multi-region choices. |
For a URL shortener, a useful requirement pass sounds like this:
“Core functions are create short URL, redirect short URL, and optional click analytics. I’ll assume reads dominate writes. Redirects should be under 100 ms p95. Creation can be slower. Newly created links should be readable immediately. I’ll design for high availability across AZs and skip multi-region unless the traffic or latency target requires it.”
That is enough. Convert answers into design constraints and move on.
The API forces precision. Many candidates draw boxes before defining what the system does. They later discover their design cannot support deletes, custom aliases, TTLs, or idempotent creation.
Keep the API small and tied to the core flows:
1POST /v1/urls
2GET /{shortCode}
3DELETE /v1/urls/{shortCode}
4GET /v1/urls/{shortCode}/statsThen define the data model.
For a URL shortener, the core mapping is short_code → long_url. Store owner, creation time, expiration time, and status with that mapping. Keep analytics separate because redirect latency should not depend on aggregation writes.
A clean starting model:
| Entity | Key Fields | Purpose |
|---|---|---|
| UrlMapping | short_code, long_url, owner_id, created_at, expires_at, status | Serves redirects and lifecycle operations. |
| ClickEvent | short_code, timestamp, referrer, country, device | Captures raw analytics asynchronously. |
| User | user_id, plan, quota | Supports ownership, rate limits, and product constraints. |
State access patterns immediately:
“Redirect reads hit short_code. Creation writes one mapping. Stats read pre-aggregated analytics.”
The access-pattern statement shows that queries drive the design.
The high-level design must show a complete request path. If the interviewer points at your diagram and asks, “Where does this request go next?” you should have an answer.
For a URL shortener, start here:
Start with client, API and one Postgres primary, then add only what the numbers justify: load balancer, replicas, cache, CDN, and an async queue for analytics.
Explain the read path first because redirects usually dominate traffic.
A redirect request checks CDN or service cache, falls back to the database by short_code, returns a 301 or 302, and records a click event asynchronously. The redirect path should not wait for analytics.
Explain the write path second.
A create request validates the URL, generates or accepts a short code, writes the mapping transactionally, and returns the short URL. If custom aliases are allowed, enforce uniqueness with a database constraint or conditional write. A check-before-write can race.
Keep the first HLD simple. A single primary Postgres instance with replicas can handle many interview-scale systems before sharding makes sense.
If your estimate says 10K writes per second and tens of TB of data, discuss partitioning. If your estimate says 100 writes per second and 500 GB, use a simple primary-replica design.
Pick deep dives that match the system’s bottlenecks. Avoid listing every distributed systems topic you know.
For a read-heavy URL shortener, good deep dives are:
| Deep Dive | When to Choose It | Recommendation |
|---|---|---|
| Cache strategy | Reads dominate and popular links are hot | Use cache-aside with TTLs. Keep the database as source of truth. |
| Short code generation | Collisions or custom aliases matter | Use random/base62 with a uniqueness constraint. Use allocated ranges if generation must avoid coordination. |
| Replication and failover | Availability target is high | Use a multi-AZ primary-replica setup with automated failover. |
| Analytics pipeline | Click tracking must not slow redirects | Emit events to Kafka or a queue. Aggregate asynchronously. |
| Abuse and rate limiting | Public endpoints can be attacked | Add per-user and per-IP limits. Scan malicious URLs. |
A common mistake is diving into cache invalidation before proving the database cannot handle reads. Redis can often serve 100K–500K ops/sec per instance. Postgres can serve high indexed read traffic with replicas. Use estimates to justify the cache.
Start a deep dive with the constraint:
“Redirects are read-heavy and p95 latency matters, so I’ll put hot mappings in Redis with cache-aside. On cache miss, the service reads Postgres and backfills Redis. For strict delete visibility, the service invalidates cache entries on delete. For loose delete visibility, short TTLs are enough.”
Be explicit about consistency.
For URL creation, newly created links should be immediately readable. Write to the primary and either populate cache after write or read from the primary for a short period.
For analytics, delayed stats are acceptable. Use async events and tolerate lag.
Use the wrap-up to state the system’s limits and next steps.
Cover four points:
A strong wrap-up for a URL shortener:
“The design serves redirects through cache and Postgres replicas, writes mappings to a primary database, and records analytics asynchronously through a queue. The first likely bottleneck is hot-key traffic or database read load, handled with cache and CDN. If storage or write throughput exceeds a single primary, the next scaling step is partitioning mappings by short code. Analytics failures do not break redirects because click recording is decoupled.”
Also state what you skipped:
“I did not add multi-region active-active because the assumed latency and availability target did not require it.”
Use this when the interview starts to drift:
1Do I have requirements?
2 No → ask scale, latency, consistency, availability.
3 Yes → move to API/data model.
4
5Do I have a complete request path?
6 No → finish HLD before deep dives.
7 Yes → choose the highest-risk bottleneck.
8
9Is the interviewer pushing a topic?
10 Yes → follow it and state the tradeoff.
11 No → drive toward failure modes and scaling limits.If you are unsure what to do next, finish the HLD. Interviewers can evaluate tradeoffs only after they understand your baseline architecture.
The same design can pass or fail depending on level.
| Level | Expected Behavior | What Usually Passes |
|---|---|---|
| L4 | Covers basics with some interviewer guidance | Clear requirements, simple HLD, reasonable database/cache choices, basic scaling discussion. |
| L5 | Moves quickly to tradeoffs and deep dives | Finishes HLD early, estimates bottlenecks, explains consistency, cache, replication, and failure behavior. |
| L6 | Drives the conversation and finds risks proactively | Frames ambiguity, prioritizes bottlenecks, challenges assumptions, covers operations and failure modes without being prompted. |
At L4, avoid adding distributed consensus everywhere to sound senior. Focus on correctness, clear flows, and basic scale awareness. A clean design with one database, a cache, and async processing can be enough if the reasoning is disciplined.
At L5, speed matters. Reach deep dives by minute 15 and spend most of the interview on tradeoffs. If you are still debating functional requirements at minute 12, you are probably losing the interview.
At L6, the interviewer expects you to steer. Say things like:
“The design has two likely risks: hot redirects and database failover. I’ll cover hot-key handling first because it affects the user-facing latency path.”
Companies run system design interviews differently. Keep the phases and adjust how much you drive.
| Company | Format Tendency | How to Adapt |
|---|---|---|
| Meta | Often separates Product Architecture from System Design | For Product Architecture, spend more time on product flows and prioritization. For System Design, move faster into scale and infrastructure tradeoffs. |
| Candidate-driven | Drive the structure yourself, narrate choices clearly, and do not wait for the interviewer to pick the next component. | |
| Anthropic | Interviewer-driven and timeboxed | Answer the prompt directly, keep transitions short, and expect the interviewer to move you between subproblems. |
| Stripe | Often uses API design and bug-squash instead of classic system design | Be precise on API contracts, idempotency, edge cases, debugging, and correctness under failure. |
For Google-style interviews, silence is expensive. If the interviewer is not steering, create the path. State your plan, execute it, and check in briefly at phase boundaries.
For Anthropic-style interviews, follow the structure you are given. If the interviewer asks for a specific subsystem, go there and give a compact answer. Long self-directed detours can hurt because the session is timeboxed.
For Stripe, classic box-and-arrow architecture may not be the main test. API correctness, idempotency keys, retries, partial failures, and debugging discipline often matter more. Treat every API as something a real customer will integrate with and misuse.
Estimation should take 2–3 minutes. You need enough math to decide whether the design needs one machine, replicas, a cache, a queue, or sharding.
Use three formulas:
| Estimate | Formula | Example |
|---|---|---|
| QPS | DAU × actions per user per day / 86,400 | 100M DAU × 10 redirects/day ≈ 11.6K average QPS. |
| Peak QPS | average QPS × 2–3 | 11.6K average becomes roughly 25K–35K peak. |
| Storage | writes/day × bytes/write × retention days | 10M URLs/day × 1 KB × 365 ≈ 3.65 TB/year. |
These numbers often prevent overengineering. A single Postgres primary can handle 10K–50K TPS and tens of TB before sharding is needed, depending on schema, indexes, write pattern, and hardware. If your system has a few TB and moderate write throughput, choose Postgres with replicas before proposing sharding.
Add cache when read load, latency target, or hot-key traffic justifies it. If Postgres replicas can handle the reads and p95 latency is acceptable, skip cache in the first design and mention it as the next step. If redirects are high-QPS and hot links dominate, use Redis or CDN caching early.
Use the 45-minute structure explicitly:
15 min requirements
25 min API and data model
310 min complete HLD
420 min highest-risk deep dives
55 min wrap-upPrioritize a working end-to-end design before optimizing. Then use estimates to choose one or two deep dives that match the bottleneck.
For most systems, start with a simple database-backed architecture. Add cache or queue when the access pattern proves they help. Avoid sharding until the numbers exceed what a modern primary database can handle.
Candidates commonly fail in these ways:
| Category | 2026 Number | Interview Use |
|---|---|---|
| General-purpose RAM | 512 GiB | A single machine can hold far more hot metadata than many candidates assume. |
| Memory-optimized RAM | 4 TB | Large in-memory indexes and caches can fit on one instance class. |
| High-memory RAM | 24 TB | Estimate before assuming data is too large for memory. |
| General-purpose CPU | 128 vCPUs | One service or database node can handle serious concurrency before horizontal scaling. |
| Local SSD | 60 TB | Local fast storage is large enough for many single-node workloads. |
| Local HDD | 336 TB | Bulk storage capacity is rarely the first bottleneck for small interview estimates. |
| Datacenter network | 25–100 Gbps | Network inside a datacenter is fast. Cross-region latency is usually the bigger issue. |
| Same-AZ latency | < 1 ms | Service-to-cache and service-to-database calls inside one AZ are low latency. |
| Cross-AZ latency | 1–2 ms | Multi-AZ replication adds latency and is usually acceptable for availability. |
| US–EU latency | 70–90 ms | Multi-region user-facing calls can dominate p95 latency. |
| US–India latency | 150–250 ms | Avoid synchronous cross-region dependencies on the critical path. |
| Redis GET | < 1 ms | Useful for hot reads and strict latency targets. |
| Postgres indexed lookup | 1–5 ms | Indexed database reads are fast enough for many first designs. |
| S3 first byte | 50–100 ms | Good for objects. Poor fit for low-latency metadata reads. |
| CDN edge latency | 5–30 ms | Best place to serve cacheable global content. |
| Redis throughput | 100K–500K ops/sec per instance | One cache instance can absorb high read traffic. |
| Postgres single primary | 10K–50K TPS | Shard when write throughput, storage, or operational limits justify it. |
| Postgres storage before sharding | Tens of TB | Do not shard at 100 GB. |
| Kafka throughput | 1M+ msg/sec per cluster | Suitable for high-volume async event pipelines. |
| Kafka latency | Single-digit ms | Good for decoupling without adding large delay. |
| Elasticsearch throughput | 10K–50K queries/sec per cluster | Useful for search-heavy workloads. Avoid using it as the default database. |
| QPS estimate | DAU × actions/user ÷ 86,400 | Use this to size reads and writes quickly. |
| Peak estimate | Average QPS × 2–3 | Size peak traffic as well as average traffic. |
| Storage estimate | Writes/day × bytes/write × retention days | Use this before discussing partitioning. |
| Bandwidth estimate | QPS × average response size | Use this to identify network or CDN needs. |