All topics

System design interview questions

260 questions, 212 with answers. 1,177 open jobs in India ask for System design.

  1. Design a Messenger

    Key points:

    • Websocket for notifications
    • Queue for reliable message delivery
    • NoSQL db for fast access to messages
    • Relational DB for user info
    • Object storage (S3) for media files
    • Fast in-memory storage (like Redis) for implementing presence Links
    • https://newsletter.systemdesign.one/p/whatsapp-system-design
    • https://www.systemdesignhandbook.com/guides/design-a-chat-system/
    • https://bytebytego.com/courses/system-design-interview/design-a-chat-system
    • https://www.geeksforgeeks.org/system-design/desiging-facebook-messenger-system-design-interview/

    Home Page

    From Java interview (MIT)

  2. Imperative vs functional vs reactive programming?

    Imperative programming is fundamental to any programming language and even machine language is imperative. Internally other programming paradigm in some way or the other use imperative style internally but abstracts this out for the caller. Imperative style is mostly sequential and follows a natural flow, hence it is easy to write, debug and troubleshoot. In most case this offers better raw performance than other.

    Functional programming is treating computation as “mathematical functions”, using pure function without side effect which does not change state. State are immutable in functional programming.

    Reactive programming is typically asynchronous events data stream over time and its propagation of change. It is built on observable (publish/subscribe) & iterator pattern. Generally there are also functional programming and reactive programming done together for transformation of one streams to another. Links

    • https://www.webagam.com/2018/11/24/imperative-functional-reactive-programming-which-one-to-use-when-and-for-what/

    From Java interview (MIT)

  3. What is Serverless?

    Like many trends in software, there’s no one clear view of what Serverless is. For starters, it encompasses two different but overlapping areas:

    1. Serverless was first used to describe applications that significantly or fully incorporate third-party, cloud-hosted applications and services, to manage server-side logic and state. These are typically “rich client” applications—think single-page web apps, or mobile apps—that use the vast ecosystem of cloud-accessible databases (e.g., Parse, Firebase), authentication services (e.g., Auth0, AWS Cognito), and so on. These types of services have been previously described as “(Mobile) Backend as a Service", and I use "BaaS" as shorthand in the rest of this article.
    2. Serverless can also mean applications where server-side logic is still written by the application developer, but, unlike traditional architectures, it’s run in stateless compute containers that are event-triggered, ephemeral (may only last for one invocation), and fully managed by a third party. One way to think of this is “Functions as a Service” or "FaaS". (Note: The original source for this name—a tweet by @marak—is no longer publicly available.) AWS Lambda is one of the most popular implementations of a Functions-as-a-Service platform at present, but there are many others, too. Links
    • https://martinfowler.com/articles/serverless.html

    From Java interview (MIT)

  4. What is the key difference between 2-phase commit and saga for distributed transactions?

    2PC uses a blocking coordinator and locks resources to ensure atomicity (all-or-nothing). Saga uses compensating actions to handle failures without locks, offering higher availability but eventual consistency. Links

    • https://www.geeksforgeeks.org/system-design/saga-design-pattern/
    • https://www.baeldung.com/cs/two-phase-commit-vs-saga-pattern

    From Java interview (MIT)

  5. When is server-side rendering technology useful?

    SSR is particularly useful when your primary goals are fast initial page loads and strong search engine optimization. This makes it an excellent choice for content-driven web applications, e-commerce platforms, and any public-facing site where discoverability and user experience are critical. By rendering the full HTML on the server, SSR ensures that users see content immediately and that search engine crawlers can easily index the page without needing to execute complex JavaScript. Links

    • https://developers.google.com/solutions/content-driven/hosting/rendering?hl=en

    Home Page

    From Java interview (MIT)

  6. What is the difference between performance and scalability?

    Performance is how fast the system is for one user today. Scalability is whether it stays fast and affordable as load grows. Slow for a single user is a performance problem. Fast for one user but failing under many is a scalability problem.

    From Grokking System Design (open companion) (CC BY 4.0)

  7. Vertical or horizontal scaling: what is the difference?

    Vertical scaling means a bigger machine. It is simple, but it has a hard ceiling and stays a single point of failure. Horizontal scaling means more machines behind a load balancer. It has no hard ceiling and survives node loss, but it needs stateless services and partitioned data.

    From Grokking System Design (open companion) (CC BY 4.0)

  8. Latency or throughput: what is the difference?

    Latency is the time to serve one request. Throughput is how many requests the system serves per second. They move independently. You can add capacity to raise throughput without making any single request faster.

    From Grokking System Design (open companion) (CC BY 4.0)

  9. Why report latency as percentiles instead of averages?

    An average hides the slow tail. If one request in a hundred takes two seconds, the average still looks healthy. Report p50, p95, and p99. At scale the tail matters more, because one page may make a hundred backend calls and wait for the slowest.

    From Grokking System Design (open companion) (CC BY 4.0)

  10. What is a bottleneck, and how do you find one?

    A bottleneck is the one component that limits the whole system. Find it by following the request path and asking which resource saturates first: CPU, memory, disk, network, or a lock. Adding capacity anywhere else changes nothing.

    From Grokking System Design (open companion) (CC BY 4.0)

  11. How much downtime does 99.99% availability allow per year?

    About 53 minutes. For comparison, 99.9% allows about 8.8 hours per year, and 99.999% allows about 5 minutes.

    From Grokking System Design (open companion) (CC BY 4.0)

  12. How does availability combine across components?

    In sequence, where both must work, the numbers multiply and the total drops below either one. In parallel, where either one is enough, the failure rates multiply and the total rises. Redundancy adds availability, and dependency chains remove it.

    From Grokking System Design (open companion) (CC BY 4.0)

  13. Active-passive or active-active failover: what is the difference?

    Active-passive keeps one node serving and one standby idle. It is simpler, but capacity sits unused and there is a short gap during failover. Active-active has both nodes serving. There is no idle capacity, but each node must handle the full load alone, and shared state gets harder.

    From Grokking System Design (open companion) (CC BY 4.0)

  14. What is a single point of failure?

    Any component whose loss takes down the system, because nothing else can do its job. Common examples are one database primary, one load balancer, or one region.

    From Grokking System Design (open companion) (CC BY 4.0)

  15. What is graceful degradation?

    Serving a reduced version of the product instead of an error when a dependency fails. An example is hiding the recommendation row when the recommendation service is down, while checkout keeps working.

    From Grokking System Design (open companion) (CC BY 4.0)

  16. State the CAP theorem.

    During a network partition, a distributed system can guarantee consistency or availability, but not both. Partitions are not optional, so the real choice is what to do during one. A CP system refuses the request rather than serve stale data. An AP system keeps serving and reconciles later.

    From Grokking System Design (open companion) (CC BY 4.0)

  17. What does PACELC add to CAP?

    It covers the normal case, when there is no partition. Even then you trade latency against consistency, because keeping replicas in agreement costs a round trip on every write. Read it as: if Partitioned, choose A or C; Else, choose L or C.

    From Grokking System Design (open companion) (CC BY 4.0)

  18. Weak, eventual, or strong consistency: what is the difference?

    Weak means a read may never see a given write, which is fine for live video. Eventual means replicas agree once writes stop, so reads can be briefly stale, which is fine for a feed. Strong means every read sees the latest write, which is required for money and for booking a seat.

    From Grokking System Design (open companion) (CC BY 4.0)

  19. What is read-your-writes consistency?

    A guarantee that a user always sees their own updates, even if other users see them later. Without it, a user edits a profile, gets routed to a lagging replica, and sees the old value.

    From Grokking System Design (open companion) (CC BY 4.0)

  20. What is monotonic reads consistency?

    A guarantee that a user never sees data move backward in time. Without it, two reads hitting replicas with different lag can show a comment appearing and then vanishing.

    From Grokking System Design (open companion) (CC BY 4.0)

  21. Layer 4 or Layer 7 load balancing: what is the difference?

    Layer 4 routes on IP address and port without reading the request. It is fast and works for any protocol. Layer 7 reads the request and routes on path, header, or cookie. That enables content-based routing and TLS termination, at higher cost per request.

    From Grokking System Design (open companion) (CC BY 4.0)

  22. Reverse proxy or load balancer: what is the difference?

    A load balancer spreads traffic across many identical backends. A reverse proxy is a single entry point in front of your services, and it is useful even with one backend, for TLS termination, caching, and request filtering. One piece of software often does both jobs.

    From Grokking System Design (open companion) (CC BY 4.0)

  23. Why must application servers be stateless to scale horizontally?

    Behind a load balancer, a request can land on any server. If session data lives in one server's memory, the other servers cannot serve that user. Move state to a shared store or the client, and any server can handle any request.

    From Grokking System Design (open companion) (CC BY 4.0)

  24. Name the common load balancing algorithms.

    Round robin, weighted round robin, least connections, and hashing on a key such as client IP. Least connections handles uneven request costs better. Hashing gives stickiness, at the cost of even distribution.

    From Grokking System Design (open companion) (CC BY 4.0)

  25. What do health checks do in a load balancer?

    They test each backend on an interval and remove failing ones from rotation. Without them, the load balancer keeps sending traffic to a dead server.

    From Grokking System Design (open companion) (CC BY 4.0)

  26. Explain the cache-aside strategy.

    The application checks the cache first. On a miss it reads the database, writes that value into the cache, and returns it. It is the default choice for read-heavy workloads, because only requested data is cached.

    From Grokking System Design (open companion) (CC BY 4.0)

  27. Write-through or write-back caching: what is the difference?

    Write-through writes to the cache and the database together. Reads after a write are correct, but writes are slower. Write-back writes to the cache and flushes to the database later. Writes are fast, but data is lost if the cache dies before the flush.

    From Grokking System Design (open companion) (CC BY 4.0)

  28. What is a cache stampede, and how do you prevent it?

    When a popular key expires, many requests miss at once and hit the database together. Prevent it by letting one request refill the key while the others wait, by spreading expiry times, or by refreshing hot keys before they expire.

    From Grokking System Design (open companion) (CC BY 4.0)

  29. Name the common cache eviction policies.

    Least recently used, least frequently used, first in first out, and plain time-to-live expiry. Least recently used is the usual default, because recent access predicts near-future access well.

    From Grokking System Design (open companion) (CC BY 4.0)

  30. Why is cache invalidation hard?

    The cache holds a copy, so every write creates two versions of the truth. You choose between expiring on a timer, which serves stale data for that window, and deleting on write, which is exact but has to reach every cache that holds the key.

    From Grokking System Design (open companion) (CC BY 4.0)

After the last page: 48 questions more, without answers. Go to the last page

Related topics

Where these questions come from

Open-source collections on GitHub, official documentation, a government careers service and the Stack Exchange sites, each used under its own licence. The answers are the authors' own words: we only tidy the layout, leave out pictures, and cut a long answer with a link to the rest. Stack Exchange answers stay under CC BY-SA and name who asked and who answered.