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
200
Machine Learning with JavaScript
yujiosaka
0
150
JavaScriptでも機械学習がやりたかった話
yujiosaka
2
410
ヘッドレス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
850
Other Decks in Technology
See All in Technology
プロダクト成長に対応するプラットフォーム戦略:Authleteによる共通認証基盤の移行事例 / Building an authentication platform using Authlete and AWS
kakehashi
1
170
LINEヤフー株式会社における音声言語情報処理AI研究開発@SP/SLP研究会 2024.10.22
lycorptech_jp
PRO
2
200
AWS CDKでデータリストアの運用、どのように設計する?~Aurora・EFSの実践事例を紹介~/aws-cdk-data-restore-aurora-efs
mhrtech
4
710
君は隠しイベントを見つけれるか?
mujyun
0
360
10分でわかるfreee エンジニア向け会社説明資料
freee
18
520k
FREE Webinar: GeoServer 2.26.0 and Beyond
simboss
PRO
0
130
ガバメントクラウド先行事業中間報告を読み解く
sugiim
1
1.7k
来年もre:Invent2024 に行きたいあなたへ - “集中”と“つながり”で楽しむ -
ny7760
0
540
物価高なラスベガスでの過ごし方
zakky
0
450
生成AIとAWS CDKで実現! 自社ブログレビューの効率化
ymae
2
400
チームを主語にしてみる / Making "Team" the Subject
ar_tama
4
330
Datachain会社紹介資料(2024年11月) / Company Deck
datachain
4
16k
Featured
See All Featured
How to Ace a Technical Interview
jacobian
275
23k
Navigating Team Friction
lara
183
14k
Learning to Love Humans: Emotional Interface Design
aarron
272
40k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Building Adaptive Systems
keathley
38
2.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
1.9k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Teambox: Starting and Learning
jrom
132
8.7k
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 ;)