libi / dcron

轻量分布式定时任务库 a lightweight distributed job scheduler library
MIT License
422 stars 73 forks source link

关于负载均衡 #15

Closed colinrs closed 2 years ago

colinrs commented 2 years ago

我想问下: 文档中提到 "负载均衡:根据任务数据和节点数据均衡分发任务。",

  1. 负载均衡是使用一致性Hash做到的么?
  2. 根据任务数据和节点数据,这是怎么做到的?,在代码中我并没有看到
libi commented 2 years ago

1.是用的一致性Hash。 2.通过redis保存所有节点信息,用一致性hash根据任务名确定执行节点。代码参考 https://github.com/libi/dcron/blob/f7fa3cc1142ff6fa4a1173e2f59205ada64b5b2c/node_pool.go#L90

colinrs commented 2 years ago

1.是用的一致性Hash。 2.通过redis保存所有节点信息,用一致性hash根据任务名确定执行节点。代码参考

https://github.com/libi/dcron/blob/f7fa3cc1142ff6fa4a1173e2f59205ada64b5b2c/node_pool.go#L90

这段代码我理解只是根据节点数量根据一致性hash来做负载均衡。并没有涉及涉及到任务数据

libi commented 2 years ago

任务数据在每个节点都全量存在,可以参考下readme的流程图理解下。

colinrs commented 2 years ago

好的,多谢