Skip to content

如何创建多个基于leastLoad的负载均衡?leastLoad的settings该填什么? #3735

Answered by vrnobody
Benjamin1919 asked this question in Q&A
Discussion options

You must be logged in to vote

简单来说 leastLoad 会挑选 延迟加权(costs)均方差(Deviation) 最小的节点。比如节点A的延迟结果为 100ms 200ms 150ms,而节点B的延迟结果为 300ms 300ms 300ms,那么会挑选节点B。看起来有点反直觉,实际上B这种情况很少出现。

settings 里面的各项参数用于调整挑选规则。
tolerance 目前没用上,直接跳过。
maxRTT 是最大延迟,这个比较容易理解,不详说。
expected 是按均方差升序排序后,保留前面多少个节点,然后从这几个节点里面随机抽取一个。
baselines 是最大均方差。

costs 用于根据节点的 tag 调整均方差数值。计算公式 均方差 * √(value)

message StrategyWeight {
  bool regexp = 1;
  string match = 2;
  float value =3;
}

比如有个节点很稳,但要收双倍钱,那么可以乘个 小数 倍数 value,降低选中概率。还有个隐藏用法是把 value 设置为零,然后在节点 tag 中添加数字系数。

所以这个均方差是什么鬼?其实就是 BurstObservatory 测出来的 deviation。 具体数值可以启用 Metrics 功能,然后在 http://127.0.0.1:11111/debug/vars 里面看每个节点的 health_ping。

总而言之,不用设置直接留空就好。

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by yuhan6665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants