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
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
390
ゼロから創る横断SREチーム 挑戦と進化の軌跡
rvirus0817
2
260
10個のフィルタをAXI4-Streamでつなげてみた
marsee101
0
160
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
150
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
190
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
180
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
180
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
520
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
530
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
150
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1366
200k
Designing for humans not robots
tammielis
250
25k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Site-Speed That Sticks
csswizardry
2
190
How STYLIGHT went responsive
nonsquared
95
5.2k
GitHub's CSS Performance
jonrohan
1030
460k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Code Reviewing Like a Champion
maltzj
520
39k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Side Projects
sachag
452
42k
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 ;)