Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Interview questions › System Design

System Design interview questions

1. What is system design?

Easy

Designing the architecture of a software system — components, data flow, storage, APIs and infrastructure — so it meets functional requirements and non-functional ones like scalability, availability, latency and cost.

2. HLD vs LLD?

Easy

High-Level Design describes the big picture: services, databases, caches, load balancers and how they interact. Low-Level Design describes classes, interfaces, methods, data structures and design patterns inside a component.

3. How should you approach a system design interview?

Easy

  1. Clarify functional and non-functional requirements. 2) Estimate scale (users, QPS, storage). 3) Define APIs. 4) Design the data model. 5) Draw the high-level architecture. 6) Deep-dive into bottlenecks (caching, sharding, queues). 7) Discuss trade-offs and failure handling.

4. Vertical vs horizontal scaling?

Easy

Vertical: add more CPU/RAM to one machine — simple but limited and a single point of failure. Horizontal: add more machines behind a load balancer — scales much further but needs stateless services and distributed data.

5. What is a load balancer and its algorithms?

Easy

It distributes traffic across servers, performs health checks and removes failed servers. Algorithms: round robin, weighted round robin, least connections, IP hash, and least response time.

6. What is a stateless service?

Medium

A service that stores no client session data in its own memory between requests; state lives in a database, cache or token. Any instance can serve any request, which makes horizontal scaling and failover easy.

7. What is caching and where can you cache?

Easy

Storing frequently accessed data in fast storage to reduce latency and backend load. Layers: browser cache, CDN, reverse proxy, application cache (Redis/Memcached), and database cache.

8. Cache-aside vs write-through vs write-back?

Medium

Cache-aside: app reads cache, on miss loads from DB and populates cache. Write-through: writes go to cache and DB together (consistent, slower). Write-back: writes go to cache and are flushed later (fast, risk of loss).

9. What are cache eviction policies?

Easy

LRU (least recently used), LFU (least frequently used), FIFO, random and TTL-based expiry. LRU is the most common default.

10. What is cache invalidation and why is it hard?

Medium

Removing or updating cached data when the source changes. It is hard because you must keep caches consistent across servers without losing the performance benefit — approaches include TTLs, delete-on-write and event-based invalidation.

11. What is a CDN?

Easy

A Content Delivery Network serves static content from edge servers close to users, reducing latency and origin load. Push CDNs upload content in advance; pull CDNs fetch from the origin on first request.

12. What is database replication?

Medium

Copying data to multiple database servers. Primary–replica (leader–follower) sends writes to the primary and reads to replicas; multi-primary allows writes on several nodes but needs conflict resolution. It improves read scaling and availability.

13. What is sharding? How do you choose a shard key?

Medium

Splitting data horizontally across databases. A good shard key spreads data and traffic evenly and keeps related data together (e.g. user_id). Bad keys create hot shards. Strategies: range, hash, directory/geo based.

14. What is consistent hashing?

Hard

A hashing scheme where servers and keys are placed on a ring and each key belongs to the next server clockwise. Adding or removing a server moves only about 1/N of the keys. Virtual nodes even out the load. Used in Cassandra, DynamoDB and distributed caches.

15. What is the CAP theorem?

Easy

In a distributed system, during a network partition you must choose consistency (reject or delay requests to avoid stale data) or availability (serve possibly stale data). Partition tolerance is required in practice, so systems are CP or AP.

16. What is eventual consistency?

Medium

A consistency model where, if no new updates are made, all replicas will eventually return the same value. Reads may be temporarily stale. Used by AP systems like DNS, Cassandra and social feeds.

17. SQL vs NoSQL — how do you choose?

Easy

Choose SQL for structured data, relationships, complex queries and strong transactions (payments, orders). Choose NoSQL for massive scale, flexible schemas, high write throughput or specific models (key-value cache, document store, wide-column time series, graphs).

18. What is a message queue and why use it?

Easy

