考察go一致性hash库

考察go一致性hash库

(金庆的专栏 2020.2)

github 搜 consistent, 按星数依次察看

stathat/consistent

Consistent hash package for Go.

688星

stathat 应该是个数据统计的云服务。consistent被认为是生产可用的。
所有文档都在 godoc. 示例和接口简洁易懂。

lafikl/consistent

A Go library that implements Consistent Hashing and Consistent Hashing With Bounded Loads.

575 星

有界负载的一致性哈希算法

示例中是 c.GetLeast() 获取最小负载,不像是一致性hash的应用。
从代码看,应该是最近的未满载,不是最小负载。

MaxLoad()说明显示最大负载是自动设置为 (total_load/number_of_hosts)*1.25。

const replicationFactor = 10

没有一次获取多个的接口。

serialx/hashring

Consistent hashing “hashring” implementation in golang (using the same algorithm as libketama)

367 星

是从 Python 库移植的。可以设置 weight.

示例

replicaCount := 3
ring := hashring.New(serversInRing)
server, _ := ring.GetNodes("my_key", replicaCount)

实际上是 GetN 的功能。内部实现缺少 replicationFactor

buraksezer/consistent

Consistent hashing with bounded loads in Golang

263 星

未提供缺省hash函数。

多了一个PartitionCount

c.loads 仅用于查询负载,并没有用于有界负载。

结论是这个不是有界负载的一致性哈希,同时一致性哈希的实现不同寻常。

其他

jump hash 不能移除节点,不考虑

dgryski/go-jump

go-jump: Jump consistent hashing

281 星

lithammer/go-jump-consistent-hash

⚡️ Fast, minimal memory, consistent hash algorithm

138 星

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值