flâneur

What Is Consistent Hashing? - by NK

newsletter.systemdesign.one · 819 words · saved by 1 readers

A simple solution is to replicate the cache server. Yet only a limited amount of data set can be cached. So cache server must be partitioned to store more data. But partitioning the cache to handle dynamic load is a difficult problem. A naive approach is Static Hash Partitioning. Here’s how it works: Hash the data key Do a modulo operation of the generated hash code against the number of cache servers. This finds you the cache server ID Store data key in the cache server But existing mapping between data keys and cache servers will break if a cache server fails. Also installing an extra cache server to handle more load will break the mapping. A workaround is to rehash the data keys. But it’s an expensive operation. So static hash partitioning won’t handle a dynamic load without service degradation. A simple solution to this problem is consistent hashing. Want to become a better software engineer? Each week, Milan sends one piece of practical advice about .NET and software architecture.

Get my system design playbook for FREE on newsletter signup: Share this post & I'll send you some rewards for the referrals. Imagine you own a website and it became popular. So you install a cache to reduce the load on the origin server. But soon the cache server will hit its limits and result in cache misses. A simple solution is to replicate the cache server. Yet only a limited amount of data set can be cached. So cache server must be partitioned to store more data. Data Replication vs Partitioning But partitioning the cache to handle dynamic load is a difficult problem. A naive…

related reading