#sharding #consistent-hashing #load-balancing #constant-time

power-consistent-hash

Power consistent hash - constant expected time constant memory consistent hash

1 unstable release

0.1.0 Aug 11, 2023

#1981 in Algorithms

Download history 4/week @ 2024-09-18 5/week @ 2024-09-25 5/week @ 2024-10-02 32/week @ 2024-10-09 54/week @ 2024-10-16 22/week @ 2024-10-23

109 downloads per month

Apache-2.0

16KB
255 lines

Constant time consistent hash

This repo contains implementation of power consistent hash - constant expected time and constant memory consistent hashing. Minimal number of keys are remapped when the number of buckets changes.

Target use cases - load balancing and data sharding.

The hashing algorithm execution time doesn't depend on number of hashing time.

Benchmark - hashing 1k 64 bit key batches

2.6GHz Intel Core i7 hashes 1k 64 bit keys in ~6.4 microseconds. The left axis is a number of consistent hash buckets:

Benchmark of hashing 1k keys

With optional integration of SeaHash to produce 64 bit key fingerprints hashing of 1k UUIDs takes around ~25 microseconds.

Dependencies

~0.6–1.2MB
~24K SLoC