...

/

Client-side Load Balancers (clone)

Client-side Load Balancers (clone)

Let's understand how Twitter performs client-side load balancing.

Introduction

In the previous lesson, we conceived the design of Twitter using a centralized load balancer. All end-users requests go through the centralized load balancing infrastructure into different services. Although this method works, and we employed it in other designs, it may not be the optimal choice for Twitter. It is because Twitter offers a variety of services at a large scale and centralized load-balancers are more suited for monolithic applications. To understand the concept better, let’s understand the history of Twitter design.

The design history of Twitter

The initial design of Twitter included a monolithic (Ruby on Rails) application with a MySQL database. As Twitter scaled, the number of services increased and the MySQL database was sharded. With a monolithic application, such a design is a disaster because of the following reasons:

  • A large number of developers work on the same codebase which makes it complex to update individual services
  • The upgrade process of one service may lead to the breaking of another
  • Hardware costs grow because a single machine performs numerous services
  • Recovery from failures is both time-consuming and complex

With the way Twitter evolved, the only way out was many microservices where each service can be served through hundreds or thousands of instances.

Client-side load balancing

In a client-side load balancing technique, there is no dedicated intermediate load balancing infrastructure between any two services with a large number of instances. A node requesting a set of nodes for a service has a built-in load balancer. We refer to the requesting node/service as a client. The client can use a variety of techniques to select a suitable instance for requesting the service. The illustration below depicts the concept of client-side load balancing. Every new arriving service/instance will register itself with a service registry so that other services are aware of its existence

Client-side load balancing
Client-side load balancing

In the diagram above, Service A has to choose a relatively less-burdened instance of Service B. Therefore, it will make use of the load balancer component inside it to choose the most suitable instance of Service B. Using the same client-side load balancing method, Service B ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy