Operations 5 min read

Mastering Load Balancing: Types, Algorithms, and Best Practices

This article outlines the three main load‑balancing methods—DNS, hardware, and software—detailing their advantages and drawbacks, then explains common algorithms such as round‑robin, weighted round‑robin, least‑connections, performance‑based, and hash, and provides guidance on combining them for optimal architecture.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Mastering Load Balancing: Types, Algorithms, and Best Practices

1. Load Balancing Classification

1. DNS Load Balancing

The idea is that DNS resolution of the same domain name can return different IP addresses, enabling geographic load distribution (e.g., northern users to Beijing data center, southern users to Shenzhen).

Advantages:

Simple and low cost; handled directly by DNS servers without extra maintenance.

Proximity access improves response speed.

Disadvantages:

Long DNS cache TTL leads to delayed updates.

DNS control resides with the domain registrar, limiting custom extensions.

2. Hardware Load Balancing

Implemented via dedicated hardware devices such as F5 or A10.

Advantages:

Powerful features, support for multiple load‑balancing levels, various algorithms, and global load balancing.

High performance, capable of handling over one million concurrent connections.

High stability.

Additional security functions like firewall and DDoS protection.

Disadvantages:

Expensive, costing tens of thousands to hundreds of thousands.

Limited scalability.

3. Software Load Balancing

Implemented with software such as Nginx (layer‑7) and LVS (layer‑4).

Compared with hardware, performance is lower (Nginx ~50k requests/second vs. hardware million‑level) but cost is much cheaper.

Advantages:

Simple

Cheap

Flexible

Disadvantages:

Average performance

Lacks built‑in security features like firewall.

Typical Load Balancing Architecture

DNS, hardware, and software methods can be combined following basic principles:

DNS for geographic‑level load balancing.

Hardware for cluster‑level load balancing.

Software for machine‑level load balancing.

2. Load Balancing Algorithms

1. Round Robin

Requests are assigned to servers sequentially, ignoring current load or server capacity; works as long as servers are operational.

2. Weighted Round Robin

An improvement over round robin that assigns weights to servers; higher‑weight servers receive more requests.

3. Least Connections

Assigns tasks to the server with the lowest current load, e.g., LVS uses connection count, Nginx uses HTTP request count.

4. Performance‑Based

Prioritizes servers with the fastest processing speed, using response time as the metric; sampling is used to reduce measurement overhead.

5. Hash

Hashes key request information (e.g., IP) so that identical hashes route to the same server, useful for session affinity.

Conclusion

Content compiled from “Learning Architecture from Scratch”.
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

network architectureOperationsload balancingAlgorithmsInfrastructure
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.