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
データ鮮度を落とさずに安全にReindexしたい
Search
kotaroooo0
February 26, 2025
0
82
データ鮮度を落とさずに安全にReindexしたい
kotaroooo0
February 26, 2025
Tweet
Share
More Decks by kotaroooo0
See All by kotaroooo0
検索エンジン自作入門 Go Conference 2021 Spring
kotaroooo0
17
7.3k
転置インデックスでどう検索しているか
kotaroooo0
0
290
俺の全文検索エンジン(Go製)を作り始めた
kotaroooo0
0
110
ぼくのかんがえたさいきょうのDocker Build
kotaroooo0
0
86
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Making the Leap to Tech Lead
cromwellryan
134
9.3k
GraphQLとの向き合い方2022年版
quramy
46
14k
How STYLIGHT went responsive
nonsquared
100
5.6k
Adopting Sorbet at Scale
ufuk
77
9.4k
Docker and Python
trallard
44
3.4k
Into the Great Unknown - MozCon
thekraken
39
1.8k
Designing for humans not robots
tammielis
253
25k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
4 Signs Your Business is Dying
shpigford
184
22k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Typedesign – Prime Four
hannesfritz
42
2.7k
Transcript
@kotaroooo0 2025/02/26 Elasticsearch Community in Tokyo 2025 σʔλΛམͱͣ͞ʹ҆શʹ Reindex͍ͨ͠ 1
ࣗݾհ 2 ҆ୡޫଠ @kotaroooo0 גࣜձࣾ10X ωοτεʔύʔͷݕࡧਪનͷ ։ൃӡ༻Λ୲͍ͯ͠·͢
ΞδΣϯμ 3 1. Reindexʹ͍ͭͯ 2. 10XͰͷ͜Ε·ͰͷReindexํ๏ͱ 3. 10XͰͷ৽͍͠Reindexํ๏ 4. ·ͱΊ
Reindexʹ͍ͭͯ • ΠϯσοΫεΛ࠶ߏங͢Δ࡞ۀ • ͳͥඞཁͳͷ͔ʁ • ܗଶૉղੳͷࣙॻߋ৽ͷͨΊ • طଘϑΟʔϧυͷมߋɾআͳͲͷͨΊ •
Ͳ͏ͬͯΔ͔ʁ • ୯७ʹߟ͑ΔͱɺReindex API → ΤΠϦΞεΛΓସ͑ • ͔͠͠ɺΠϯσοΫεΛࠩߋ৽͢Δ߹ɺ͜ͷΓํͰσʔλߋ৽࿙ Ε͕ൃੜͯ͠͠·͏… 4 →
10XͰͷ͜Ε·ͰͷReindexํ๏ લఏ • ϝΠϯͷΠϯσοΫεωοτεʔύʔͷΛݕࡧ͢ΔͨΊͷΠϯσοΫε • σʔλͷཧআͳ͠ • ͓٬͞·͔ΒͷϦΫΤετʹΑΔࢀর͕େྔʹ͋Δ • ߋ৽͕ৗʹ͋Δ
• 3shards, 2replicaͰ1shard 12GB͘Β͍ 5 10XͷΠϯσΩγϯάΞʔΩςΫνϟ
10XͰͷ͜Ε·ͰͷReindexํ๏ 6 1. Reindex APIΛୟ͘(70) 2. ΤΠϦΞεΛΓସ͑Δ 3. ߋ৽࿙ΕͷσʔλΛdb͔Β औಘ͠࠶publish(10)
10XͰͷ͜Ε·ͰͷReindexํ๏ • σʔλ͕མͪΔ͕͍࣌ؒ • Reindex͕1࣌ؒҎ্͔͔Γͦͷؒʹߋ৽͞Εͨσʔλ͕ଟ͍ • ΤΠϦΞεΓସ͑ޙʹσʔλճ෮͢Δͷʹ͕͔͔࣌ؒΔ • σʔλճ෮ͷͨΊͷॲཧ͕ɺdb,
queue, workerʹґଘ͠Τϥʔ͕ൃੜ ͍͢͠ 7
10XͰͷ৽͍͠Reindexํ๏ 8 https://tech.legalforce.co.jp/entry/2021/12/21/190129
10XͰͷ৽͍͠Reindexํ๏ • Reindex APIͰqueryΛॻ͚Δ͜ͱΛͬͨ • updatedAtͰߜΓࠐΊɺ͚ࠩͩReindexͰ͖Δ • Կճ͔Reindex APIΛୟ͚ɺঃʑʹॴཁ͕࣌ؒ͘ͳΓσʔλ͕΄΅མͪ ͳ͘ͳΔͷͰ…?
• ·ͨElasticsearch୯ମͰReindexΛ݁Ͱ͖γϯϓϧʹͳΓোੑ্͕͢Δ 9 → →
10XͰͷ৽͍͠Reindexํ๏ 10
10XͰͷ৽͍͠Reindexํ๏ ͬͯΈͨ݁Ռ • 3ճReindexΛ܁Γฦͯ͠Έͨ • ຊ൪ڥ • 1ճͷReindex 4368ඵ •
2ճͷReindex 261ඵ • 3ճͷReindex 331ඵ • ΤΠϦΞεΓସ͑ޙͷReindex 1ඵ • σʔλ͕མͪΔ͕࣌ؒ΄ͱΜͲͳ͍ʂ • ReindexͷλΠϛϯάʹΑΓॴཁ࣌ؒલޙͦ͠͏ 11 ࢀߟ: ։ൃڥ • 1ճͷReindex 5743ඵ • 2ճͷReindex 1028ඵ • 3ճͷReindex 577ඵ • ΤΠϦΞεΓସ͑ޙͷReindex 603ඵ
10XͰͷ৽͍͠Reindexํ๏ ͠ཧআ͕͋ͬͨΒ…? • ͜ͷํ๏Ͱෆे • Reindex API͚ͩͰʮআ͞Εͨσʔλʯ͑ͳ͍ • Ͳ͏ରԠ͢Δ͔ •
ํ๏1: ཧআʹํࣜΛม͑Δ • ํ๏2: আϩάΛه͓͖ͯ͠࠷ޙʹআ͢Δ • ํ๏3: ΤΠϦΞεΓସ͑ޙʹdbͱElasticsearchΛൺֱ͠ෆཁͳυΩϡϝϯτΛ আ͢Δ 12
·ͱΊ Reindex APIΛෳճୟ͘ํ๏ʹΑΓ • σʔλ͕མͪΔ͕࣌ؒେ෯ʹॖͨ͠ • ElasitcsearchͷΈͰReindexΛྃͰ͖ɺγϯϓϧʹͳΓোੑ্͕ͨ͠ 13 → →