</>CodexBash
All articles
Networking

Load balancing algorithms

The algorithms load balancers use to choose a server, with code and trade-offs: round robin, weighted round robin, random, least connections, least response time, power of two choices, IP and consistent hashing, Maglev, and how slow start, health and connection reuse affect them in practice.

CodexBash, , 6 min read

Our load balancers article explained what a load balancer does: spreading traffic over several servers and routing around failures. This one looks closely at the decision it makes for every request or connection: which server gets it? The choice of algorithm affects latency, how evenly servers are used, how gracefully the system copes with slow or failing machines, and whether caches stay warm. Each algorithm below comes with a short Python sketch and its trade-offs.

Sign in to read the rest

The whole 6 minute article is free with an account, along with every problem, lesson and tutorial. No card.