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
0
200
About: consistent hashing
Harukasan
PRO
February 27, 2017
Tweet
Share
More Decks by Harukasan
See All by Harukasan
pixivを支える技術 / 技育CAMPアカデミア
harukasan
PRO
3
400
20240401 新卒研修 - ピクシブにおける技術領域
harukasan
PRO
1
710
ピクシブのコンテンツ配信基盤技術 / pixiv TECH SALON
harukasan
PRO
5
5.4k
Goにおける画像ファイル処理 / golang.tokyo #19
harukasan
PRO
7
6.5k
WebRTC動画をトランスコードする / Transcoding video streams from WebRTC
harukasan
PRO
5
1.5k
ImageFluxを支えるリモート開発 / 20171202
harukasan
PRO
2
1.8k
YAPC::Fukuoka 前夜祭LT / Yet Another Pawoo Commit logs
harukasan
PRO
0
2.9k
YAPC::Fukuoka lunch session
harukasan
PRO
1
3k
マストドン会議: Pawoo / Mastodon Kaigi2
harukasan
PRO
2
440
Other Decks in Technology
See All in Technology
ハイテク休憩
sat
PRO
2
140
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
550
Wantedly での Datadog 活用事例
bgpat
1
430
podman_update_2024-12
orimanabu
1
260
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
220
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
430
kargoの魅力について伝える
magisystem0408
0
200
UI State設計とテスト方針
rmakiyama
2
440
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
150
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
150
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
2
2.2k
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
45
7k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Raft: Consensus for Rubyists
vanstee
137
6.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Unsuck your backbone
ammeep
669
57k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Practical Orchestrator
shlominoach
186
10k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Gamification - CAS2011
davidbonilla
80
5.1k
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[ׁ׀ !؆ֿ̙ ؆ϟՃѹҁҊѯҐӘӹـӐѮƀҌѥ ؆࣮ΆҤӏԍӯԃ