Am; YourMove : What is Load Balancer and Consistent Hashing #1

link to the actual video

On 10th April 2017 a new video is released on the channel AM;YourMove.

In this video, the presenter took up an interesting topic. The topic for this tech talk is “ load balancing and consistent hashing ”. The presenter started off the video with a question. The question was how large companies like Google, Amazon or Facebook are managing to process a huge amount of requests !? To give you a perspective on how large this information is, Google search alone gets around 3.2 billion requests in a single day. Just imagine how many requests does Youtube get? (Largest video streaming platform in the world) or Facebook!

So, The presenter then explains that this is possible because the load is balanced across multiple data centers situated at multiple places. That is why we are often hearing that Facebook is installing a new data center. Let me explain what is a data center. A data center is a large group of networked servers used for remote storage, processing, or distribution of large amounts of data. Then the presenter explains why there is a need for setting up a new data center. The obvious reason is the data center is getting overloaded or if not overload, it could be the efficiency of that data center is decreased. For many reasons, a data center can only process a certain n number of requests at an instant of time.

So we know why there is a requirement for a new data center. Multiple data centers should be well in sync so that none gets overloaded. The presenter then answers that this distribution of requests across multiple data centers is done by Load Balancer. A load balancer is a software or hardware or both.

 

load-balancing-1

 

Load balancing aims to optimize resource use, maximize throughput, minimize response time, and avoid overload of any single resource. Any addition or removal of these resources should not affect the user experience. This is usually achieved with a shared database or an in-memory session database, for example, Memcached. So basically, a load balancer distributes clients uniformly across multiple servers such that none get overloaded.Further, it is desirable to find an allocation that does not change very much over time in a dynamic environment in which both clients and servers can be added or removed at any time. In other words, we need the allocation of clients to servers to be consistent over time.

But how this allocation of clients is possible? certainly, some algorithm is used, right ? The algorithm used is called consistent hashing.

But let us first understand what is hashing. Hashing is a technique to store the data. Data can be accessed faster through directly by index in the location which can be computed by a hash function.

static_hash

Hashing concept is used in some famous databases like Amazon’s dynamo. The hash function is used to index the original value or key and then used later each time the data associated with the value or key is to be retrieved. Thus, hashing is always a one-way operation. There’s no need to “reverse engineer” the hash function by analyzing the hashed values. In fact, the ideal hash function can’t be derived by such analysis. A good hash function also should not produce the same hash value from two different inputs. If it does, this is known as a collision. A hash function that offers an extremely low risk of collision may be considered acceptable.

The presenter then asks the viewers what could be the difference between hashing and consistent hashing. First, let’s understand why we need different algorithms. As the systems which we are dealing with are dynamic i.e that server or client can go offline at any point of time. So if any server goes down all the clients allocated to it should be re-allocated to other servers to provide a user-friendly experience.

Consider this, If you have a collection of n cache machines then a common way of load balancing across them is to put object o in cache machine number hash(o) mod n. This works well until you add or remove cache machines (for whatever reason), for then n changes and every object is hashed to a new location. This can be catastrophic since the originating content servers are swamped with requests from the cache machines. It’s as if the cache suddenly disappeared. It would be nice if, when a cache machine was added, it took its fair share of objects from all the other cache machines. Equally, when a cache machine was removed, it would be nice if its objects were shared among the remaining machines. This is exactly what consistent hashing does – consistently maps objects to the same cache machine, as far as is possible, at least.

Seems too technical or difficult? The presenter promises to make the concepts simple enough to be understood by a non-technical person. The presenter then informs that this is just part 1 of this video. In the next video, The actual algorithm of load balancing and how consistent hashing works will be explained. Stay tuned to the channel AM;YourMove.

If you haven’t already subscribed to the channel subscribe NOW!  It is a great channel to get the latest information related to computer science.

Subscribe here -> CLICK HERE!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s