A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Load Balancing and Server Selection

Graduate Depth 82 in the knowledge graph ☐ I know this ☆ Set as goal
2topics build on this
347prerequisites beneath it
See this on the map →
HTTP: Hypertext Transfer ProtocolIP Routing and Forwarding→→Reverse Proxy and Caching Architecture
load-balancing server-selection distribution failover

Core Idea

Load balancers distribute incoming requests across multiple servers to balance load, improve throughput, and provide fault tolerance. They may operate at layer 4 (transport) for simple round-robin distribution or layer 7 (application) for sophisticated decisions based on request content. Load balancing is essential for scaling services and maintaining availability.

Explainer

From your knowledge of IP routing and HTTP, you understand that a client sends a request to an IP address, the network routes it to the destination, and a server processes it and returns a response. But what happens when a single server cannot handle the volume of incoming requests? You cannot simply make one server infinitely powerful — hardware has limits, and a single machine is a single point of failure. The solution is to place multiple servers behind a load balancer, a device or software component that accepts all incoming connections and distributes them across a pool of backend servers, called a server farm or backend pool.

The simplest distribution strategy is round-robin: the load balancer sends the first request to server 1, the second to server 2, the third to server 3, and so on, cycling through the list. This works when all servers are identical and all requests take roughly the same effort. But real workloads are uneven — some requests are quick lookups, others trigger heavy computation. Weighted round-robin assigns more traffic to more powerful servers. Least-connections sends each new request to whichever server currently has the fewest active connections, naturally adapting to varying request durations. IP hash routes all requests from the same client IP to the same server, providing session affinity — important when the server maintains state about the client between requests.

Load balancers operate at two fundamentally different layers. A Layer 4 (transport) load balancer makes routing decisions based only on the TCP/IP header — source and destination IP addresses and port numbers. It is fast because it does not need to inspect the request content, but it cannot make content-aware decisions. A Layer 7 (application) load balancer inspects the actual HTTP request — the URL path, headers, cookies, even the request body. This enables powerful routing: send all `/api/` requests to one server pool and all `/static/` requests to another; route authenticated users to servers with their session data; direct mobile clients to optimized backends. Layer 7 balancing is more computationally expensive but enables fine-grained traffic management that layer 4 cannot achieve.

Beyond distributing load, load balancers provide health checking and fault tolerance. The load balancer periodically probes each backend server — sending a TCP connection attempt, an HTTP request, or a custom health check — and removes unresponsive servers from the pool automatically. When a server recovers, it is added back. This means a server can crash or be taken offline for maintenance without any client-visible downtime, as long as the remaining servers can absorb the load. Combined with redundant load balancers (an active-passive or active-active pair), this architecture eliminates single points of failure and provides the high availability that modern internet services require.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Subnetting and CIDR Notation → IP Routing and Forwarding → Load Balancing and Server Selection

Longest path: 83 steps · 347 total prerequisite topics

Prerequisites (2)

Leads To (1)