45

负载均衡策略之两次随机选择策略

 5 years ago
source link: https://mozillazg.com/2019/03/load-balancing-strategy-algorithm-the-power-of-two-random-choices.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

两次随机选择(Two Random Choices)

两次随机选择策略出自论文 《The Power of Two Random Choices: A Survey of Techniques and Results》 ,主要思想是:

  1. 从可用节点列表中做两次随机选择操作,得到节点 A、B
  2. 比较 A、B 两个节点,选出负载最低(一般是正在处理的连接数/请求数最少)的节点作为被选中的节点

至于简单实现这里就不贴出来了,可以参考下面的伪代码以及前面的 负载均衡策略之随机选择负载均衡策略之最少连接 结合这两个就可以了:

A = random_choice(nodes)
B = random_choice(nodes)
best = least_connection_choice([A, B])

本文简单介绍了一下两次随机选择这个负载均衡策略。 关于两次随机选择策略的更详细信息可以参考参考资料中列出来的资源。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK