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
Harukasan
PRO
February 27, 2017
Technology
240
0
Share
About: consistent hashing
Harukasan
PRO
February 27, 2017
More Decks by Harukasan
See All by Harukasan
Building a Standalone Programming Environment
harukasan
PRO
1
1.7k
Successor to PicoRabbit: Ruby Programming Envorinment / RubyKaigi 2025 follow up
harukasan
PRO
1
1.1k
Write your own mrbgem, Create your own device
harukasan
PRO
1
380
PicoRabbit: a Tiny Presentation Device Powered by Ruby
harukasan
PRO
2
1.6k
pixivを支える技術 / 技育CAMPアカデミア
harukasan
PRO
3
590
20240401 新卒研修 - ピクシブにおける技術領域
harukasan
PRO
1
940
ピクシブのコンテンツ配信基盤技術 / pixiv TECH SALON
harukasan
PRO
5
5.9k
Goにおける画像ファイル処理 / golang.tokyo #19
harukasan
PRO
7
6.8k
WebRTC動画をトランスコードする / Transcoding video streams from WebRTC
harukasan
PRO
5
1.7k
Other Decks in Technology
See All in Technology
Fabric-cicd によるAzure DevOps デプロイ
ryomaru0825
0
120
long-running-tasks
cipepser
2
440
GitHub Copilot のこれまでとこれから: From Copilot to Collaborative Agents
yuriemori
1
230
Platform engineering for developers, architects & the rest of us (AI agents)
danielbryantuk
0
120
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.8k
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
4
1.8k
Oracle Cloud Infrastructure:2026年5月度サービス・アップデート
oracle4engineer
PRO
1
240
Claude Codeですべての日常業務を爆速化しよう!
minorun365
PRO
16
15k
Strands Agents超入門
kintotechdev
1
140
オンコールの負荷軽減のためのBits Assistant 活用方法 / How to Use Bits Assistant to Reduce the Workload on On-Call Staff
sms_tech
1
320
イベントで大活躍する電子ペーパー名札 〜その3〜 / ビジュアルプログラミングIoTLT vol.23
you
PRO
0
160
RubyでRuby拡張を書いたらRubyより35倍速になったってどういうこと??
kazuho
3
920
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
RailsConf 2023
tenderlove
30
1.4k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
520
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
180
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
590
Writing Fast Ruby
sferik
630
63k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
710
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.2k
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[ׁ׀ !؆ֿ̙ ؆ϟՃѹҁҊѯҐӘӹـӐѮƀҌѥ ؆࣮ΆҤӏԍӯԃ