Overview of Round Robin algorithm


Round Robin is commonly known as Hash Modulus Method, which is a very common data slicing method in practice. Assuming there are k physical machines, data fragmentation can be realized through the following hash functions:
H(key)=hash(key)mod K
Number the physical machines from 0 to K-1. According to the above hash function, for a record with key as the primary key, the value of H(key) is the number of the physical machine that stores the data. In this way, all the data is distributed to k physical machines. When searching for a record, the same hash function can be used to find the physical machine that stores the corresponding information.
The advantage of Round Robin is that it is very simple to implement, but lacks flexibility. For example, if a physical machine is added to the distributed storage system, the hash function becomes:
In this way, the mapping relationship between all the previously allocated data and the physical machine storing the data is completely disrupted, so all the data can only be redistributed again according to the changed hash function, which obviously lacks expansion flexibility for the online storage system.
Why is Round Robin so inflexible to expand? Round Robin actually combines the two function points of physical machine and data slice into one, i.e. each physical machine corresponds to one data slice, so that the key-partition mapping and partition-machine mapping are two-in-one and are all assumed by the same hash function. The result is that the number of machines K appears in the mapping function as a parameter, resulting in close coupling between the number of machines and the mapping function. As long as the number of machines changes, the hash function will also change, which is the fundamental reason why Round Robin lacks flexibility in expansion.