Study Notes
Notecore

Load Balancing

Send all your traffic to one machine and it buckles. Load balancing is the layer that fans requests across many servers — and it starts, surprisingly, at the level of the domain name you type in.

35 min read·verified Content review 2026·reviewed 2026-08-30

Assumes you know

After this you should be able to

  • Explain the core idea in Load Balancing
  • Apply Load Balancing in a representative design
System Design · Chapter 06

Send all your traffic to one machine and it buckles. Load balancing is the layer that fans requests across many servers — and it starts, surprisingly, at the level of the domain name you type in.

🧭
How to read this

The chapter follows the path a request actually takes: it starts as a domain name, gets resolved to an IP through DNS, and lands on a balancer that picks a server. So we cover the problem first, then DNS (the machinery you must understand before load balancing makes sense), then the balancing methods and algorithms themselves. Anything marked [+] is context I added; everything else is rewritten from the five teaching lessons.

01

One server can't hold the whole crowd#

A load balancer distributes incoming traffic across the servers in a cluster so no single machine gets overwhelmed. It's a key component of web architecture, and it exists to prevent a specific failure: if all traffic converges on one or a few machines, those machines overload — latency spikes, performance drops, and the nodes can go offline entirely. Spreading the requests avoids that mess.

The balancer also props up availability. If a server dies mid-request, the balancer simply routes future requests to the machines still running, so the service as a whole stays up. It acts as the single point of contact for every client request — clients talk to the balancer, and the balancer decides which server actually answers.

🔤
One vocabulary note from the course

Node, server, server node, instance, and machine all mean the same thing here and are used interchangeably.

Balancers aren't only for the front door. They can sit in front of any application component — backend app servers, the database, a message queue — to spread request load evenly across the machines powering that specific component.

client client client Load balancer server 1 server 2 server 3
Figure 1 — The balancer is the single point of contact: clients hit it, and it distributes each request across the healthy servers.
02

The balancer only trusts servers it can hear#

To route intelligently, a balancer must know which servers are actually alive — so it runs regular health checks. It keeps a real-time list of the machines that are up, and forwards requests only to those. A machine that's up is in-service; a machine that's down is out-of-service. When a server fails a health check, it's dropped from the list. When it recovers and passes again, the balancer adds it back and resumes routing to it.

🩺
Why this matters for the DNS method later

Hold onto this idea. The health-check list is exactly what DNS-level load balancing lacks — and that gap is the main reason DNS balancing is the crudest of the methods you'll meet in Section 05.

03

DNS turns names into numbers#

Every machine on the web has a unique IP address, and DNS is the system that lets you reach one without memorizing it. IP (Internet Protocol) delivers data packets between machines using those addresses — something like 2001:db8:0:1234:0:567:8:1. Nobody can hold addresses like that in their head, so the Domain Name System (DNS) maps a memorable domain name such as amazon.com to its IP address for you.

When you type a URL and hit enter, that event is called DNS querying. Resolving the name involves four kinds of servers working in a chain:

DNS componentIts job
DNS Recursive nameserver
(aka DNS Resolver)
Receives your browser's request and does the legwork of walking the chain. Usually run by your ISP.
Root nameserverPoints the Resolver to the right top-level domain nameserver.
Top-Level Domain (TLD) nameserverHolds data for a whole extension — the .com TLD server knows about all .com domains, .edu for .edu, and so on.
Authoritative nameserverThe final server in the chain; owned by the domain's owner. Returns the domain's actual IP address.
04

Following a query through all four servers#

Here's the full lookup for amazon.com, step by step.

  1. Browser → Resolver. You hit enter; the browser sends the request to the DNS Resolver (recursive nameserver), typically managed by your ISP.
  2. Resolver → Root. The Resolver asks the Root nameserver where to find the right TLD server. The Root returns the address of the .com TLD nameserver.
  3. Resolver → TLD. The Resolver queries the .com TLD server, which returns the address of the amazon.com authoritative nameserver.
  4. Resolver → Authoritative. The Resolver queries the authoritative nameserver, which returns the actual IP address of amazon.com.
  5. Resolver caches → Browser. The Resolver caches the result and hands the IP to your browser, which then requests the site directly from that IP.

Caching keeps this fast. The whole DNS infrastructure is a distributed system living in large ISP data centers, with server clusters tuned to answer queries in milliseconds. Results are cached along the way — and your own device caches DNS records too, with a TTL (Time To Live). Modern browsers do this automatically to skip the lookup on repeat visits.

Browseryou ResolverISP Root NS .com TLD Authoritative amazon.comweb server browser fetches site from returned IP
Figure 2 — The DNS query lookup chain. The Resolver walks Root → TLD → Authoritative, caches the IP, and returns it so the browser can hit the site directly.
05

The first place to balance: the authoritative server#

A service the size of amazon.com runs across many data centers worldwide, and DNS load balancing spreads traffic across them right at the authoritative nameserver. Instead of returning a single IP, the authoritative server returns a list of IPs for the domain — and with each query it rotates the order of that list in round-robin fashion.

The client tries the first IP on the list; the reason it gets a whole list is so it can fall back to the next IP if the first doesn't respond in time. The next client's query gets the list re-ordered with a different IP on top, and so on. Note that the IP a client hits may not be an application server directly — it's often another load balancer at the data-center level that manages that site's server clusters.

