Load Balancing Algorithms (Round Robin, Least Connections)

Round Robin: Simple, Even Rotation

Request 1 -> Server A
Request 2 -> Server B
Request 3 -> Server C
Request 4 -> Server A   (cycle repeats)

Round robin simply cycles through the list of available servers in order, sending each new request to the next one in turn. It's simple to implement and works well when every server has roughly equal capacity and every request takes roughly similar effort to handle.

Least Connections: Accounting for Current Load

Round robin has a blind spot: it doesn't know if a server is currently bogged down handling a few very heavy, slow requests. Least connections instead sends each new request to whichever server currently has the fewest active connections - a better fit when requests vary significantly in how long they take to process.

Server A: 12 active connections
Server B: 4 active connections   <- new request goes here
Server C: 9 active connections

Weighted Variants: Accounting for Unequal Servers

Both algorithms have "weighted" versions, useful when servers have genuinely different capacities. A more powerful server can be assigned a higher weight, causing it to receive a proportionally larger share of traffic than a smaller, less powerful one.

Choosing the Right Algorithm

AlgorithmBest suited when
Round robinServers are equal, requests are roughly uniform in cost
Least connectionsRequest processing time varies significantly
Weighted variantsServers have meaningfully different capacities
Written by Lorens Mishra

Software Engineer Notes Management System Administrator

Discussion

0 comments
Sign in to join the discussion.

No comments yet. Be the first to say something.