Round-robin and weighted distribution
Round-robin cycles through backend servers in order: request 1 to server A, request 2 to server B, request 3 to server C, request 4 to server A again. Simple and fair if all servers have equal capacity. Weighted round-robin lets you assign higher weights to faster servers: if server A has weight 2 and B has weight 1, A gets twice as many requests. This handles heterogeneous hardware without adding complexity.
Least-connections and state awareness
Least-connections routes each new request to the server currently handling the fewest connections. This adapts to slow clients: a server stuck with a slow upload is avoided by new requests until that client finishes. Weighted least-connections divides by capacity: a faster server can hold more concurrent connections. For stateful services (long-lived WebSocket connections), these algorithms ensure relative balance, though sticky sessions (pinning clients to a server) are often necessary.
Hash-based routing for consistency
Hash-based algorithms (source IP, session cookie, request path) send the same client or request type to the same server always. A user's requests land on server A every time, enabling local caching of session state. This helps with stateful services but can lead to hot spots: if many users hash to the same server, load becomes unbalanced. Consistent hashing (minimizing remapping when servers are added or removed) mitigates this.