Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save EliFuzz/2c3cf0f21e2fed740bc0e6d4535e7cbd to your computer and use it in GitHub Desktop.
Save EliFuzz/2c3cf0f21e2fed740bc0e6d4535e7cbd to your computer and use it in GitHub Desktop.
Overview Table: Load Balancer Algorithms
Algorithm Description Type Pros Cons Use Cases
DNS Based Load Balancing Technique that uses DNS queries to distribute incoming requests across multiple nodes, returning the IP address of the nearest node to the client Static/Dynamic No need for a centralized load balancer, can be easily implemented using existing DNS infrastructure Limited control over load distribution, may not work well with applications that require session persistence Location-based routing is sufficient, such as content delivery networks or geographically distributed services
Equal Cost Multi Path (ECMP) Load balancing algorithm that allows for the simultaneous use of multiple network interfaces, distributing incoming requests across multiple paths, reducing the risk of a single point of failure and improving overall availability Static/Dynamic Improves availability and reduces the risk of a single point of failure, allows for easier scalability Requires multiple network interfaces, can be more expensive High availability and redundancy are critical, such as mission-critical business systems or cloud infrastructure
IP Hash Popular load balancing algorithm used in many production environments, works by hashing the client IP address and using the resulting value to determine which server to send the request to Static Provides good session persistence, can be combined with other algorithms for better load distribution Requires a stable IP address for clients, can lead to uneven load distribution if the hash function is not well designed Session persistence is important, such as web sessions or database connections
Least Bandwidth Directs incoming requests to the server currently utilizing the least amount of bandwidth, measured in megabits per second (Mbps) Dynamic Helps to ensure that servers are not overwhelmed by network traffic May not be as effective if there are large variations in server capacity or network latency Where bandwidth usage varies across nodes
Least Connection (LC) Similar to Least Requests but takes into account the number of active connections rather than requests, sending new requests to the node with the fewest active connections Dynamic Better than LR in terms of response time and throughput, works well with applications that have long-lived connections May cause starvation if there are nodes with much higher capacities than others Connections are long-lived, such as video streaming or online gaming
Least Requests (LR) Variant of the round-robin algorithm that takes into account the current workload of each node, sending new requests to the node with the fewest active requests at the time Dynamic Better than RR in terms of response time and throughput, works well with applications that have varying request rates May cause starvation if there are nodes with much higher capacities than others Request rates vary across nodes
Least Time Monitors both the number of concurrent connections and the average response time from each node in the load-balanced pool Dynamic Better than RR in terms of response time and throughput, works well with applications that have varying request rates May cause starvation if there are nodes with much higher capacities than others Request rates vary across nodes
Random Randomly distributes requests to servers using a random number generator Static Easy to implement, starvation-free Does not take into account node capacity or latency, can lead to poor performance if there are large variations in node capacity or network latency Node capacity and network latency are relatively consistent
Round-Robin (RR) Simple and widely used load balancing algorithm that distributes incoming requests evenly across all available nodes in the cluster Static Easy to implement, starvation-free Does not take into account node capacity or latency, can lead to poor performance if there are large variations in node capacity or network latency Node capacity and network latency are relatively consistent
Token Aware (TA) Sophisticated load balancing algorithm that takes into account both the number of active connections and the server's capacity, assigning a weight to each node based on its capacity and using a token-based scheme to distribute incoming requests Static/Dynamic Takes into account node capacity and connection count, can handle large variations in node capacity and network latency More complex to implement Node capacity and connection count are critical factors, such as real-time analytics or financial trading platforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment