Intermediate

Load Balancing Fundamentals

Stand up HAProxy locally in front of three backend containers, compare load balancing algorithms directly, and kill a backend mid-traffic to watch health checks and failover happen in real time.

~2.5h
0 / 7 steps
🚀
Intro

Why you need something standing in front of your servers

Prerequisites: TCP/IP Fundamentals; HTTP/HTTPS Internals; Docker installed.

A single server has a hard ceiling: one machine's CPU, memory, and network capacity, and a single point of failure if it goes down. A load balancer sits in front of multiple backend servers and distributes incoming requests across them — which immediately buys you two different things at once: horizontal scaling (more backends handle more total traffic) and availability (if one backend dies, the load balancer routes around it instead of every request failing).

Load balancers operate at one of two layers, and which one matters a lot for what decisions they can make. Layer 4 (transport layer) load balancing routes based on IP and port alone — fast, protocol-agnostic, but blind to anything inside the request. Layer 7 (application layer) load balancing can inspect the actual HTTP request — path, headers, cookies — and route based on content, at the cost of more processing per request. This project uses HAProxy, which supports both modes, configured as an L7 HTTP load balancer for the hands-on steps.

🔨

Load balancing algorithms, conceptually

🔨

Stand up HAProxy with three backends

🔨

Health checks and watching failover happen live

🔨

Sticky sessions: a tradeoff, not a free feature

🎯
Secret Mission

Secret Mission: weighted distribution and a failover-time measurement

🧹
Wrap Up

Before You Go

Pro

Test what you just learned

Self-testing is one of the best ways to retain new skills. Unlock project quizzes to check your understanding.

Log in to unlock