What is load balancing?
Useful first: HTTP · optional, not a requirement
Choose your depth
Stay with the essentials, or look closer.
YOUR GOALUnderstand why one service can use several servers.
Share incoming work
One service, several places to work
Imagine a help desk with two assistants. A coordinator sends each new question to one of them instead of making everyone wait for the same person. A load balancer plays a similar routing role for a group of servers.
For example, a website could run the same application on servers A and B. A load balancer chooses where to send an incoming request. The selected server does the application work; the balancer does not need to send that request to every server.
[1]Equal turns can mean unequal work
In a simplified round-robin example, ordinary page requests take turns: A, B, A, B. Assume both servers are available, have equal weights, and no rule keeps a visitor on one server.
One request might be quick while another takes much longer. Sharing the number of requests therefore does not guarantee equal effort or instant responses. The help-desk analogy explains distribution, not a promise about speed.
[2]A load balancer shares incoming work across a server group.
A load balancer makes every server equally busy.
The routing policy distributes work using particular signals. Equal request counts can still produce unequal workloads.
Show the explanation
Which server should handle the request. Load balancing selects a destination for work. It does not by itself replicate application data or guarantee response speed.
YOUR GOALCompare routing policies and recognize the limits of health checks.
Choose a server and check its health
Round robin and weights
Round robin shares requests by taking turns. NGINX supports weights that adjust the relative shares. In a simplified stable pool with weights 3 for A and 1 for B, A is intended to receive roughly three requests for each one sent to B.
These are configured shares, not a measurement proving A is three times faster. Failures and session-persistence rules can change the observed distribution.
[2] [3]Least connections measures connections
NGINX also offers least connections, choosing with active connection counts and server weights. With equal weights, two active connections on A and none on B can favor B for the next request.
This can help when connections last different amounts of time. It does not directly measure CPU usage or how expensive the next operation will be.
[3]Health checks are evidence with limits
Active checks send periodic probes. AWS Application Load Balancer, for example, checks a configured path and uses response criteria and failure thresholds. Passive checks instead learn from real traffic failures; NGINX can temporarily avoid a server after configured unsuccessful attempts.
A hypothetical /health response can succeed while a different operation fails. Detection also takes time. Do not assume every product always excludes every unhealthy server: AWS ALB routes to its unhealthy targets if all registered targets in the group are unhealthy.
Match the routing signal and health check to the work you need to serve.
Passing a health check proves every feature of the application works.
It proves only that the configured check passed. Other operations can fail, and routing behavior depends on the product and settings.
Show the explanation
The health check may not exercise the failing search operation. A probe tests its configured operation and success criteria. Passing one endpoint is not proof that a different endpoint works.
YOUR GOALSeparate routing choices from session storage and safe retry behavior.
Connections, state, and recovery
A request is not always the balancing unit
Check what the balancer selects. NGINX HTTP upstreams distribute requests; its stream upstreams distribute connections. These are different scopes.
For a concrete application example, AWS ALB keeps an established WebSocket connection with its selected target. Each later message is not a fresh opportunity to choose another server. A failed connection needs application recovery; routing alone does not move its conversation history.
[2] [5] [6]Affinity is not a copy of session data
Session affinity, or sticky sessions, tries to keep a client with one server. AWS ALB can use a cookie to remember that choice, but may select another target if the previous one becomes unhealthy or is removed.
Suppose a basket exists only in A's memory. Sending the next request to B does not give B that basket. An application could instead store the basket where both servers can retrieve it; that shared storage then has its own availability requirements. The routing cookie alone does not provide that storage.
[5] [8]A missing response does not prove nothing happened
Imagine A accepts an order but its response is lost. Repeating the order at B could create a second order. Finding another server is therefore different from deciding that a retry is safe.
HTTP calls an operation idempotent when repeating it has the same intended server effect as doing it once. RFC 9110 prohibits proxies from automatically retrying non-idempotent requests. Applications need recovery rules that account for whether the original operation may already have happened.
[7]Design connection recovery, session storage and retry safety separately from server selection.
Sticky sessions preserve my in-memory data when a server fails.
Affinity controls routing. A different server does not automatically receive the failed server's local application state.
Show the explanation
Routing to B alone does not restore the basket; the application needs a way to recover its state. Choosing another destination does not copy A's memory. The application must define where state lives and how it survives a server failure.
Keep asking. Check the details.
Source-checked using AI (OpenAI Codex) on . The checks covered sources, examples, and quizzes for this article version.
No human review is claimed. AI review can miss errors; check the original sources below.
- AWS — What is Elastic Load Balancing?
- NGINX — HTTP load-balancing methods and session persistence
- NGINX — HTTP upstream weights, least_conn and failure accounting
- AWS — Application Load Balancer health checks and fail-open behavior
- AWS — Application Load Balancer sticky sessions and connection behavior
- NGINX — Stream upstream connection balancing
- RFC 9110 — HTTP idempotency and automatic retries, section 9.2.2
- AWS Well-Architected — Stateless systems and offloading session data