A queue (Kafka, RabbitMQ, SQS) where producers publish messages and consumers process them asynchronously. It decouples services, smooths traffic spikes, enables retries and makes slow work (emails, video encoding) background jobs.

19. Kafka vs RabbitMQ?

Hard

Kafka is a distributed log: very high throughput, messages are retained and can be replayed, consumer groups read partitions in order — great for event streaming. RabbitMQ is a traditional broker with flexible routing and per-message acknowledgements — great for task queues.

20. What are microservices? Pros and cons?

Medium

An architecture where an application is split into small, independently deployable services, each owning its data. Pros: independent scaling and deployment, team autonomy, technology freedom. Cons: network latency, distributed data consistency, harder debugging and operations.

21. Monolith vs microservices?

Easy

A monolith is one deployable unit — simple to build, test and deploy early on. Microservices suit large teams and systems needing independent scaling. Most products start as a well-structured monolith and split later.

22. What is an API gateway?

Medium

A single entry point in front of microservices that handles routing, authentication, rate limiting, request aggregation, caching and logging.

23. What is rate limiting? Name algorithms.

Medium

Restricting how many requests a client can make in a time window to prevent abuse and overload. Algorithms: token bucket, leaky bucket, fixed window counter, sliding window log and sliding window counter.

24. Explain the token bucket algorithm.

Hard

A bucket holds up to N tokens and is refilled at a fixed rate. Each request takes a token; if the bucket is empty the request is rejected (429). It allows short bursts up to N while enforcing an average rate.

25. REST vs GraphQL vs gRPC?

Medium

REST: resource URLs + HTTP verbs, simple and cacheable. GraphQL: one endpoint where clients ask for exactly the fields they need — avoids over/under-fetching. gRPC: binary Protocol Buffers over HTTP/2 — very fast, great for service-to-service calls.

26. What makes an API idempotent? Why does it matter?

Medium

An operation is idempotent if repeating it has the same effect as doing it once (GET, PUT, DELETE). It matters because clients retry on timeouts; for payments, use an idempotency key so a retried POST doesn't charge twice.

27. What is horizontal partitioning vs vertical partitioning?

Medium

Horizontal partitioning (sharding) splits rows across tables/servers. Vertical partitioning splits columns (e.g. move rarely used large columns to another table) or splits by feature into separate databases.

28. What is a single point of failure and how do you remove it?

Easy

A component whose failure brings down the whole system. Remove it with redundancy: multiple app servers behind redundant load balancers, database replicas with failover, multi-AZ/multi-region deployments.

29. What is high availability? What do "nines" mean?

Easy

The proportion of time a system is operational. 99.9% allows ~8.8 hours of downtime per year, 99.99% ~53 minutes, 99.999% ~5 minutes. Achieved with redundancy, health checks, failover and graceful degradation.

30. What is latency vs throughput?

Easy

Latency is how long one request takes (ms). Throughput is how many requests are handled per unit time (QPS). Improving one can hurt the other (e.g. batching raises throughput but adds latency).

31. How do you design a URL shortener?

Medium

APIs: POST /shorten, GET /{code}. Generate a unique 7-char Base62 code (counter-based ID service or hashing with collision checks). Store code → URL in a key-value store, cache hot codes in Redis, put app servers behind a load balancer, and return 301/302 redirects.

32. How would you design a rate limiter?

Hard

Place it in the API gateway or middleware. Use a token bucket or sliding-window counter per user/IP stored in Redis (atomic INCR + EXPIRE or Lua script) so all servers share counts. Return 429 with Retry-After headers.

33. How would you design a chat application like WhatsApp?

Hard

Clients keep WebSocket connections to chat servers; a service registry maps users to servers. Messages are stored (Cassandra-like store partitioned by chat), delivered via the recipient's connection or queued for offline users with push notifications. Add read receipts, presence via heartbeats, and media in object storage + CDN.

34. How would you design a news feed?

Hard

