写点什么

架构师训练营第 1 期 第 5 周作业

用户头像
李循律
关注
发布于: 2020 年 11 月 02 日
  1. 用你熟悉的编程语言实现一致性 hash 算法。

  2. 编写测试用例测试这个算法,测试 100 万 KV 数据,10 个服务器节点的情况下,计算这些 KV 数据在服务器上分布数量的标准差,以评估算法的存储负载不均衡性。


https://github.com/lixunlv/consistent_hash.git


运行结果:

use time:0.73s v_num: 1 deviation:95155.38189824052 counts:[194390, 50689, 146598, 25754, 120231, 326752, 59594, 23228, 52160, 604]
use time:0.9s v_num: 30 deviation:10651.757958196384 counts:[105139, 113283, 100949, 89307, 81239, 100803, 111259, 84379, 106992, 106650]
use time:0.94s v_num: 60 deviation:11186.56113378906 counts:[105157, 109523, 85842, 87468, 116587, 109334, 80090, 103953, 101362, 100684]
use time:0.96s v_num: 90 deviation:8264.482802934495 counts:[106141, 101104, 93715, 109301, 96623, 116675, 92481, 95669, 87635, 100656]
use time:0.98s v_num: 120 deviation:7166.440399528904 counts:[107114, 90388, 96243, 111374, 101214, 101565, 106623, 87568, 95596, 102315]
use time:0.97s v_num: 150 deviation:6016.300142113922 counts:[113803, 102455, 95533, 103487, 97674, 100789, 99004, 89302, 101182, 96771]
use time:0.98s v_num: 180 deviation:4573.741138280565 counts:[91651, 95905, 99582, 97932, 101912, 107818, 102427, 97578, 106355, 98840]
use time:0.99s v_num: 210 deviation:7374.681850764818 counts:[97200, 111671, 97106, 90902, 107620, 96026, 107991, 97315, 105650, 88519]
use time:0.99s v_num: 240 deviation:6919.73383881201 counts:[97715, 100029, 99184, 101653, 94316, 113006, 94762, 98836, 111200, 89299]
use time:1.0s v_num: 270 deviation:5882.344736582513 counts:[89846, 101481, 95710, 105634, 93310, 97264, 107036, 97557, 103971, 108191]
use time:1.01s v_num: 300 deviation:6092.568588042321 counts:[100935, 105537, 96929, 97190, 104050, 104869, 91781, 91659, 95771, 111279]
复制代码


用户头像

李循律

关注

还未添加个人签名 2018.05.23 加入

还未添加个人简介

评论

发布
暂无评论
架构师训练营第 1 期 第 5 周作业