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
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
5
610
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
170
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
130
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
380
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.6k
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.2k
隣接領域をBeyondするFinatextのエンジニア組織設計 / beyond-engineering-areas
stajima
1
270
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.8k
Featured
See All Featured
Music & Morning Musume
bryan
46
6.2k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Designing for humans not robots
tammielis
250
25k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building Your Own Lightsaber
phodgson
103
6.1k
Why Our Code Smells
bkeepers
PRO
334
57k
Gamification - CAS2011
davidbonilla
80
5k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
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 ;)