# Overview A load balancer is used to evenly distribute traffic across downstream components. These components can be hardware ([[Computer Server]], [[Virtual Machines]]) or software (workers in a multi-threaded architecture). Additionally, a Load Balancer may operate of Level 3/4 (Network) of the [[Open System Interconnection (OSI) Model]] or it may operate at a higher level (L7 Application). There is a tradeoff in performance vs. more advanced features (load balancing using advanced logic) between the two options. ## Products Popular Load Balancer products include: - [[AWS Elastic Load Balancer]] - [[NGINX]] - [[HAPro]] # Key Considerations ## Client-side Load Balancers A load balancing approach where the client is responsible for selecting which server to select. The client will first talk to a service registry or directory which contains a list of available servers. The client will get the list and select their server (likely whichever is fastest). This is what is used for [[Domain Name System (DNS)]] and Redis clusters. ## Types of Load Balancers ### [[Layer 4 Load Balancer]] ![[Layer 4 Load Balancer#Overview]] ### [[Layer 7 Load Balancer]] ![[Layer 7 Load Balancer#Overview]] ## Scaling There are several approaches for creating a load balancer that is capable of scaling: | Topic | Description | Pros | Cons | Use Cases | | --------------------------------------- | ------------------------------------------------- | --------------------------------------------- | --------------------------------------------- | -------------------------------------------------- | | [[Global Server Load Balancing (GSLB)]] | ![[Global Server Load Balancing (GSLB)#Overview]] | ![[Global Server Load Balancing (GSLB)#Pros]] | ![[Global Server Load Balancing (GSLB)#Cons]] | ![[Global Server Load Balancing (GSLB)#Use Cases]] | | [[Active-Passive Load Balancer]] | ![[Active-Passive Load Balancer#Overview]] | ![[Active-Passive Load Balancer#Pros]] | ![[Active-Passive Load Balancer#Cons]] | ![[Active-Passive Load Balancer#Use Cases]] | | [[Anycast Load Balancing]] | ![[Anycast Load Balancing#Overview]] | ![[Anycast Load Balancing#Pros]] | ![[Anycast Load Balancing#Cons]] | ![[Anycast Load Balancing#Use Cases]] | | [[Elastic Load Balancer]] | ![[Elastic Load Balancer#Overview]] | ![[Elastic Load Balancer#Pros]] | ![[Elastic Load Balancer#Cons]] | ![[Elastic Load Balancer#Use Cases]] | ## Load Balancing Algorithms #flashcard - Round Robin - requests are distributed sequentially across servers - Sticky Round Robin - Weighted Round Robin - Random - requests are distributed sequentially across servers - Least Connections - requests go to the server with the fewest active connections - IP Hash - client IP determines which server receives the request - [[Consistent Hashing]] - Lowest Response Time - requests go to the server with the fastest response time <!--ID: 1751507776502--> # Related Topics - [[Health Checking]]