Interview Q&A / System Design
System Design interview questions
Caching, scaling, databases and classic design problems for beginners.
Prefer rapid revision? Practise System Design short interview answers →
- How do you choose between a SQL and a NoSQL database?
Choose SQL when data is relational, you need joins, transactions and flexible queries, and the schema is fairly stable. Choose NoSQL when you need a flexible schema, very high scale for simple access patterns known in advance, or a data model like documents, key-value or graphs. Many systems use both.
BeginnerIn-depth4 min read - What does a load balancer do, and what is the difference between L4 and L7 load balancing?
A load balancer sits in front of a group of servers and spreads incoming requests across the healthy ones, so no single server is overloaded and failures are hidden from users. An L4 balancer routes by IP address and port without reading the request. An L7 balancer reads HTTP details such as path, host and headers and can route on them.
BeginnerIn-depth4 min read - What is caching and what caching strategies should you know?
A cache keeps a copy of frequently used data in faster storage, like memory, so repeated reads are quick. Know cache-aside, write-through and write-back, eviction policies like LRU, TTLs, and the hard part, keeping the cache consistent with the database.
BeginnerIn-depth3 min read - What is the difference between horizontal and vertical scaling?
Vertical scaling (scaling up) makes one machine bigger with more CPU, RAM or faster disks. Horizontal scaling (scaling out) adds more machines and spreads the load across them. Vertical is simpler but has a hard ceiling and a single point of failure; horizontal scales further and survives failures but needs stateless services and a load balancer.
BeginnerIn-depth4 min read - How would you design a URL shortener like bit.ly?
Store a mapping from a short code to the long URL. Generate codes with a counter encoded in base62 (or random codes with a collision check), keep the mapping in a key-value store, put a cache in front for fast redirects, and return a 301 or 302 redirect. Add rate limits, expiry and analytics as extras.
IntermediateIn-depth3 min read - What is a message queue and why would you use one?
A message queue lets one service drop a message and move on, while another service picks it up and processes it later. It decouples services, absorbs traffic spikes, makes slow work asynchronous and retries failures. Examples are RabbitMQ, Amazon SQS and Kafka (a log-based alternative).
IntermediateIn-depth4 min read - What is the CAP theorem, in simple words?
The CAP theorem says that when a network partition splits a distributed system, it must choose between consistency (every read sees the latest write or gets an error) and availability (every request gets a non-error response, possibly stale). Partitions can't be ruled out, so the real choice is CP or AP during a partition.
IntermediateIn-depth4 min read - How would you design a rate limiter?
A rate limiter caps how many requests a client can make in a time window, for example 100 per minute per user, and rejects extras with HTTP 429. Common algorithms are token bucket (allows short bursts), fixed window, sliding window log and sliding window counter. In a distributed system the counters live in a shared store like Redis and are updated atomically.
AdvancedIn-depth4 min read