Store posts; build feeds by fan-out on write (push post IDs into followers' feed caches — fast reads) or fan-out on read (merge at read time — better for celebrities). Most systems use a hybrid, cache feeds in Redis and rank them.

35. How would you design YouTube / video streaming?

Hard

Uploads go to object storage; a queue triggers transcoding into multiple resolutions and chunks (HLS/DASH). Metadata lives in a database, video chunks are served through a CDN, and the player uses adaptive bitrate to switch quality.

36. What is a reverse proxy?

Easy

A server (Nginx, HAProxy) in front of backend servers that receives client requests and forwards them, adding load balancing, SSL termination, caching, compression and security.

37. What is service discovery?

Medium

A mechanism for services to find each other's network locations dynamically (Consul, Eureka, Kubernetes DNS), since instances scale up and down and change IPs.

38. What is the circuit breaker pattern?

Hard

When calls to a failing service keep timing out, the circuit "opens" and further calls fail fast (or use a fallback) for a while, then a few trial calls test recovery. It prevents cascading failures.

39. What is database indexing in system design?

Easy

Indexes make reads on queried columns fast (B+ tree or hash) at the cost of slower writes and extra storage. Index columns used in WHERE, JOIN and ORDER BY, and avoid over-indexing write-heavy tables.

40. What is denormalization in system design?

Medium

Storing redundant or precomputed data (e.g. a like count on the post row, or an author's name inside each post document) to avoid expensive joins on hot read paths, accepting more complex writes.

41. What is the difference between push and pull models?

Medium

In push, the server sends data to clients as it changes (WebSockets, notifications, fan-out on write). In pull, clients request data when needed (polling, fan-out on read). Push gives freshness; pull gives simplicity and control.

42. WebSockets vs long polling vs SSE?

Medium

Long polling: client waits on a request until the server has data, then reconnects. SSE: one-way server-to-client stream over HTTP. WebSockets: full-duplex persistent connection — best for chat, games and live collaboration.

43. How do you estimate storage and QPS in an interview?

Medium

Start from daily active users and actions per user: QPS = daily requests / 86,400 (≈ 10^5 seconds), peak ≈ 2–3× average. Storage = items per day × size per item × retention days. Round numbers and state assumptions clearly.

44. What is object storage?

Easy

Storage for large unstructured files (images, videos, backups) accessed via HTTP APIs, e.g. Amazon S3. It is cheap, highly durable and scales almost infinitely; usually paired with a CDN.

45. What is the Saga pattern?

Hard

A way to manage a business transaction across microservices without a distributed lock: a sequence of local transactions where each step publishes an event, and failures trigger compensating actions (e.g. refund payment if inventory fails).

46. What is observability?

Medium

Understanding a system from its outputs using logs, metrics and traces. Tools: Prometheus/Grafana for metrics, ELK for logs, OpenTelemetry/Jaeger for distributed tracing; plus alerting on SLOs.

47. What is a distributed unique ID generator?

Hard

A way to create unique IDs across many servers without a central database bottleneck — e.g. Twitter Snowflake: 64-bit IDs made of timestamp + machine ID + per-machine sequence, which are also roughly time-sortable.

48. What is blue-green and canary deployment?

Medium

Blue-green: run two identical environments and switch traffic from the old (blue) to the new (green) at once — easy rollback. Canary: release to a small percentage of users first, monitor, then gradually roll out.

49. What is a bloom filter?

Hard

A space-efficient probabilistic structure that answers "is X in the set?" with no false negatives but possible false positives, using several hash functions over a bit array. Used to avoid unnecessary disk/DB lookups (e.g. checking if a username might exist, or in Cassandra/HBase reads).

50. What is back-of-the-envelope estimation for a read-heavy system?

Medium

If reads ≫ writes (e.g. 100:1), optimise the read path: aggressive caching, read replicas, CDNs and denormalised views. Keep writes simple and push expensive work to async jobs.

More topics