What’s: Load Balancer

A load balancer (LB) is an essential component in any distributed system. It ensures that incoming traffic is evenly distributed across multiple resources based on a chosen metric, such as round-robin, random selection, or resource-specific weighting like CPU or memory usage. Additionally, the LB monitors the health of resources while distributing requests. If a server becomes unavailable, stops responding, or exhibits a high error rate, the LB automatically stops routing traffic to that server.

To achieve maximum scalability and redundancy, load balancing can be implemented at multiple layers within a system. Load balancers can be strategically placed in the following locations:

  • Between users and the web servers
  • Between web servers and the internal platform layer, such as application servers or caching servers
  • Between the internal platform layer and the database

Smart Clients

A smart client manages a pool of service hosts, balancing the load among them while also handling host failures. It avoids routing requests to unresponsive hosts and reintroduces recovered ones back into the pool. Additionally, it manages dynamic changes, such as adding new hosts.

Incorporating load-balancing functionality directly into the database, cache, or service client can be an appealing option for developers, particularly in smaller systems. It is relatively simple to implement and maintain at this stage. However, as the system grows in complexity and scale, the need often arises to transition to dedicated load-balancing servers for better management and performance.

Hardware Load Balancers

A dedicated hardware load balancer, offers a high-performance solution to load balancing. These devices can address a broad range of challenges but come with significant costs and require intricate configurations.

Even large enterprises with substantial budgets tend to limit the use of hardware load balancers due to their expense. Typically, such devices are used as the initial point of contact for user traffic. Other methods, such as smart clients or software-based load balancers, are utilized for internal traffic management within their networks.

Software Load Balancers

For those seeking a middle ground between building a smart client and investing in costly hardware, software load balancers provide an effective solution.

It can be deployed between clients and servers or between different layers of a server-side system. If the client machine is under your control, the LB can run locally, binding specific ports that the client uses to connect to backend services. Requests made to these ports are intercepted by the LB, which efficiently routes them to the appropriate backend server.

For scenarios where client machines cannot be managed, the LB can operate on an intermediary server, or it can mediate traffic between various server-side components. It ensures efficient load distribution, performs health checks, and dynamically manages the pool of servers by adding or removing nodes as needed.

For most systems, starting with a software load balancer is a practical approach. As the system evolves, transitioning to smart clients or hardware load balancers can be considered when necessary.

Other System Design Resource Pages:

Browse all articles