Module 95: Scaling

Lesson 2 of 5 · 15–25 minutes

Load balancing

🏠The everyday picture

A bank with several open counters and a token machine: each new customer is sent to the next free counter. No counter is overwhelmed while others are idle, and if one counter closes, customers go to the rest.

📘What it really is

🖱️Try it

Run three copies of the booking API with Compose, behind Nginx using least_conn and passive health checks (max_fails, fail_timeout). Run your k6 load test, then stop one copy during the test and watch errors (there should be few or none) and latency. Confirm the app is stateless by logging in on one copy and continuing on another.

✅Quick check

Why are sticky sessions best avoided?

Show the answer

They tie users to one server, making scaling and recovery from failures harder; stateless apps don't need them.

What does a load balancer's health check do?

Show the answer

It stops traffic going to copies that aren't healthy.

← PreviousMeasuring performance
ProLearners Assist