Load Balancer
A load balancer picks one server for each request. A poor rule leaves some servers with long queues while others sit idle. Requests vary in cost: most take a few hundred milliseconds, while a search or a checkout can take seconds. Servers also differ in size and in current speed. The selection rule is a load-balancing algorithm, and algorithms differ in what they know about each server.
What a Load Balancer Does
Most load balancers act as a reverse proxy: clients connect to the load balancer rather than directly to the servers. The application's domain name resolves to the load balancer's address. For each incoming request, the load balancer picks a server from its pool, forwards the request, and returns the server's response to the client. Because clients never learn the servers' addresses, the team can add, remove, or replace servers without changing anything on the client side.
The load balancer also sends a health check to each server at a fixed interval and removes any server that fails it. The System Design Components lesson shows that mechanism in a widget. This lesson assumes every server in the pool is running and focuses on how to pick which running server gets the next request.
Static Algorithms
A static algorithm follows a fixed rule and ignores how busy each server is right now.
Round robin sends requests to the servers in turn: server 1, server 2, server 3, server 1, and so on. Each server gets one request in three. Round robin works well when the servers are alike and the requests cost about the same.
Weighted round robin assigns each server a weight proportional to its capacity. A server with weight 4 gets four requests for every one that a server with weight 1 gets. Because these weights come from static configuration, they stay accurate only while the configured capacity matches the real capacity.
Both rules count requests rather than work. If one request in ten takes ten times longer than the rest, round robin still sends each server the same number of requests. When a server happens to receive several long requests in a row, it fills up and new requests wait behind them. The same queueing happens when one server slows down, such as when a noisy neighbor on its host uses the CPU. Round robin keeps sending that slow server one request in three.
Dynamic Algorithms
A dynamic algorithm checks the current state of each server before choosing one.
Least connections sends each request to the server with the fewest open connections. The load balancer already tracks this count because every active request holds a connection through it. A server that works slowly holds its connections longer, which raises its count so it receives fewer new requests. This algorithm adapts to slow servers and long requests without knowing why they are slow.
Least response time prefers the server with the lowest recent response time, often combined with the connection count. It reacts to servers that are slow even when they hold few connections, at the cost of measuring latency for every server.
Power of two choices picks two servers at random and sends the request to the one with fewer connections. Comparing only two random servers spreads load almost as well as checking every server (Mitzenmacher, The Power of Two Choices in Randomized Load Balancing). This approach helps when many load balancers share one pool and read load data that is a moment old. If each load balancer chose the single least-loaded server, they would all pick that same server at once and overload it. Because two random samples differ from one load balancer to the next, the requests spread out.
Grasping the building blocks ("the lego pieces")
This part of the guide will focus on the various components that are often used to construct a system (the building blocks), and the design templates that provide a framework for structuring these blocks.
Core Building blocks
At the bare minimum you should know the core building blocks of system design
- Scaling stateless services with load balancing
- Scaling database reads with replication and caching
- Scaling database writes with partition (aka sharding)
- Scaling data flow with message queues
System Design Template
With these building blocks, you will be able to apply our template to solve many system design problems. We will dive into the details in the Design Template section. Here’s a sneak peak:

Additional Building Blocks
Additionally, you will want to understand these concepts
- Processing large amount of data (aka “big data”) with batch and stream processing
- Particularly useful for solving data-intensive problems such as designing an analytics app
- Achieving consistency across services using distribution transaction or event sourcing
- Particularly useful for solving problems that require strict transactions such as designing financial apps
- Full text search: full-text index
- Storing data for the long term: data warehousing
On top of these, there are ad hoc knowledge you would want to know tailored to certain problems. For example, geohashing for designing location-based services like Yelp or Uber, operational transform to solve problems like designing Google Doc. You can learn these these on a case-by-case basis. System design interviews are supposed to test your general design skills and not specific knowledge.
Working through problems and building solutions using the building blocks
Finally, we have a series of practical problems for you to work through. You can find the problem in /problems. This hands-on practice will not only help you apply the principles learned but will also enhance your understanding of how to use the building blocks to construct effective solutions. The list of questions grow. We are actively adding more questions to the list.