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

power-consistent-hash

Power consistent hash - 预期时间恒定、内存恒定的哈希

1 个不稳定版本

0.1.0 2023年8月11日

#1920 in 算法

Apache-2.0

16KB
255

恒时一致哈希

此仓库包含power consistent hash的实现 - 预期时间恒定和内存恒定的一致哈希。当桶的数量变化时,重新映射的键的数量最小。

目标用例 - 负载均衡和数据分片。

哈希算法的执行时间不依赖于哈希时间。

基准 - 哈希 1k 64 位键批次

2.6GHz Intel Core i7 在 ~6.4 微秒内哈希 1k 64 位键。左侧轴是一致哈希桶的数量

Benchmark of hashing 1k keys

可选集成SeaHash,生成 1k UUIDs 的 64 位键指纹哈希大约需要 ~25 微秒。

依赖项

~0.6–1.2MB
~24K SLoC