Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Load Balancer

LB is a service that distributes incoming network traffic across multiple servers to ensure no single server becomes overwhelmed, improving application availability and responsiveness.

Load balancers can operate at different layers of the OSI model, such as Layer 4 (Transport Layer) and Layer 7 (Application Layer), providing various features like SSL termination, session persistence, and health monitoring of backend servers.

Common Load Balancing Algorithms

  1. Round Robin: Distributes requests sequentially across the servers.
  2. Least Connections: Directs traffic to the server with the fewest active connections.
  3. IP Hash: Uses the client’s IP address to determine which server will handle the request.
  4. Weighted Round Robin: Similar to Round Robin but allows assigning weights to servers based on their capacity.
  5. Random: Distributes requests randomly across the servers.
  6. Metric-Based: Uses specific metrics (like response time or server load) to make load balancing decisions.

Why you need to know this?

Backend services must have a load balancer in front of them. This is a good pattern, because it allow us to better use infrastructure resources and improve availability of our services. Usually the default if you are using AWS is to have a Application Load Balancer in front of your backend services. In case you have a lot of traffic you can also use a Network Load Balancer.