Erlang implementation of the consistent hashing algorithm used in the load balancing MagLev system.
MagLev [1] is a network load balancing system developed at Google and published in 2016.
As part of the system a consistent hashing algorithm is proposed and that is what this library contains, an implementation of the consistent hashing algorithm part of the MagLev system.
It aims to be lightning fast and always accurate due to the use of a deterministic algorithm at the spend of needing more computational power when there is a change in the list of possible outputs as it needs to recalculate the internal hashing table.
- Create your maglev table with the list of possible outputs:
MaglevTable = nmaglev:create([a,b,c,d]).
- Use the get function to retrieve the output for your input:
Output = nmaglev:get(<<"some bin">>, MaglevTable).
By default the lookup table size is 65537 as it should be enough for a normal scenario. You can choose your own size using the nmaglev:create/2
function but please be aware that the size has to be a prime number.