One request
An application asks a server to do something. The server runs the work and returns a response. Here the request asks for a user profile.
A request is the ask. A response is the result. The server does work between them.
- 0s Meet the application and server.
- 5s The application sends a request.
- 10s The server processes the request.
- 19s The server sends a response.
- 25s The application receives the result.
Check your understanding
What is the server doing while the application waits?
It is processing the request. The response travels back only after that work finishes.
Share the work
A server has finite capacity. A second server can run the same service, so separate requests can be handled at the same time. This simplified example gives each server one work slot.
More servers can provide more capacity when requests can be handled independently. Someone still needs to choose a server.
- 0s Two servers can run the same service.
- 6s The first request starts on server A.
- 12s A second request starts on server B while A works.
- 24s Both finish independently.
- 29s Separate requests use separate capacity.
Check your understanding
Does adding a second server make one request run twice as fast?
No. Here it lets two separate requests run at once. Each request still takes its own processing time.
Take turns
A load balancer receives a request and selects a server. Round robin is a selection rule: take turns between eligible servers. Here both servers have the same configured weight.
Round robin rotates through servers: A, B, A, B. A request goes to one selected server.
- 0s Introduce the load balancer.
- 5s Request 1 routes to A.
- 13s Request 2 routes to B.
- 21s Request 3 routes to A.
- 29s The rule repeats A, B, A, B.
Check your understanding
After A, B, A, which server gets the next request?
B, provided both servers remain eligible and equally weighted.
Unequal work
Taking turns balances the number of assigned requests, but requests can take different amounts of work. Watch a slow report on A and a short lookup on B. This example allows one running request per server.
Equal request counts do not imply equal remaining work. Round robin can choose a busy server even while another is idle.
- 0s Some requests take longer.
- 4s A receives a slow request.
- 10s B receives a quick request.
- 18s B is ready while A remains busy.
- 22s Round robin selects A and request 3 waits.
- 31s A finishes and the waiting request starts.
Check your understanding
Why does request 3 wait even though B is ready?
The round-robin rule selects A next. In this one-slot example A is still working, so the new request waits there.
Look at active work
Another rule is least requests: choose a server with fewer requests still in progress. We start with the same imbalance as before: A has one long-running request and B has none. Counts are useful signals, not perfect measurements of cost.
Least requests uses current active-request counts when choosing where new work goes. It does not move existing work.
- 0s A has one active request; B has none.
- 8s Compare current active counts.
- 14s The new request goes to B.
- 23s B finishes while A continues.
- 29s Selection changes new assignments only.
Check your understanding
Does choosing B move the long-running request away from A?
No. A keeps its existing request. Only the new request goes to B.
Avoid a failed server
A selection rule also needs to know which servers are eligible. In this example a periodic health probe gets no successful response from A. After its configured timeout, the balancer marks A unavailable and sends new requests to B.
Health checks can remove a failed server from new routing decisions after detection. They do not instantly detect every failure or rescue requests already sent.
- 0s A stops responding.
- 6s The balancer sends a health probe.
- 13s The probe times out.
- 18s A is excluded from new selection.
- 23s A new request routes to B.
- 31s B returns its response through the balancer.
Check your understanding
If A fails just after a successful check, is the failure detected immediately?
No. Detection depends on the next checks, their timeouts, and configured thresholds. A request already sent can still fail.