Mastering High‑Availability Load Balancing: LVS, Nginx, F5 and Beyond
This article examines common website architecture layers, compares hardware (F5) and software (LVS, Nginx) load‑balancing solutions, discusses high‑availability setups with Keepalived/Heartbeat, evaluates their network dependencies, and offers practical recommendations for choosing and monitoring load‑balancers, file servers, and databases in high‑traffic environments.
1. Typical Website Architecture
Websites are usually divided into a load‑balancing layer, a web layer, and a database layer. Many also add a file‑server layer because growing traffic increases file‑server load. The front‑most load balancer, often called the Director, typically uses round‑robin distribution.
2. Hardware vs. Software Load Balancers
F5 provides hardware load balancing, commonly used in CDN systems and squid reverse‑proxy clusters, and excels in scenarios requiring high connection‑creation rates. LVS and Nginx achieve load balancing via software and also demonstrate strong stability under high concurrency.
3. Network Dependency
Nginx has minimal network dependency; as long as the server can ping and serve pages, Nginx works and can differentiate internal and external networks. LVS relies more heavily on the network environment and performs best when servers share the same subnet and use direct mode for traffic splitting.
4. Mature High‑Availability Solutions
Common HA load‑balancing setups include LVS + Keepalived and Nginx + Keepalived. Although Nginx historically lacked a mature dual‑node backup, HA can be achieved with shell‑script monitoring or DNS round‑robin techniques.
5. Meaning of “Cluster”
In this context, a cluster refers to the web or Tomcat servers behind the load balancer, but the term has broadened to encompass the entire system architecture, including the load balancer and backend application servers. Some people loosely call any Linux cluster an LVS cluster, which should be distinguished.
6. Definition of HA in Load Balancing
HA means that when one load balancer fails, another takes over in less than one second. The most common software for this purpose are Keepalived and Heartbeat. Production‑grade solutions typically use LVS + Keepalived or Nginx + Keepalived.
7. Advantages and Drawbacks of LVS
LVS offers strong load capacity, stable operation (thanks to mature HA), no traffic overhead, and broad application support, which has earned it many fans. However, its heavy reliance on network conditions makes it less suitable for complex network environments, where Nginx may be preferred.
8. Advantages of Nginx
Nginx’s low network dependency, powerful and flexible regular‑expression engine, and simple configuration make it attractive, especially for small‑ to medium‑size projects. When budget permits, F5 remains the top choice.
9. Combining Load‑Balancing Technologies
Large‑scale sites often combine F5, LVS, and Nginx, selecting two or three of them. If F5 is unaffordable, the front‑end should point to LVS (i.e., DNS directs traffic to the LVS balancer). Critical IP addresses—such as database or web‑service IPs—should be hosted by LVS for reliability.
10. Virtual IP (VIP) Usage
Keepalived provides a virtual IP (VIP) that is publicly reachable and used as the DNS target. Designing the architecture therefore requires requesting an additional external IP from the IDC.
11. HTTPS Support
Both LVS and Nginx handle HTTPS well, with LVS often being simpler to configure.
12. Fault Handling
In failure scenarios, LVS + Keepalived or Nginx + Keepalived can quickly switch DNS to a real web server, ensuring short‑term continuity. For high‑traffic ad or e‑commerce sites, deploying a CDN is strongly recommended.
13. No Magic in Linux Clusters
Linux clusters are not mythical; the choice should depend on the application scenario. Nginx, LVS, and F5 are tools—select the one that best fits the requirements.
14. Session Sharing
Nginx can use the ip_hash method to share sessions; F5 and LVS provide session‑persistence mechanisms. Storing sessions in a database is also possible but adds load to the database.
15. Real‑World Traffic Numbers and Solutions
Typical concurrent users: 1000 for an e‑commerce site, 100 for a securities news site, 3000 for a large ad platform. Web‑layer concurrency is manageable with strong servers and Nginx, but file‑server and database layers become bottlenecks. Solutions include MooseFS, DRDB + Heartbeat + NFS, MySQL master‑slave, or Oracle RAC for extreme load.
16. Apache vs. Nginx
Both Apache and Nginx perform well; a common recommendation is to use Nginx as the front‑end load balancer and Apache as the back‑end web server.
17. Heartbeat and DRDB
Heartbeat’s split‑brain issue is less severe than expected; DRDB + Heartbeat is a mature, cost‑effective alternative to EMC shared storage.
18. Monitoring Recommendations
Deploy Nagios (or similar) to monitor server health in real time, with email and SMS alerts. Commercial website‑scanning services can also periodically check site availability and trigger warnings.
19. Security Measures
Use hardware firewalls (e.g., 华赛 three‑layer firewall + 天泰 web firewall) for DDoS protection. Linux iptables and SELinux can be disabled, and open ports should be minimized.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
