Interview Prep — System Design Track
System Design Interview Questions
38 curated questions covering scalability, load balancing, caching, databases, messaging, and FAANG case studies with expandable answers.
ScalabilityCachingMicroservicesCase Studies
36Total Qs
6Beginner
14Intermediate
11Advanced
5FAANG
Questions
01
What is horizontal vs vertical scaling?
Scalability
Beginner
▾
Vertical scaling adds CPU/RAM to one machine (simpler, hits hardware ceiling). Horizontal scaling adds more machines behind a load balancer (harder state/consistency, scales further). Most web systems scale out at the application tier first.
02
Explain round-robin vs least-connections load balancing.
Load Balancing
Beginner
▾
Round-robin rotates requests evenly — simple but ignores server load. Least-connections sends to the backend with fewest active connections — better for long-lived requests. Use health checks on both; remove unhealthy nodes quickly.
03
What is cache-aside pattern?
Caching
Beginner
▾
App reads cache first; on miss, read DB, populate cache, return. Writes update DB then invalidate/delete cache entry. Pros: flexible. Cons: stampede risk on cold keys — mitigate with single-flight or probabilistic early expiration.
04
State the CAP theorem in plain language.
CAP
Beginner
▾
During a network partition, a distributed system cannot simultaneously guarantee both Consistency (every read sees latest write) and Availability (every request gets a response). Real systems pick CP or AP per subsystem.
05
SQL vs NoSQL — when would you pick each?
Databases
Beginner
▾
SQL when you need ACID transactions, joins, and flexible ad-hoc queries. NoSQL when you need horizontal write scale, flexible schema, or specialized models (documents, wide-column, graph, time-series).
06
What is an API gateway responsible for?
API Design
Intermediate
▾
TLS termination, authentication, routing, rate limiting, request aggregation, protocol translation, and observability at the edge. Keeps microservices from reimplementing cross-cutting concerns.
07
Compare synchronous REST vs asynchronous messaging.
Messaging
Intermediate
▾
REST is simple and request-response — good for user-facing paths with tight latency budgets. Messaging decouples producers/consumers, absorbs spikes, enables retries — better for background work. Hybrid architectures are common.
08
What is database sharding?
Sharding
Intermediate
▾
Splitting data across multiple DB instances by a shard key. Enables write scale beyond one node. Challenges: cross-shard queries, rebalancing, hot shards. Often paired with a routing layer or consistent hashing.
09
Leader-follower replication — how does failover work?
Replication
Intermediate
▾
One leader accepts writes; followers replicate asynchronously or synchronously. On leader failure, promote a follower (manual or automated). Risk: replication lag causes stale reads or lost writes if promotion is too aggressive.
10
What is a circuit breaker?
Fault Tolerance
Intermediate
▾
Stops calling a failing dependency after error threshold, fails fast, periodically probes recovery. Prevents cascade failures. Pair with timeouts, bulkheads, and graceful degradation.
11
Define SLI, SLO, and SLA.
Reliability
Intermediate
▾
SLI = measured indicator (e.g. availability). SLO = internal target (99.9% monthly). SLA = contractual commitment with consequences. Error budgets = 1 − SLO, guiding release velocity.
12
How does a CDN reduce latency?
CDN
Intermediate
▾
Caches static assets at edge PoPs close to users. Reduces origin load and RTT. Use cache headers, versioning in filenames, and origin shield for traffic spikes.
13
Token bucket vs sliding window rate limiting.
Rate Limiting
Intermediate
▾
Token bucket allows bursts up to bucket size with steady refill — smooth UX. Sliding window counts requests in rolling time window — stricter fairness. Often implemented in Redis or at API gateway.
14
Microservices vs modular monolith trade-offs.
Architecture
Advanced
▾
Microservices: independent deploy, tech diversity, fault isolation — but network complexity, distributed tracing, data consistency pain. Modular monolith: simpler ops until team/traffic scale demands service extraction.
15
Eventual consistency — give a real example.
Consistency
Advanced
▾
Dynamo-style shopping cart or social feed: writes propagate asynchronously; users may briefly see stale counts. Acceptable when business rules allow temporary inconsistency with convergence guarantees.
16
How would you design a URL shortener?
Case Study
Advanced
▾
Clients → LB → API (create/redirect)
→ SQL/NoSQL (mapping)
→ Redis cache (hot links)
→ Analytics queue (async)Key: base62 ID generation, cache-aside for redirects, rate limit creation, TTL optional.
17
Design Twitter/X timeline (high level).
Case Study
FAANG
▾
Post service → Kafka → Fan-out workers Home timeline: push (write fan-out) for normal users; pull (merge on read) for celebrities. Cache timelines in Redis; rank by time/score.Trade-off: fan-out write amplification vs read latency.
18
Design Netflix video streaming architecture.
Case Study
FAANG
▾
Upload → transcode pipeline → object storage + CDN. Playback: adaptive bitrate (ABR), edge caches, regional origin failover. Control plane separate from data plane; SLO-driven capacity planning.
19
How do you achieve 99.99% availability?
High Availability
FAANG
▾
Eliminate single points of failure: multi-AZ, redundant load balancers, automated failover, chaos testing, graceful degradation, and error budgets. ~52 min downtime/year — requires defense in depth, not one trick.
20
Consistent hashing — why use it?
Distributed
Advanced
▾
Minimizes key remapping when nodes added/removed vs naive modulo hashing. Used in distributed caches, CDNs, and sharding routers. Virtual nodes improve balance.
21
What is service discovery?
Discovery
Intermediate
▾
Mechanism for clients to find healthy service instances (DNS, Consul, etcd, Kubernetes Services). Client-side (smart client) vs server-side (LB) discovery — K8s often uses ClusterIP + kube-proxy or mesh.
22
Kafka vs RabbitMQ — when to choose which?
Kafka
Advanced
▾
Kafka: high-throughput event log, replay, stream processing, retention by time. RabbitMQ: flexible routing (exchanges), task queues, lower operational footprint for classic messaging. Many systems use both.
23
What is backpressure?
Queues
Intermediate
▾
Slow consumers signal producers to reduce send rate — prevents unbounded queue growth and OOM. Implement via bounded queues, HTTP 429, or reactive streams.
24
Hot partition problem — mitigation?
Partitioning
Advanced
▾
Salting keys, composite partition keys, write sharding, or dedicated resources for hot tenants. Monitor per-partition QPS and size.
25
Idempotency in distributed APIs.
API Design
Intermediate
▾
Clients send Idempotency-Key header; server stores result for key TTL. Retries return same outcome without double charge/side effects. Critical for payments and write APIs.
26
What is the thundering herd problem?
Caching
Intermediate
▾
Many clients miss cache simultaneously and hammer origin/DB. Fix: request coalescing, jittered TTL, stale-while-revalidate, or pre-warming.
27
Active-active vs active-passive DR.
HA
Advanced
▾
Active-passive: standby region idle until failover — simpler, wasted capacity. Active-active: both regions serve traffic — lower RTO, harder data consistency and split-brain handling.
28
How do you estimate QPS capacity in an interview?
Fundamentals
FAANG
▾
Back-of-envelope: DAU × actions/day ÷ 86400 × peak factor. Then size app servers (req/s per core), DB writes, cache hit ratio, and bandwidth. State assumptions explicitly.
29
Bloom filters in system design.
Caching
Advanced
▾
Probabilistic structure: definitely not in set vs maybe in set. Used to avoid unnecessary DB lookups (e.g. CDN miss path, Cassandra anti-join). False positives possible; no false negatives.
30
Two-phase commit limitations.
Distributed
Advanced
▾
2PC blocks on coordinator failure and is not partition tolerant. Production often uses sagas, outbox pattern, or eventual consistency instead of global 2PC.
31
Outbox pattern for reliable events.
Event-Driven
Advanced
▾
Write business row + outbox row in same DB transaction. Separate relay publishes to message bus and marks sent. Guarantees at-least-once delivery without dual-write races.
32
Design a rate limiter for 1M RPS API.
Rate Limiting
FAANG
▾
Distributed counters in Redis Cluster with local token buckets at edge gateways for fast reject. Sync periodically; shard by API key hash. Return 429 + Retry-After.
33
What metrics define a healthy microservice?
Monitoring
Intermediate
▾
RED: Rate, Errors, Duration. Plus saturation (CPU, queue depth), dependency health, and SLO burn rate. Alert on symptoms users feel, not every infra blip.
34
GraphQL vs REST at scale.
API Design
Intermediate
▾
GraphQL reduces over-fetching but complicates caching and can enable expensive queries — need depth/complexity limits. REST simpler at CDN edge; GraphQL popular for mobile BFF layers.
35
How does DNS load balancing work?
Load Balancing
Beginner
▾
DNS returns multiple A records or geo-routed answers. Clients pick randomly; TTL controls cache. Coarse-grained — often paired with L7 LB behind DNS.
36
What is saga pattern?
Microservices
Advanced
▾
Sequence of local transactions with compensating actions on failure. Choreography (events) vs orchestration (central coordinator). Chooses availability over immediate cross-service ACID.
No questions match this filter.