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
210
Machine Learning with JavaScript
yujiosaka
0
150
JavaScriptでも機械学習がやりたかった話
yujiosaka
2
420
ヘッドレスChromeでクローラを作った後の話
yujiosaka
3
600
俺が最初にヘッドレス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
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
1
110
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
Platform Engineering for Software Developers and Architects
syntasso
1
520
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
アジャイルチームがらしさを発揮するための目標づくり / Making the goal and enabling the team
kakehashi
3
140
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
3
630
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
660
FlutterアプリにおけるSLI/SLOを用いたユーザー体験の可視化と計測基盤構築
ostk0069
0
100
Flutterによる 効率的なAndroid・iOS・Webアプリケーション開発の事例
recruitengineers
PRO
0
120
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
AIチャットボット開発への生成AI活用
ryomrt
0
170
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
230
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Building Adaptive Systems
keathley
38
2.3k
Why Our Code Smells
bkeepers
PRO
334
57k
What's in a price? How to price your products and services
michaelherold
243
12k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Adopting Sorbet at Scale
ufuk
73
9.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
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 ;)