1. Distribution algorithm
Round-robin cycles through servers in order; least-connections sends each request to the node with the fewest active connections.
algorithm: round-robin-or-least-connTyporithm · medium
Step 1 of 8 · intro card
Scaling
A load balancer spreads traffic across servers using round-robin, least-connections, or hashing. L4 balancers work at the transport layer while L7 ones are application-aware. Health checks remove failing nodes, sticky sessions pin a user to one backend, and the balancer itself must be redundant.
A load balancer sits in front of a pool of servers and distributes incoming requests so no single node is overwhelmed. Common algorithms are round-robin (cycle through servers), least-connections (favor the least-busy node), and hashing (route by a key like client IP).
Balancers operate at different layers. An L4 (transport) balancer routes on TCP/UDP and IP:port without inspecting the payload, so it is fast but blind to content. An L7 (application) balancer reads HTTP, letting it route by path, header, or cookie at the cost of more work per request.
Health checks probe each backend and remove unhealthy ones from rotation. Sticky sessions (session affinity) keep a user on one server when state is not shared. Because the balancer is itself a single point of failure, it is deployed in an active-passive or active-active pair.
Algorithms: round-robin, least-connections, hashing.
L4 routes on TCP/IP; L7 is HTTP-aware (paths, headers).
Health checks evict unhealthy nodes from the pool.
load_balancer:
algorithm: round-robin-or-least-conn
layer: l4-tcp-or-l7-http
health_check: remove-unhealthy
sticky: session-affinity
redundancy: active-passiveConnect each part of the code to the concept before you type.
Round-robin cycles through servers in order; least-connections sends each request to the node with the fewest active connections.
algorithm: round-robin-or-least-connAn L4 balancer routes on TCP/UDP without reading the payload; an L7 balancer is application-aware and can route on HTTP paths and headers.
layer: l4-tcp-or-l7-httpPeriodic probes detect failing nodes and pull them out of rotation so traffic only goes to healthy servers.
health_check: remove-unhealthySession affinity pins a given user to the same backend, which matters when server-side session state is not shared.
sticky: session-affinityThe balancer is itself a single point of failure, so it runs in an active-passive (or active-active) pair to avoid an outage.
redundancy: active-passiveRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.