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
820
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
300
Distributed Deep Learning with Chainer and Hadoop
kuenishi
3
1.1k
A Few Ways to Accelerate Deep Learning
kuenishi
0
1k
Introducing Retz
kuenishi
5
1.1k
Introducing Retz and how to develop practical frameworks
kuenishi
3
680
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
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
240
LINE Developersプロダクト(LIFF/LINE Login)におけるフロントエンド開発
lycorptech_jp
PRO
0
120
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
220
Snykで始めるセキュリティ担当者とSREと開発者が楽になる脆弱性対応 / Getting started with Snyk Vulnerability Response
yamaguchitk333
2
190
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
750
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
190
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
170
20241220_S3 tablesの使い方を検証してみた
handy
4
580
宇宙ベンチャーにおける最近の情シス取り組みについて
axelmizu
0
110
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
550
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
3
2.3k
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
How to train your dragon (web standard)
notwaldorf
88
5.7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
4 Signs Your Business is Dying
shpigford
181
21k
Making Projects Easy
brettharned
116
5.9k
Mobile First: as difficult as doing things right
swwweet
222
9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
RailsConf 2023
tenderlove
29
940
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
How GitHub (no longer) Works
holman
311
140k
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ɺϨϓϦέʔγϣϯ •ʢࠓʣ͏Կ͕ͳΜ͔͔ͩΒͳ͍͘Β͍ଟ༷Խ •ٕज़తͳ؍ʢͷྨʣ •εέʔϧΞτɺނোੑɺ߹ੑʢɺ͋ΔΑ