Loader Balancer

[ ]

Load balancers distribute incoming client requests to computing resources and returns the response from the computing resource to the appropriate client. Load balancers are effective at:

  • Preventing requests from going to unhealthy servers
  • Preventing overloading resources
  • Helping eliminate single points of failure
  • SSL termination - Decrypt incoming requests and encrypt server responses so backend servers do not have to perform these potentially expensive operations
  • Session persistence - Issue cookies and route a specific client’s requests to same instance if the web apps do not keep track of sessions

Load balancers can be implemented with hardware (expensive) or with software such as HAProxy.

To protect against failures, it’s common to set up multiple load balancers, either in active-passive or active-active mode.

How to Route Traffic

Load balancers can route traffic based on various metrics, including:

  • Random
  • Least loaded
  • Session/cookies
  • Round robin or weighted round robin
  • Layer 4: Layer 4 load balancers look at info at the transport layer to decide how to distribute requests. Generally, this involves the source, destination IP addresses, and ports in the header, but not the contents of the packet. Layer 4 load balancers forward network packets to and from the upstream server, performing Network Address Translation (NAT).
  • Layer 7: Layer 7 load balancers look at the application layer to decide how to distribute requests. This can involve contents of the header, message, and cookies.

Disadvantage of Loader Balancer

  • The load balancer can become a performance bottleneck if it does not have enough resources or if it is not configured properly.
  • Introducing a load balancer to help eliminate single points of failure results in increased complexity.
  • A single load balancer is a single point of failure, configuring multiple load balancers further increases complexity.

Examples of Load Balancer

Example of Nginx

Written on March 30, 2019