Montu Mia's System Design
Load Balancer

Load Balancer: One Tool, a Hundred Jobs

A load balancer is more than a traffic cop, auto-scaling, health checks, zero-downtime deploys, and security.

Montu was ready to set up his load balancer. But something nagged at him: "I'm spending all this money on this thing. Is it only ever going to play traffic cop? Or has it got more up its sleeve?"

A little digging, and Montu found that a load balancer is basically a Swiss Army knife. Its list of tricks never ends. He noted down all its magical powers:

More traffic? More servers (Auto Scaling) 📈

Montu thought: "BiralTube's superstar, Mr. Treat, has a birthday coming up. What happens if he announces a midnight livestream?" Every cat lover on the planet would pile in at once. Montu's 10 servers would crash in a heartbeat.

This is where the load balancer's magic kicks in. Montu can tell it: "Listen, the moment server load (CPU usage) crosses 80%, spin up 10 more servers right away." And once the stream ends and the load drops, it shuts the extra servers back down. The whole thing happens automatically. No waking up at 3 a.m. to flip servers on and off.

Sending sick servers home (Health Check) 🏥

Machines get sick too, just like people, right? If 1 of the 10 servers suddenly hangs or dies, and the load balancer keeps routing users there, those users just stare at 'Loading...' or 'Error'.

But the load balancer is pretty clever. Every few seconds, it calls out to the servers (this is a Health Check, or Ping). — "Yo, number 1, you good?" — Server 1: "All good, boss (200 OK)." If a server doesn't answer, the load balancer knows it's sick and stops sending users there until it recovers. This is called Fault Tolerance.

Health Check

Repainting the shop without closing it (Zero Downtime Deployment) 🛠️

Montu wanted to ship a new feature. The catch: uploading new code usually means taking the server offline for a bit. Users can't get in during that window. That's lost business!

With a load balancer, this isn't a problem. Montu pushes the update to just 1 server first, then tells the load balancer, "send only 1% of users to this new server." If everything looks fine, no errors, the rest of the servers get updated one by one. The site never goes down for a single second. Users have no idea the app just updated under their feet!

The bouncer at the door (Security) 🛡️

As BiralTube blows up, a few bad actors (hackers) will inevitably try to take it down. They might fire thousands of fake requests, or 'junk traffic,' to jam up the servers. Here the load balancer acts like the bouncer at the gate. If it spots thousands of suspicious requests pouring in from one IP address, it stops them right at the door. The main servers inside stay safe and sound.

Security

Easing the encryption load (SSL Termination) 🔐

(This one's a little advanced, we'll dig into it later. For now, the simple version.)

When you see HTTPS in your browser, it means your data is being sent locked up tight (encrypted). When it reaches the server, that lock has to be opened. All that locking and unlocking (decryption/encryption) burns a lot of CPU power. Montu realized his servers were already busy loading videos, so why make them handle all the locking and unlocking too? So he handed that job to the load balancer. It opens the lock, checks the request, then passes a fresh one along to the servers. That takes a huge weight off the servers.

Montu closed his notebook with a satisfied grin. A load balancer isn't some plain old traffic cop, it's a downright superhero! No more waiting around, time to configure!

On this page