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
technology x business
Search
yujiosaka
June 10, 2015
Technology
3
530
technology x business
db tech showcase Tokyo 2015
yujiosaka
June 10, 2015
Tweet
Share
More Decks by yujiosaka
See All by yujiosaka
I was understanding WASM all wrong! 🤯
yujiosaka
2
220
Machine Learning with JavaScript
yujiosaka
0
150
JavaScriptでも機械学習がやりたかった話
yujiosaka
2
420
ヘッドレスChromeでクローラを作った後の話
yujiosaka
3
610
俺が最初にヘッドレスChromeでクローラ作った 事になんねーかな
yujiosaka
4
1.2k
『XXX』のための管理画面
yujiosaka
1
1.2k
Enjoy Deep Learning by JavaScript
yujiosaka
1
310
ひたすら楽してディープラーニング
yujiosaka
20
13k
第二回もんご祭 パネルディスカッション
yujiosaka
0
860
Other Decks in Technology
See All in Technology
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
Snowflake女子会#3 Snowpipeの良さを5分で語るよ
lana2548
0
230
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
1
230
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
DevOps視点でAWS re:invent2024の新サービス・アプデを振り返ってみた
oshanqq
0
180
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
310
株式会社ログラス − エンジニア向け会社説明資料 / Loglass Comapany Deck for Engineer
loglass2019
3
32k
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
480
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
140
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
160
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
270
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
36
14k
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Typedesign – Prime Four
hannesfritz
40
2.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
450
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Designing for humans not robots
tammielis
250
25k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Transcript
MongoDB x Business db tech showcase Tokyo 2015 Yuji Isobe
Profile Yuji Isobe Play fiddle/violin Engineer Contribute to socket.io Startup
member of emin
emin = Emotion Intelligence ؾ࣋ͪΛղ͢ΔςΫϊϩδʔͷ୳ڀ Emotion Intelligenceɺʮແҙࣝͷߦಈ͔Βɺ ਓͷؾ࣋ͪͷػඍΛղ͢ΔੑʯΛɺਓೳ͓Αͼػցֶ शͷԠ༻ٕज़Λ༻͍ͯ ։ൃ͠ɺϏδωεʹԠ༻͍ͯ͠·͢ɻ
;FO$MFSL ͕ࣾ։ൃͨ͠༧ଌΤϯδϯʮ&NPUJPO*0ʯ͕ɺΣϒα Πτ্ͷϢʔβʔͷແҙࣝͷߦಈΛϦΞϧλΠϜͰݕɺղ ੳ͠·͢ɻϢʔβʔͷߪങߦಈʹ͓͚Δ໎͍Λ͠ɺ࠷ద ͳλΠϛϯάͰΦϑΝʔΛఏࣔ͢ΔʮίϯόʔδϣϯɾΦϓ ςΟϚΠβʔʯ͕ɺ&$αΠτͷ$73Λ࠷దԽ͠·͢ɻ
ͳͥdb tech showcaseͰ Ϗδωε͕ςʔϚͳͷ͔ʁ
ਖ਼͍ٕ͠ज़ Ϗδωεͷཁ݅Λຬͨ͢ Α͘ड͚Δ૬ஊ □□Θͳ͍ͷʁ ˚˚͕ͭΒ͍ ××ͬͯΔ͚Ͳ ͜ͷ··Ͱ͍͍ͷ͔ͳ ◦◦ͬͯͲ͏ࢥ͏ʁ ٕज़ͳΜͯԿͬͯ ҰॹͰ͠ΐʁͬͯݴΘΕͨ
Μ͚ͩͲͲ͏͢Ε…
ਖ਼͍ٕ͠ज़ Ϗδωεͷཁ݅Λຬͨ͢ Business Tech ਖ਼͍ٕ͠ज़
Business ؒҧٕͬͨज़ Tech ؒҧٕͬͨज़Λબ͢Δͱ Ϗδωεޭ͠ͳ͍
Business Tech εέʔϧ͠ͳ͍ٕज़ εέʔϧ͠ͳ͍ٕज़ Ϗδωεͷ͔ͤʹͳΔ
Business Tech ίετ͕ߴ͍ٕज़ ίετ͕ߴ͗͢Δٕज़ ϏδωεΛ৯͍ͭͿ͢
Business Tech εέʔϧ͢Δਖ਼͍ٕ͠ज़ εέʔϧ͢Δٕज़ ϏδωεΛՃͤ͞Δ
ಛʹDBޙ͔Βมߋ͕ ͳ͔ͳ͔Ͱ͖·ͤΜ
NoSQLదࡐదॴ
ͦΕMongoDB ྫ֎Ͱ͋Γ·ͤΜ
Depth of Functionality Scalability & Performance NFNDBDIFE 3%#.4 LFZWBMVFTUPSF .POHP%#
MongoDBͷཱͪҐஔ Relational Databases Fight NoSQL Gravity https://www.mongodb.com/blog/post/relational-databases-nosql-gravity
͜ͷਤʹͳ͍͜ͱ͕ ݱ࣮ͰʹͳΓ·͢
Ϗδωεͷࢹ͕·͢·͢ ॏཁʹͳ͖͍ͬͯͯ·͢
ҰͭͷϢʔεέʔεΛհ͢Δ͚ͩͰͳ͘ ৽ͨͳʹ໘ͨ࣌͠ʹղܾʹཱͯΒΕΔ Goal
Topics ͳͥMongoDBΛબΜͩͷ͔ Ϗδωε͕ٸʹ͢ΔཪͰɺ ͲͷΑ͏ͳʹ໘͠ɺղܾ͖͔ͯͨ͠
ͳͥMongoDBΛબΜͩͷ͔
ͦͷલʹ
ࢲͨͪతʹԠͯ͡ DBΛ͍͚͍ͯ·͢
redis : ϦΞϧλΠϜσʔλ MongoDB : ੳ༻ϩάσʔλ MySQL : ϚελʔσʔλˍϨϙʔτ ༻͍ͯ͠ΔDB
redis : ϦΞϧλΠϜσʔλ MongoDB : ੳ༻ϩάσʔλ MySQL : ϚελʔσʔλˍϨϙʔτ ༻͍ͯ͠ΔDB
$PVDI%# )#"4& DBTTBOESB 3લʹൺֱݕ౼ͨ͠DB ࠓͳΒ Amazon DynamoDB͋ͨΓݕ౼ʹೖΓͦ͏
ͳͥMongoDBΛબΜͩͷ͔ ߏԽσʔλ εΩ ʔ Ϛ Ϩε εέ ʔ ϥ Ϗ
Ϧ ς Ο Ϗδωε ϓϩηε
Ϗδωεϓϩηε ϦΞϧλΠϜੳ Ωϟϯϖʔϯ৴ σʔλϚΠχϯά Ϟσϧߏங ຊ൪ೖ σʔλੵ
Garbage In, Garbage Out
ΰϛΛੳͯ͠ ΰϛ͕ฦͬͯ͘Δ͚ͩ
σʔλͷՁΛ ߴΊΔϓϩηεΛ࡞Δ
ߏԽσʔλ db.events.insert({ event: “touch”, touches: [ {pageX: 150, pageY: 100,
…}, {pageX: 47, pageY: 171, …} ], touchCount: 2 }); db.events.createIndex({ event: 1 }); ߦྻʹറΒΕͳ͍ σʔλߏΛදݱͰ͖Δ ݕࡧ͍ͨ͠ϑΟʔϧυʹ ࣗ༝ʹΠϯσοΫε͕ షΕΔ͜ͱ͕େ͖ͳڧΈ
Point! MongoDBRDBMSͱࣅͨΠϯσοΫεߏΛ ͍࣋ͬͯΔͷͰɺRDBͷࣝΛੜ͔͢͜ͱ͕Ͱ͖·͢ B-Tree, Compound Index, Covered Index, etc.
εΩʔϚϨε db.events.insert({ event: “touch”, touches: [ {pageX: 150, pageY: 100,
…}, {pageX: 47, pageY: 171, …} ], // delete touchCount: 2, // new orientation: -90, touchStart: new Date(), … }); औಘ͍ͨ͠σʔλ ʑมԽ͍͖ͯ͠·͢ RDBͷڧΈͰ͋Δͣͷ εΩʔϚ͕ɺϏδωεͷ ͔ͤʹͳͬͯ͠·͏
Point! ʰεΩʔϚϨε≠εΩʔϚఆ͕ٛෆཁʱͰ͋Γ·ͤΜ Ή͠ΖɺεΩʔϚϨεͰ͋Δ͔Βͦ͜ɺ εΩʔϚఆ͕ٛͱͯॏཁͰ͢
https://www.mongodb.com/presentations/schema-design-scale-1
ϨϓϦΧηοτ: ੑͷ֬อͱReadͷࢄ γϟʔσΟϯά: ReadͱWriteͷਫฏࢄ εέʔϥϏϦςΟ
γϯάϧϊʔυ mogngod
ϨϓϦΧηοτ delayed replica replica set
ϨϓϦΧηοτˍγϟʔσΟϯά replica set shard mongos replica set shard replica set
shard delayed replica delayed replica delayed replica mongoc
͜͜·Ͱίʔυͷมߋ ΄ͱΜͲඞཁ͋Γ·ͤΜ
Point! ͡Ί͔ΒେنͳDBΛߏ͢Δඞཁ͋Γ·ͤΜ ·ͣϛχϚϜʹ࢝ΊͯɺϏδωεͷʹ߹Θͤͯ MongoDBεέʔϧͤ͞Δ͜ͱ͕Ͱ͖·͢
ݱ࣮ͷ੍ Node.js ͱͷ૬ੑ ➡ ํ௨৴ͷͨΊʹ socket.io͕ඞਢͩͬͨ ϗεςΟϯάαʔϏεͷ༗ແ ➡ গਫ਼ӶͰαʔϏεʹूத͔ͨͬͨ͠ ӦۀͱσʔλαΠΤϯςΟετѻ͑Δ
αʔϏεʹूத͢ΔͨΊʹ ϗεςΟϯάαʔϏεΛར༻͢Δͱ͍͏ બݕ౼ͷՁ͋Γ http://www.slideshare.net/yujiosaka/starting-mongo-db-on-hosting-services
MongoDB͕ ద͞ͳ͔ͬͨέʔε
ίϨΫγϣϯͷδϣΠϯ͕Ͱ͖ͳ͍ ίϨΫγϣϯΛ·͕ͨΔ τϥϯβΫγϣϯΛཧͰ͖ͳ͍ υΩϡϝϯταΠζ͕༧ଌͰ͖ͳ͍߹ʹ σΟεΫޮ͕ѱ͍ MongoDBͷۤख
http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/
http://blog.scrapinghub.com/2013/05/13/mongo-bad-for-scraped-data/
εΩʔϚσβΠϯʹࣦഊ͍ͯ͠Δ ෳࡶͳτϥϯβΫγϣϯ͕ඞཁͳσʔλΛѻ͍ͬͯΔ υΩϡϝϯταΠζ͕༧ଌͰ͖ͳ͍ ద͞ͳ͔ͬͨཧ༝
DB୯ҐͰϩοΫ͕͔͔ΓɺCPUΛޮྑ͑͘ͳ͍ ϗοτσʔλ͕ͳ͍Α͏ͳσʔλͷཧ͕ۤख MongoDB 2.6Ҏલͷ
গ͠ා͕Βͤͯ ͠·͍·ͨ͠…
͔͠͠ɺDBͷબຊདྷ ৻ॏͰ͋Δ͖Ͱ͢
Point! MongoDB 3.0ͰMMAPv1ͷCollection Level Pluggable Storage Engine͕࣮͞Εɺগͣͭ͠ ۤखΛࠀͭͭ͋͠Γ·͢
Topics ͳͥMongoDBΛબΜͩͷ͔ Ϗδωε͕ٸʹ͢ΔཪͰɺ ͲͷΑ͏ͳʹ໘͠ɺղܾ͖͔ͯͨ͠
Ϗδωε͕ٸʹ͢ΔཪͰɺ ͲͷΑ͏ͳʹ໘͠ɺղܾ͖͔ͯͨ͠
Customer Count Total Costs 0QUJNJ[BUJPO .PSF IBSEXBSF $PTUTUPP IJHIPQUJNJ[F Changing
the Growth Formula https://www.compose.io/articles/changing-the-growth-formula/ -PXUPUBM DPTUT
Low total costs ίετɾύϑΥʔϚϯεͷͳ͘αʔϏεΛఏڙͰ͖͍ͯΔ More hardware ϏδωεͷΛࢧ͑ΔͨΊʹࢿΛ͢Δ࣌ظ Costs too high!
optimize ίετͷܯࠂ্͕͕ΓɺΞʔΩςΫνϟͷݟ͕͠ٻΊΒΕΔ Optimization ΞʔΩςΫνϟ͕ܦࡁతʹύϑΥʔϚϯεతʹ࠷దԽ͞ΕΔ ϑΣʔζ Changing the Growth Formula https://www.compose.io/articles/changing-the-growth-formula/
Customer Count Total Costs 0QUJNJ[BUJPO .PSF IBSEXBSF $PTUTUPP IJHIPQUJNJ[F Changing
the Growth Formula https://www.compose.io/articles/changing-the-growth-formula/ -PXUPUBM DPTUT
݄ؒ10ԯPV ಉ࣌ଓ5ສ ݄ؒ10TBอଘ db. ZenClerk .stats()
Economy Of Scale
ϏδωεͷʹͭΕͯ εέʔϧϝϦοτ͕͖͘
ΫϥΠΞϯτ1ࣾ͋ͨΓͷ ίετࣗવͱԼ͕͍ͬͯ͘
ඞཁͳ͜ͱεέʔϧ͢Δ γεςϜΛߏங͢Δ͜ͱ
Problem ݱ࣮ͷੈքࢥͬͨ௨Γʹ͍͔ͳ͍ͷ͕ৗͰ͋Δ
ޮԽ͠ͳ͚Ε ίετ૿͑ଓ͚ΔҰํ
Solution ϞχλϦϯά ϘτϧωοΫղফ Ծઆݕূ
MMS
͍ΫΤϦͷࢹ
ϘτϧωοΫΛݟ͚ͭͯɺ ҰͭҰͭղফ͍ͯ͘͠ https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan
ΠϯσοΫεΛνϡʔχϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan
ΠϯσοΫεΛ͞Βʹνϡʔχϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan
ৗʹϗοτσʔλΛ͏Α͏ʹҙࣝͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan
ΫΤϦΛνϡʔχϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan
ηΧϯμϦͷΫΤϦ͕͘Α͏ʹͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan
ΞοϓσʔτΛνϡʔχϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan
RedisΛͬͯόοϑΝϦϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan
తʹԠͯ͡DBΛ͚ͨΓ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan
Point! MongoDB {“key”:”value”} ͷܗࣜͰσʔλΛ ֨ೲ͢ΔͨΊɺσʔλͷ૿ՃແࢹͰ͖ͳ͍ ఆظతͳόοΫΞοϓˍআେ
ಓͳνϡʔχϯά͕ඞཁ
ۜͷؙଘࡏ͠ͳ͍ ʢ͋Δ͍͓ߴ͍ʣ
To Shard-First, Or Not to?
·ͣγϟʔσΟϯάʹ པΒͳ͍ͱ͍͏ఏҊ
Inefficiency ඇޮͳ··ͩͱ
ඇޮੑਫฏࢄ͢Δ Inefficiency Inefficiency Inefficiency
γεςϜશମΛޮԽͤ͞Δ
ͰɺͦΕҎ্ʹେͳ͜ͱ
ਖ਼͍ٕ͠ज़ Ϗδωεͷཁ݅Λຬͨ͢ Business Tech ਖ਼͍ٕ͠ज़
Throw Garbage Away, Discover New Gold
ϏδωεʹՁͷͳ͍ σʔλࣺͯͯ͠·͏
Ձͷ͋Δσʔλͷ ͨΊʹίετΛ͏
Customer Count Total Costs 1όΠτͷՁ 1όΠτͷՁ ޮԽ
Technology scales business We are hiring ;)