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
NoSQL概論
Search
UENISHI Kota
September 11, 2015
Technology
3
810
NoSQL概論
High-level overview on NoSQL
UENISHI Kota
September 11, 2015
Tweet
Share
More Decks by UENISHI Kota
See All by UENISHI Kota
Metadata Management in Distributed File Systems
kuenishi
2
470
Behind The Scenes: Cloud Native Storage System for AI
kuenishi
2
330
Apache Ozone behind Simulation and AI Industries
kuenishi
0
290
Distributed Deep Learning with Chainer and Hadoop
kuenishi
3
1.1k
A Few Ways to Accelerate Deep Learning
kuenishi
0
990
Introducing Retz
kuenishi
5
1.1k
Introducing Retz and how to develop practical frameworks
kuenishi
3
670
Formalization and Proof of Distributed Systems (ja)
kuenishi
10
6.3k
Mesos Frameworkの作り方 (How to Make Mesos Framework)
kuenishi
7
2.3k
Other Decks in Technology
See All in Technology
FlutterアプリにおけるSLI/SLOを用いたユーザー体験の可視化と計測基盤構築
ostk0069
0
100
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
200
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
330
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
120
日経電子版のStoreKit2フルリニューアル
shimastripe
1
140
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
320
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
180
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
170
Featured
See All Featured
A better future with KSS
kneath
238
17k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Scaling GitHub
holman
458
140k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
A Philosophy of Restraint
colly
203
16k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Building an army of robots
kneath
302
43k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Transcript
NoSQL ֓ 2015/9/11 DB Tech Showcase Sapporo Basho δϟύϯ᷂ɹ্߁ଠ
୭ʁ • @kuenishi • Github, Twitter, etc • ࢄγεςϜྺ7 •
Bashoδϟύϯͷํ͔Βདྷ·ͨ͠ • Riak CSͷ։ൃ • ࠷ۙτϥϯβΫγϣϯʹڵຯ ͕͋Γ·͢
Ξϯέʔτ •SQL͡Όͳ͍ͱϦϨʔγϣφϧͳσʔλϕʔ ε࡞Εͳ͍ʁ •ʮཧ͔ΒֶͿσʔλϕʔε࣮ફೖʯΛಡ Μͩʁ •ʮNoSQLͷجૅࣝʯΛಡΜͩʁ •Dynamo? BigTable? Tandem?
ΞδΣϯμ •NoSQLΑ͏Θ͔ΒΜʂԿʁʂͱ͍͏ਓͷͨΊʹɺ ԿͳͷͬͯΛ͠·͢ •͍Ζ͍Ζ͋ͬͯΘ͔ΒΜʂͱ͍͏ਓͷͨΊʹྨ ࣠ʹ͍͓ͭͯ͠·͢ •ͦͷଞɺ༩ଠΛ͠·͢
Relational DBMS •Ұൠతʹ… •ෳͷΫϥΠΞϯτ͔ΒTCP/IPͰଓ͠ •ϦϨʔγϣφϧϞσϧΛ࣮༻Խͨ͠SQLͱ͍͏ݴޠΛΠϯλʔ ϑΣʔεͱ͠ •B+treeͱϒϩοΫΩϟογϡͱ͍͏σʔλߏΛ͍ɺ •WALͱB+treeͰӬଓԽΛ͠ʢϨϓϦέʔγϣϯ͠ͳ͍ʣɺ •MVCCͳͲͰฒߦੑ੍ޚΛߦ͏σʔλϕʔεཧγεςϜ
NoSQL? •Not Only? •ݴ༿ͱҟͳΔɺ2௨Γͷ࣮ଶ •A) σʔλϞσϧɺΠϯλʔϑΣʔεͱͯ͠SQLΛͬͯ ͍ͳ͍ •B) طଘͷτϥϯβΫγϣϯॲཧٕज़ͰͰ͖ͳ͔ͬͨ͜ ͱΛ࣮ݱ͢ΔͨΊʹɺผٕज़Λ࠾༻ͨ͠
SQLͰͳ͍ʁ •ϦϨʔγϣφϧϞσϧͰͳ͍ԿΒ͔ͷσʔλϞσϧ •σʔλදݱΫΤϦݴޠʹSQLΛΘͳ͍ •υΩϡϝϯτDB: “Semi-structured database” •Redis •KVS (Key-Value Store):
ฆΒΘ͍͠
Document DB •ͱͱͷࢥ: •͋ΒΏΔλΠϓͷυΩϡϝϯτΛอଘͯ͠ΫΤϦ Ͱ͖ΔΑ͏ʹ͠Α͏ •JSON, XML, PDF, etc… •ݱ࣮:
݁ہ… •KVS ʹ JSON + ΠϯσοΫε + ࢄMapReduce
ACIDͰͳ͍ʁ
ACID •Atomicity •ߋ৽ͷ్தঢ়ଶ͕ݟ͑ͳ͍͜ͱ •Isolation •ଞͷਓ͕ߋ৽͍ͯ͠Δͷ͕ݟ͑ͳ͍͜ͱ •Key-Value StoreͳΒɺ୯ҰͷΤϯτϦΛϩοΫͯ͠ߋ৽͢Δͩ ͚ͳͷͰAtomicͩ͠Isolated!! ʢϗϯτʁʣ
ACID •RDBͩͱ •ϦϨʔγϣϯಉ࢜ͷσʔλ͕߹͍ͯ͠Δ͜ͱ •ࢄτϥϯβΫγϣϯͯ͠σʔλ͕ෆ߹͠ͳ͍͜ͱ •ނোͯ͠߹ͨ͠ঢ়ଶͰϦΧόϦͰ͖Δ͜ͱ •NoSQLͩͱ •ϨϓϦέʔγϣϯͯ͠σʔλ͕ෆ߹͠ͳ͍͜ͱ •Key-Value StoreͳΒ…
ACID •RDBͩͱ •ӬଓԽσΟεΫʹॻ͍ͨΒऴΘΓ •σΟεΫյΕͨΒΒͶ •NoSQLͩͱ •σΟεΫյΕͯιϑτΣΞͰԿͱ͔͢Δ •ࣗͰϨϓϦέʔγϣϯΔʂ
εέʔϧΞτʁ •σʔλͷۭؒΛԿΒ͔ͷϧʔϧʹଇׂͬͯ͢Δ •ׂͨ͠σʔλΛࢄͯ͠ཧ͢Δ •ϊʔυΛ૿͢ͱॲཧೳྗ༰ྔ͕૿͑Δʢʁʣ
εέʔϧΞτਤղ σʔλۭؒ ׂۭؒ
B+Tree •ΩʔΠϯσοΫε͔Β O(log N) ҎԼͷίετͰ σʔλΛݟ͚ͭΔͨΊͷσʔλߏ •εέʔϧΞτ͢Δͱ… •͍͔ͭ͘ิʢସʣٕज़͕͋Δ •Consistent Hashing
•γϟʔσΟϯά (Range Partitioning) •֊γϟʔσΟϯά
εέʔϧΞτͱނোੑ •Q. 1ͷϊʔυͷނো֬Λ p ͱ͢Δͱɺ n ͷΫϥελ͕શͯ ਖ਼ৗಈ࡞͍ͯ͠Δ֬ʁ 1. 1
- p^n 2. p^n 3. (1 - p)^n •εέʔϧ͕େ͖͍ͱɺͲ͔͕͜΄΅ඞͣյΕ͍ͯΔঢ়ଶʹͳΔ •෦ނো͕ى͖͍ͯͯશମ͕ਖ਼͘͠ಈ࡞͢Δઃܭ͕ඞཁ •ϨϓϦέʔγϣϯʹΑΔࣗಈతͳϑΣΠϧΦʔόʔͳͲ͕ඞཁ
ਖ਼ৗಈ࡞ͷ֬ n \ p 0.1 0.01 0.001 1 0.9 0.99
0.999 10 0.348678440 0.904382075 0.990044880 100 0.000026561 0.366032341 0.904792147 1000 0 0.000043171 0.367695424 ※༗ޮࣈ…
εέʔϧΞτਤղ 2 σʔλۭؒ ෳ
ӬଓԽͱ •ܗ͋Δͷ͍͔ͭյΕΔ •ॾߦແৗʢେൠᔷᒒܦʣ •2ͭҎ্ͷίϐʔΛ͓࣋ͬͯ͘Ҏ֎ʹɺ σʔλΛӬٱʹอଘ͢Δํ๏ͳ͍ •ෳͷͳ͍σʔλϕʔεͳ͍
ෳඞͣ࡞ΒΕΔ •LANͷ͜͏Ͱ •SANͷ͜͏Ͱ •ւͷ͜͏Ͱ •ނো୯Ґ͕ඞ͔ͣΕ ͍ͯΔ (C) Evan Amos
ނোͯ͠ಈ࡞ܧଓ͢Δෳ •Ͳ͏͍͏ނোϞσϧΛલఏʹͯ͠Ϩϓ ϦέʔγϣϯΛΜ͔͕ͩॏཁ •Fail-stopΛલఏʹ͍͚ͯ͠ͳ͍ •ʮյΕ͔͚ͷRadioʯ •͍ΘΏΔαΠϨϯτނো •ωοτϫʔΫͷஅɺॠஅ •Disk Hiccup (C)
Evan Amos
ωοτϫʔΫͷஅ •அͨ͠ΒɺͲͪΒ͕ਖ਼͠ ͍͔ܾΊͳ͚Ε͍͚ͳ͍ •ϚχϡΞϧͰհೖ͢Εܾ ΊΒΕΔʢ͔͠Εͳ͍ʣ •ࣗಈԽ͢Δʹɺωοτϫʔ Ϋ͕ΕͯσʔλΛ߹ ͤ͞Δෳٕज़͕ඞཁ ? ?
(C) Evan Amos
ෳͷٕज़ ෳͷλΠϓ ނোͳͲͷલఏ Master-slave ಉظ ωοτϫʔΫ͕ނোͨ͠Βࢭ·Δ Master-slave ඇಉظ ωοτϫʔΫ͕ނোͨ͠Β σʔλ͕ෆ߹͢Δ͔
Consensus (Strong Consistency) ωοτϫʔΫ͕ނোͨ͠ΒҰ෦ಈ࡞ Eventual Consistency ωοτϫʔΫ͕ނোͯ͠શಈ࡞
ෳͰͳ͍σʔλͷ߹ੑ •εέʔϧΞτ͢Δͱɺผϊʔυ্ͷ ผͷσʔλΛ߹ͨ͠ঢ়ଶͰߋ৽͠ͳ ͚ΕͳΒͳ͍ •ࢄͨ͠ΠϯσοΫεͷߋ৽ •֎෦Ωʔͷߋ৽ •τϦΨʔͷॲཧ
εέʔϧΞτਤղ 3 ςʔϒϧ ΠϯσοΫε or FKey or else
ෳͰͳ͍σʔλͷ߹ੑ อো •2PC (or ࢄϩοΫ) •ϩοΫΛ࣋ͬͨ··ϊʔυ͕ނোͨ͠ͱ͖ͷѻ͍ •Cluster-wideͰҰ؏ͯ͠୯ௐ૿Ճ͢ΔԿΒ͔ͷΛੜ͢Ε ɺTSOMVCCΛ࣮Ͱ͖Δ •λΠϜελϯϓ …
࣌ܭͷಉظΛอো͢Δํ๏͕ࣗ໌Ͱͳ͍ •IDΛൃߦ͢ΔϚελʔϊʔυ … SPoF •͜͜·ͰͪΌΜͱ͍ͬͯΔNoSQL΄ͱΜͲͳ͍
NoSQLͷऴΘΓ •RDBMSͰղ͚ͳ͔͕͍͔ͬͨͭ͘ղ͚ͨͷͰʮͬͺΓSQL͕΄͍͠ʯ ʮ׳Εٕͨज़ऀ͕ଟ͍ͷͰʯ •ϦϨʔγϣφϧϞσϧʹଇ͍ͯ͠ͳ͍σʔλͰSQLͰΫΤϦΛॻ͚ͯ͠·͏ •͍͔ͭ͘ͷNoSQLɺτϥϯβΫγϣϯཧΛͦͦ͜͜ʹ SQL(-like ͳ) ΠϯλʔϑΣʔεΛఏڙͭͭ͋͠Δ •CQL, N1QL,
etc.. •OLAP͚ͷMPPΤϯδϯSQL͕ඪ४ •Impala, Drill, PrestoDB, Calcite
2ͭͷٕज़ •ΫΤϦॲཧ •RDBMSͰSQL •RDBMSͰͳͯ͘SQL •τϥϯβΫγϣϯॲཧ •ACIDΛ࣮ݱ͍ͯ͠ΔRDBMS •ࢄ͍ͯͯ͠ACIDΛࢦ͍ͯ͠Δ
Summary •ʢੲʣNoSQL ͱɺطଘͷσʔλϕʔεٕज़Λ1͔Βݟͳ ͓ͯ͠ɺRDBMSͰͰ͖ͳ͔ͬͨ͜ͱΛୡ͠Α͏ͱͨ͠Ұ ࿈ͷࢼΈ •ϦϨʔγϣφϧϞσϧɺB+treeɺϨϓϦέʔγϣϯ •ʢࠓʣ͏Կ͕ͳΜ͔͔ͩΒͳ͍͘Β͍ଟ༷Խ •ٕज़తͳ؍ʢͷྨʣ •εέʔϧΞτɺނোੑɺ߹ੑʢɺ͋ΔΑ