Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
About: consistent hashing
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Harukasan
PRO
February 27, 2017
Technology
0
230
About: consistent hashing
Harukasan
PRO
February 27, 2017
Tweet
Share
More Decks by Harukasan
See All by Harukasan
Successor to PicoRabbit: Ruby Programming Envorinment / RubyKaigi 2025 follow up
harukasan
PRO
1
220
Write your own mrbgem, Create your own device
harukasan
PRO
1
240
PicoRabbit: a Tiny Presentation Device Powered by Ruby
harukasan
PRO
2
630
pixivを支える技術 / 技育CAMPアカデミア
harukasan
PRO
3
560
20240401 新卒研修 - ピクシブにおける技術領域
harukasan
PRO
1
890
ピクシブのコンテンツ配信基盤技術 / pixiv TECH SALON
harukasan
PRO
5
5.8k
Goにおける画像ファイル処理 / golang.tokyo #19
harukasan
PRO
7
6.8k
WebRTC動画をトランスコードする / Transcoding video streams from WebRTC
harukasan
PRO
5
1.6k
ImageFluxを支えるリモート開発 / 20171202
harukasan
PRO
2
1.9k
Other Decks in Technology
See All in Technology
ZOZOにおけるAI活用の現在 ~開発組織全体での取り組みと試行錯誤~
zozotech
PRO
5
4.8k
GitLab Duo Agent Platform × AGENTS.md で実現するSpec-Driven Development / GitLab Duo Agent Platform × AGENTS.md
n11sh1
0
120
Tebiki Engineering Team Deck
tebiki
0
24k
Agile Leadership Summit Keynote 2026
m_seki
1
400
Deno・Bunの標準機能やElysiaJSを使ったWebSocketサーバー実装 / ラーメン屋を貸し切ってLT会! IoTLT 2026新年会
you
PRO
0
290
usermode linux without MMU - fosdem2026 kernel devroom
thehajime
0
210
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
42k
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
日本の85%が使う公共SaaSは、どう育ったのか
taketakekaho
1
140
Databricks Free Edition講座 データサイエンス編
taka_aki
0
290
MCPでつなぐElasticsearchとLLM - 深夜の障害対応を楽にしたい / Bridging Elasticsearch and LLMs with MCP
sashimimochi
0
140
15 years with Rails and DDD (AI Edition)
andrzejkrzywda
0
170
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Rails Girls Zürich Keynote
gr2m
96
14k
Amusing Abliteration
ianozsvald
0
96
Statistics for Hackers
jakevdp
799
230k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
0
1.8k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
270
A better future with KSS
kneath
240
18k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
110
The Invisible Side of Design
smashingmag
302
51k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
110
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Transcript
ӋԍӏӑӞԍӠӧӜӏӾʂҍ҅ѥ҈ ӬӆӏӮװɒױґҭѭѷҵ
ѵѵ҉ѥѧӧӜӏԍӇҊґ
ΌҐӄـҴΌҐӦـӡҍðҬƾ҈ҁѥ Ҋѥѧī
ֿ ׀ ׁ ׅ ׆ ׇ ֿ־ ֿ ׀ ׁ
ׂ ׃ ׄ ӄـ Ӧـӡ
ֿ ׀ ׁ ׅ ׆ ׇ ֿ־ ֿ ׀ ׁ
ׂ ׃ ׄ ˅ˤҍґѵѧҌ҆҈ҝѹѥ Ӧـӡ
ѵҮѮ҉ѯҭҊ ؆!ҐӏӼـӟҺԍӇ ؆ӄӼӜӏӾҐåࢄشࠓ´҆҈ҭҥ҅ ؆Ҍҍѭѣҭҥ҅ҴҌҵѭͮѥײѺҍåð ……ҊѭҠѣѥүѥүҊ¸ê
˕ӏԍӯԃҌȠʂ פӺӐӾԅʂץ
ֿ ׀ ׁ ֿ ׀ ׁ %3 = 1 %3
= 2 %3 = 0 ׂ %3 = 1 ӺӐӾԅʂ ӦـӡҐ²ҴҊҭ ׃ ׄ %3 = 2 %3 = 0
ӺӐӾԅʂ ؆ÅҬѮχѵҫҌѱ҈ͮѷѿѧ ؆ӏԍӯԃ ؆ӦـӡҴϟՃѻҭҊѯҍŖő
ӺӐӾԅʂ ֿ ׀ ׁ ֿ ׀ ׁ %3 = 1
%3 = 2 %3 = 0 ׂ %3 = 1 ׃ ׄ %3 = 2 %3 = 0
ӺӐӾԅʂ ׂ ֿ ׀ ׁ ֿ ׀ ׁ %3 =
1 %3 = 2 %3 = 0 ׂ %3 = 1 ׃ ׄ %3 = 2 %3 = 0
ֿ ׀ ׁ ֿ ׀ ׁ %4 = 1 %4
= 2 %4 = 3 ׂ %4 = 0 ӺӐӾԅʂ ׂ ׃ ׄ %4 = 1 %4 = 2 ӦـӡҴϟՃѻҭҊѯҍŖő ׀¦߱ѻқ҈҉ȳѯȈѩѮˠੜ
פӺӐӾԅʂץґ ࣮ΆѮ؆୯҂ѮӦـӡҐϟՃ؏আѮŖő
ӋԍӏӑӞԍӠӧӜӏӾʂ • @_LE@YJFYF[@Q،TSZLZ[FS[ @ZKLSJ@SE@SETR YFFZLZ[YLC\[FE@DKLSJYT[TDTQZITYFQLF_LSJ T[ WT[ZTS[KF"TYQE"LEF"FC،ׇׇֿׅׯ • ࣮ΆҊѹ҈ґFRD@DKFEҐҁңҐF[@R@ѮȵĚ K[[WZזזJL[K\CאDTRזזPF[@R@
• SJLSaW@DKFY@IILDFY_FYҤ࠾ˉ
ӋԍӏӑӞԍӠӧӜӏӾʂ ؆ӧӜӏӾВґɠҍåƖѻҭґѼ ؆ӧӜӏӾВҴԂԍӇ ҍѹ҈࣮Ά
ֿ ׀ ׁ ӋԍӏӑӞԍӠӧӜӏӾʂ ӦـӡӄـҐѿҮҀҮҴęѺӧӜӏӾ̌БҍࣹӨ @ZK @ZK @ZK ׯ ׯ
ׯ ӧӜӏӾ̌Б
ֿ ׀ ׁ @ZK @ZK @ZK ׯ ׯ ׯ ӧӜӏӾ̌Б
ֿ ׀ ׁ ׂ ׃ ׄ @ZK @ZK @ZK @ZK @ZK @ZK ׯ ׯ ׯ ׯ ׯ ׯ ӋԍӏӑӞԍӠӧӜӏӾʂ ӦـӡӄـҐѿҮҀҮҴęѺӧӜӏӾ̌БҍࣹӨ
ֿ @ZK ׯ ֿ ׀ ׁ @ZK @ZK @ZK ׯ
ׯ ׯ ۙѥÃҴબ ֿ ׀ ׁ ׂ ׃ ׄ @ZK @ZK @ZK @ZK @ZK @ZK ׯ ׯ ׯ ׯ ׯ ׯ ֿ˕ ҐÃҴҊҭ ؼ ӧӜӏӾ̌Б ӋԍӏӑӞԍӠӧӜӏӾʂ ӦـӡӄـҐѿҮҀҮҴęѺӧӜӏӾ̌БҍࣹӨ
ӋԍӏӑӞԍӠӧӜӏӾʂ ؆ӧӜӏӾВґɠҍåƖѻҭґѼ ؕҌҐ҉ÅҫҌѥ ؆ȳѯȈҰҭҐґӧӜӏӾ̌БҐ϶҂ѳҐґѼ ؕҌҐ҉ϟՃѹҁҊѯҐӘӹـӐѮƀҌѥ
ֿ ׀ ׁ ϟՃѹҁҊѯҐӘӹـӐѮƀҌѥ @ZK @ZK @ZK ׯ ׯ ׯ
ӧӜӏӾ̌Б ֿ ׀ ׁ ׂ ׃ ׄ @ZK @ZK @ZK @ZK @ZK @ZK ׯ ׯ ׯ ׯ ׯ ׯ
ϟՃѹҁҊѯҐӘӹـӐѮƀҌѥ ӧӜӏӾ̌Б ֿ ׀ ׁ ׂ ׃ ׄ @ZK @ZK
@ZK @ZK @ZK @ZK ׯ ׯ ׯ ׯ ׯ ׯ ֿ ׀ ׁ @ZK @ZK @ZK ׯ ׯ ׯ ׂ @ZK ׯ ׂҴϟՃ
ϟՃѹҁҊѯҐӘӹـӐѮƀҌѥ ӧӜӏӾ̌Б ֿ ׀ ׁ ׂ ׃ ׄ @ZK @ZK
@ZK @ZK @ZK @ZK ׯ ׯ ׯ ׯ ׯ ׯ ֿ ׀ ׁ @ZK @ZK @ZK ׯ ׯ ׯ ۙѥÃҴબ ׂ @ZK ׯ ȳѯȈҰ҆ҁҐґׄ҂ѳ
ӋԍӏӑӞԍӠӧӜӏӾʂ ؆ÅҫҌѥ ؆ϟՃѹҁҊѯҐӘӹـӐѮƀҌѥ
ӧӜӏӾ̌Б ֿ @ZK ׯ ˅ˤҍґ ؟ֿذ׀
˅ˤҍґ ӧӜӏӾ̌Б ֿ ׀ @ZK @ZK ׯ ׯ ׀ҴϟՃѻҭҊ ؟ֿذ׀׃־أ
ӧӜӏӾ̌Б ֿ ׀ @ZK @ZK ׯ ׯ ׁ @ZK ׯ
˅ˤҍґ ؟׀ذׁ׀׃أ ׁҴϟՃѻҭҊ
ӧӜӏӾ̌Б ֿ ׀ @ZK @ZK ׯ ׯ ׁ @ZK ׯ
ׂ @ZK ׯ ˅ˤҍґ ؟ׁذׂ׀׃أ ׂҴϟՃѻҭҊ
ӋԍӏӑӞԍӠӧӜӏӾʂ ؆ÅҫҌѥ ؆ϟՃѹҁҊѯҐӘӹـӐѮƀҌѥ
ӋԍӏӑӞԍӠӧӜӏӾʂҐ࣮Ά F[@R@ҐńĘׯ
# ϋογϡؔ32bit unsigned intͷϋογϡΛฦ͢ # CRC32, MD5ͷ্Ґ32bitͳͲͰ࣮ func hash(key string)
uint32 { ... } # ϊʔυͷϋογϡΛܭࢉ for _, node := range nodes { # ͻͱͭͷϊʔυຖʹ160ݸͷϋογϡΛܭࢉ for i := 0; i < 160; i++ { k := fmt.Sprintf(“%s-%d”, node, i) # ϊʔυ໊ͱϋογϡͷϖΞΛՃ continuum.add(node, hash(k)) } } # ϋογϡͰιʔτ͓ͯ͘͠ sort.Sort(continuum) ֿאӦـӡӶӜӯҐܭࢉ
ֿאӦـӡӶӜӯҐܭࢉ ӧӜӏӾ̌Б ֿ @ZK ׯ ֿ҅ҐӦـӡҍରѹ ΌҐӧӜӏӾҴܭࢉ ذӧӜӏӾܭࢉҍҩҭÅҬҴЕɦ ؕ׀־־¿ѱҫѥ҉ůŲׯ
# ϋογϡͰιʔτ͓͚ͯ͠ೋ୳ࡧͰ୳ࡧͰ͖Δ func search(key string) string { v := hash(key)
i, j := 0, n for i < j { h := i + (j-i)/2 if (continuum.values[i] > v) { i = h + 1 } else { j = h } } return continuum.nodes[i] } ׀אӧӜӏӾҐ୳ࡧ
׀אӧӜӏӾҐ୳ࡧ ӧӜӏӾ̌Б _ @ZK ׯ ֿ ׀ ׁ @ZK @ZK
@ZK ׯ ׯ ׯ ׂ @ZK ׯ å୳ࡧ҉˕ۙѥӧӜӏӾҴʹŲ
ҠҊң ӋԍӏӑӞԍӠӧӜӏӾʂׯ ؆ÅҫҌѥ ؕӧӜӏӾВҊѹ҈ґ׃ ¯ׁ׀CL[ׁ׀ !؆ֿ̙ ؆ϟՃѹҁҊѯҐӘӹـӐѮƀҌѥ ؆࣮ΆҤӏԍӯԃ