Authoritative NS rotates IP list per query client 1 receives [ IP-A, IP-B, IP-C ] tries IP-A first client 2 receives [ IP-B, IP-C, IP-A ] tries IP-B first client 3 receives [ IP-C, IP-A, IP-B ] tries IP-C first
Figure 3 — Round-robin DNS: each client receives the same IPs in a rotated order, distributing which server they try first.
⚠️
Why DNS balancing is the blunt instrument

It ignores everything the balancer in Section 02 tracks: current server load, the content a server holds, request-processing time, and in-service status. Worse, because clients and Resolvers cache those IPs, a request can still be routed to a machine that's already out of service. Companies use it anyway — across multiple data centers — because it's cheap and easy to set up.

06

Hardware or software — pick your balancer#

There are three modes of load balancing overall: DNS (covered above), hardware-based, and software-based. The latter two are the common ways to balance traffic on large-scale services.

Hardware load balancersSoftware load balancers
What they areDedicated high-performance physical appliances that sit in front of the app servers.Software installable on commodity hardware and VMs; also available as LBaaS (Load Balancer as a Service) with no setup.
Routing inputsOpen connection count, compute utilization, and other parameters.Far more advanced — data hosted by servers, cookies, HTTP headers, CPU/memory use, network load, plus continual health checks.
Cost & opsExpensive; need maintenance, updates, and a specialist skill set. Must be over-provisioned upfront for peak traffic.Cost-effective, flexible, easy to upgrade and provision on demand.
VerdictBest raw performance — if you have a network/IT team to run them.Preferred by dev teams because they don't need specialists to manage. e.g. HAProxy, used by GitHub, Reddit, Instagram, AWS, Tumblr, and StackOverflow.

The trade-off in one line: hardware wins on peak performance, software wins on cost, flexibility, and how much smarter its routing decisions can be — which brings us to the algorithms.

07

How a balancer actually picks a server#

DNS balancers only know round robin. Software balancers add several smarter algorithms.

Round robin & weighted round robin

Round robin hands out server IPs sequentially, ignoring load, CPU, or anything else. Weighted round robin fixes the blind spot: each server gets a weight based on its compute and traffic-handling capacity, and traffic is distributed in proportion to those weights. More traffic flows to the beefier machines — useful when a service spans multiple data centers of different sizes, so the larger ones absorb more.

Least connections

Routes the next request to the machine with the fewest open connections. Two flavors:

  • Naive: assumes every request costs the same resources — but the machine with the fewest connections might already be pinned at high CPU, so sending more there is a bad bet.
  • Resource-aware: also weighs CPU utilization and request-processing time. The ideal target has the shortest processing time, lowest CPU use, and fewest open connections.

Least connections shines when connections stay open a long time — like persistent connections in a gaming application. [+]

Random

Routes traffic to servers at random. The balancer may also group servers that look similar (by existing load, processing time, etc.) and then randomly pick among that similar set.

Hash

Hashes the source IP and/or the request URL to decide the target — and the payoff is stickiness:

client IP hash(IP)balancer same serverholds session → session stays local, lower latency request URL hash(URL)balancer same cachedata present → no cache miss, no duplication
Figure 4 — Hashing for stickiness. Hashing the client IP pins a user to one server (session stays warm); hashing the URL pins a resource to one cache (avoids misses and duplication).

Hashing the source IP guarantees a given client always lands on the same server. That server already holds the client's data in local memory, so it skips fetching session data from the cluster's shared session store — lower latency — and lets the client re-establish with the same server if the connection drops. Hashing the URL guarantees a request always hits the cache that already holds its data, avoiding cache misses and removing the need to duplicate data across every cache.

08

Recap#

Balancer = single point of contactFans traffic across a cluster so no machine overloads; reroutes around dead servers to keep the service up.
Health checks drive routingThe balancer keeps a live list of in-service machines and only routes to those.
DNS resolves names to IPsResolver → Root → TLD → Authoritative, with heavy caching (TTL) to stay millisecond-fast.
DNS balancing = round robinAuthoritative server rotates a list of IPs. Cheap and easy, but ignores load and can route to dead nodes.
Hardware vs. softwareHardware = top performance, costly, specialist-run. Software (e.g. HAProxy) = cheap, flexible, smarter.
Algorithms beyond round robinWeighted round robin, least connections, random, and hash (IP for stickiness, URL for cache hits).
💡
The single idea underneath it all

Every load-balancing method is the same bet made with better information. Round-robin DNS decides blind; a software balancer decides with health, load, CPU, and hashing signals. The more the router knows about the servers behind it, the smarter — and stickier — its choice of where your request lands.

09

Further reading#

The section cites two external links. Both verified live today.

[1]
Round-robin DNS — Wikipedia Why read it: expands Section 05 with the mechanics of A-record rotation and a dedicated "Drawbacks" section that reinforces exactly why DNS balancing shouldn't be relied on alone (caching, no load awareness, routing to failed hosts).
[2]
HAProxy Why read it: the canonical software load balancer named in Section 06 — the real-world tool behind the algorithms in this chapter. ⚠ Now a broad enterprise-platform site; the course cited it simply as an example software balancer.

Rewritten in full from the Load Balancing section of Web Application & Software Architecture 101 — merging its five teaching lessons (Introduction to load balancing, Understanding DNS Parts 1 & 2, DNS load balancing, and Load balancing methods). The end-of-section quiz was skipped. All four diagrams are original SVGs built from the lessons' descriptions, not reproductions of the source images. [+] marks context added beyond the source. Both external links were verified live on Aug 13, 2026.