Mastering Load Balancing: Types, Architectures, and Algorithms Explained
This article explains why high‑performance clusters are complex, introduces the three main load‑balancing categories—DNS, hardware, and software—describes their definitions, advantages, and drawbacks, outlines typical combined architectures, and reviews common load‑balancing algorithms such as round‑robin, weighted round‑robin, least‑load, performance‑optimal, and hash‑based methods.
Classification and Architecture
Common load balancers are divided into three types: DNS load, hardware load, software load.
1. DNS Load Balancing
Definition: Resolving the same domain name to different IP addresses, typically used for geographic load balancing. For example, northern and southern users receive different addresses.
Advantages: Simple, low cost; enables nearby access, improving speed.
Disadvantages: Updates are not timely due to DNS cache; poor scalability; simple allocation strategies.
2. Hardware Load Balancing
Definition: Implemented via dedicated hardware devices (e.g., F5, A10) that perform load balancing.
Advantages: Powerful features (supports multiple layers, many algorithms, global load balancing); high performance (over 1 million concurrent connections); high stability; includes security functions (firewall, DDoS protection).
Disadvantages: Expensive (starting around 150,000 CNY, up to millions); limited extensibility.
3. Software Load Balancing
Definition: Implemented with load‑balancing software such as Nginx or LVS.
Advantages: Simple deployment and maintenance; inexpensive (just a Linux server); flexible and customizable.
Disadvantages (compared with hardware): Moderate performance (Nginx handles about 50,000 concurrent connections); fewer features; generally lacks firewall and DDoS protection.
4. Typical Architecture
The three mechanisms can be combined. Basic principle: DNS load balancing for geographic level; hardware load balancing for cluster level; software load balancing for machine level.
Algorithms
Based on the goal, algorithms are classified into four categories: task classification (even distribution by count, proportion, weight), load‑balancing (based on server load metrics like CPU, connections, I/O), performance‑optimal (assign to servers with fastest response), and hash‑based (assign based on hash of key information).
1. Round‑Robin
Definition: Assign tasks to servers in order, without considering server status. Simple but may ignore server health.
2. Weighted Round‑Robin
Definition: A variant of round‑robin that uses static weights based on hardware capacity to distribute tasks. Still does not consider real‑time server status.
3. Least‑Load First
Definition: Assign tasks to the server with the lowest current load, measured by metrics such as connections, request count, CPU, or I/O. Improves over round‑robin but adds complexity due to state monitoring.
4. Performance‑Optimal
Definition: From the client’s perspective, assign tasks to the server with the fastest processing speed. Similar to least‑load but requires extensive monitoring and analysis.
5. Hash‑Based
Definition: Compute a hash on certain key information of the task; requests with the same hash value are routed to the same server, useful for session affinity or transactional workloads (e.g., source‑IP hash, ID hash).
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.