System Design · Intermediate
System Design Interview Preparation: A Framework and the Core Building Blocks
Learn a step-by-step framework for system design rounds and the building blocks you'll use — load balancers, caching, databases, sharding, queues and CDNs — with a worked URL shortener example.
Published 4 Dec 20262 min read
System design rounds are open-ended conversations. Interviewers look for structured thinking, sensible trade-offs and clear communication — there is rarely one correct answer.
A framework for the interview
- Clarify requirements (5 min)
- Functional: what must the system do?
- Non-functional: scale, latency, availability, consistency needs.
- Estimate scale (3–5 min) — users, requests per second, data size. Rough numbers guide decisions.
- Define the API — the main endpoints or operations.
- High-level design — draw clients, services, data stores and how requests flow.
- Data model — key entities and the choice of database.
- Deep dive — scale the bottlenecks: caching, partitioning, replication, queues.
- Trade-offs and failures — what breaks first, and how you would monitor and recover.
Core building blocks
Load balancer — spreads traffic across servers (round robin, least connections) and removes unhealthy servers.
Horizontal vs vertical scaling — add more machines vs make one machine bigger. Stateless services scale horizontally easily.
Caching — keep frequently read data in memory (e.g. Redis).
- Cache-aside: the app reads the cache, falls back to the database and populates the cache.
- Plan for invalidation and expiry (TTL); stale data is the main risk.
CDN — serves static content from servers close to users, reducing latency and origin load.
Databases
- Relational databases for structured data and transactions.
- NoSQL (key-value, document, wide-column) for flexible schemas and very high write scale.
- Replication: a primary for writes with read replicas — improves read throughput and availability.
- Sharding: split data across machines by a shard key (e.g. user ID). Choose keys that spread load evenly.
Message queues (e.g. Kafka, RabbitMQ) — decouple services and absorb spikes; work is processed asynchronously by consumers.
Rate limiting — protect services with algorithms such as token bucket.
CAP theorem, simply
During a network partition, a distributed system must choose between consistency (every read sees the latest write) and availability (every request gets a response). Payment systems lean towards consistency; social feeds often accept eventual consistency for availability.
Worked example: URL shortener
Requirements: create a short URL for a long one; redirect quickly; optional expiry; reads far outnumber writes.
API:
POST /urls { longUrl } → { shortCode }GET /{shortCode} → 301/302 redirect
Short code generation: encode a unique numeric ID in base62 (a–z, A–Z, 0–9); 7 characters give 62⁷ ≈ 3.5 trillion combinations. IDs can come from a distributed ID generator to avoid collisions.
Storage: a key-value store mapping shortCode → longUrl, createdAt, expiresAt.
Read path: check the cache (popular links are hot) → fall back to the database → redirect.
Scaling: stateless app servers behind a load balancer, cache in front of the database, shard by short code, and send click analytics to a queue so redirects stay fast.
Practice topics
- Design a rate limiter.
- Design a news feed.
- Design a chat application.
- Design a job portal search with filters (good practice for this very site!).
For each, practise drawing the diagram and explaining one bottleneck in depth.
- #system-design
- #backend
- #architecture