Save 37% off PRO during our Black Friday Sale! »

technology x business

technology x business

db tech showcase Tokyo 2015

5d247ff63b1861db5e6a56d4990e5a4f?s=128

yujiosaka

June 10, 2015
Tweet

Transcript

  1. MongoDB x Business db tech showcase Tokyo 2015 Yuji Isobe

  2. Profile Yuji Isobe Play fiddle/violin Engineer Contribute to socket.io Startup

    member of emin
  3. emin = Emotion Intelligence ؾ࣋ͪΛղ͢ΔςΫϊϩδʔͷ୳ڀ Emotion Intelligence͸ɺʮແҙࣝͷߦಈ͔Βɺ ਓͷؾ࣋ͪͷػඍΛղ͢Δ஌ੑʯΛɺਓ޻஌ೳ͓Αͼػցֶ शͷԠ༻ٕज़Λ༻͍ͯ ։ൃ͠ɺϏδωεʹԠ༻͍ͯ͠·͢ɻ

  4. ;FO$MFSL ౰͕ࣾ։ൃͨ͠༧ଌΤϯδϯʮ&NPUJPO*0ʯ͕ɺ΢Σϒα Πτ্ͷϢʔβʔͷແҙࣝͷߦಈΛϦΞϧλΠϜͰݕ஌ɺղ ੳ͠·͢ɻϢʔβʔͷߪങߦಈʹ͓͚Δ໎͍Λ࡯஌͠ɺ࠷ద ͳλΠϛϯάͰΦϑΝʔΛఏࣔ͢ΔʮίϯόʔδϣϯɾΦϓ ςΟϚΠβʔʯ͕ɺ&$αΠτͷ$73Λ࠷దԽ͠·͢ɻ

  5. ͳͥdb tech showcaseͰ
 Ϗδωε͕ςʔϚͳͷ͔ʁ

  6. ਖ਼͍ٕ͠ज़͸
 Ϗδωεͷཁ݅Λຬͨ͢ Α͘ड͚Δ૬ஊ □□࢖Θͳ͍ͷʁ ˚˚͕ͭΒ͍ ××࢖ͬͯΔ͚Ͳ ͜ͷ··Ͱ͍͍ͷ͔ͳ ◦◦ͬͯͲ͏ࢥ͏ʁ ٕज़ͳΜͯԿ࢖ͬͯ΋
 ҰॹͰ͠ΐʁͬͯݴΘΕͨ


    Μ͚ͩͲͲ͏͢Ε͹…
  7. ਖ਼͍ٕ͠ज़͸
 Ϗδωεͷཁ݅Λຬͨ͢ Business Tech ਖ਼͍ٕ͠ज़

  8. Business ؒҧٕͬͨज़ Tech ؒҧٕͬͨज़Λબ୒͢Δͱ
 Ϗδωε͸੒ޭ͠ͳ͍

  9. Business Tech εέʔϧ͠ͳ͍ٕज़ εέʔϧ͠ͳ͍ٕज़͸
 Ϗδωεͷ଍͔ͤʹͳΔ

  10. Business Tech ίετ͕ߴ͍ٕज़ ίετ͕ߴ͗͢Δٕज़͸ ϏδωεΛ৯͍ͭͿ͢

  11. Business Tech εέʔϧ͢Δਖ਼͍ٕ͠ज़ εέʔϧ͢Δٕज़͸
 ϏδωεΛՃ଎ͤ͞Δ

  12. ಛʹDB͸ޙ͔Βมߋ͕
 ͳ͔ͳ͔Ͱ͖·ͤΜ

  13. NoSQL͸దࡐదॴ

  14. ͦΕ͸MongoDB΋
 ྫ֎Ͱ͸͋Γ·ͤΜ

  15. 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
  16. ͜ͷਤʹ͸ͳ͍͜ͱ͕
 ݱ࣮Ͱ͸໰୊ʹͳΓ·͢

  17. Ϗδωεͷࢹ఺͕·͢·͢
 ॏཁʹͳ͖͍ͬͯͯ·͢

  18. ҰͭͷϢʔεέʔεΛ঺հ͢Δ͚ͩͰ͸ͳ͘
 ৽ͨͳ໰୊ʹ௚໘ͨ࣌͠ʹ΋ղܾʹ໾ཱͯΒΕΔ Goal

  19. Topics ͳͥMongoDBΛબΜͩͷ͔ Ϗδωε͕ٸ଎ʹ੒௕͢ΔཪͰɺ
 ͲͷΑ͏ͳ໰୊ʹ௚໘͠ɺղܾ͖͔ͯͨ͠

  20. ͳͥMongoDBΛબΜͩͷ͔

  21. ͦͷલʹ

  22. ࢲͨͪ͸໨తʹԠͯ͡
 DBΛ࢖͍෼͚͍ͯ·͢

  23. redis : ϦΞϧλΠϜσʔλ MongoDB : ෼ੳ༻ϩάσʔλ MySQL : ϚελʔσʔλˍϨϙʔτ ࢖༻͍ͯ͠ΔDB

  24. redis : ϦΞϧλΠϜσʔλ MongoDB : ෼ੳ༻ϩάσʔλ MySQL : ϚελʔσʔλˍϨϙʔτ ࢖༻͍ͯ͠ΔDB

  25. $PVDI%# )#"4& DBTTBOESB 3೥લʹൺֱݕ౼ͨ͠DB ࠓͳΒ Amazon DynamoDB͋ͨΓ΋ݕ౼ʹೖΓͦ͏

  26. ͳͥMongoDBΛબΜͩͷ͔ ߏ଄Խσʔλ εΩ ʔ Ϛ Ϩε εέ ʔ ϥ Ϗ

    Ϧ ς Ο Ϗδωε
 ϓϩηε
  27. Ϗδωεϓϩηε ϦΞϧλΠϜ෼ੳ Ωϟϯϖʔϯ഑৴ σʔλϚΠχϯά Ϟσϧߏங ຊ൪౤ೖ σʔλ஝ੵ

  28. Garbage In,
 Garbage Out

  29. ΰϛΛ෼ੳͯ͠΋
 ΰϛ͕ฦͬͯ͘Δ͚ͩ

  30. σʔλͷՁ஋Λ
 ߴΊΔϓϩηεΛ࡞Δ

  31. ߏ଄Խσʔλ db.events.insert({
 event: “touch”,
 touches: [
 {pageX: 150, pageY: 100,

    …},
 {pageX: 47, pageY: 171, …}
 ],
 touchCount: 2 }); db.events.createIndex({
 event: 1
 }); ߦྻʹറΒΕͳ͍
 σʔλߏ଄ΛදݱͰ͖Δ ݕࡧ͍ͨ͠ϑΟʔϧυʹ
 ࣗ༝ʹΠϯσοΫε͕
 షΕΔ͜ͱ͕େ͖ͳڧΈ
  32. Point! MongoDB͸RDBMSͱࣅͨΠϯσοΫεߏ଄Λ
 ͍࣋ͬͯΔͷͰɺRDBͷ஌ࣝΛੜ͔͢͜ͱ͕Ͱ͖·͢ B-Tree, Compound Index, Covered Index, etc.

  33. εΩʔϚϨε db.events.insert({
 event: “touch”,
 touches: [
 {pageX: 150, pageY: 100,

    …},
 {pageX: 47, pageY: 171, …}
 ],
 // delete
 touchCount: 2,
 // new
 orientation: -90,
 touchStart: new Date(),
 … }); औಘ͍ͨ͠σʔλ͸
 ೔ʑมԽ͍͖ͯ͠·͢ RDBͷڧΈͰ͋Δ͸ͣͷ
 εΩʔϚ͕ɺϏδωεͷ
 ଍͔ͤʹͳͬͯ͠·͏
  34. Point! ʰεΩʔϚϨε≠εΩʔϚఆ͕ٛෆཁʱͰ͸͋Γ·ͤΜ
 Ή͠ΖɺεΩʔϚϨεͰ͋Δ͔Βͦ͜ɺ
 εΩʔϚఆ͕ٛͱͯ΋ॏཁͰ͢

  35. https://www.mongodb.com/presentations/schema-design-scale-1

  36. ϨϓϦΧηοτ: ৑௕ੑͷ֬อͱReadͷ෼ࢄ γϟʔσΟϯά: ReadͱWriteͷਫฏ෼ࢄ εέʔϥϏϦςΟ

  37. γϯάϧϊʔυ mogngod

  38. ϨϓϦΧηοτ delayed replica replica set

  39. ϨϓϦΧηοτˍγϟʔσΟϯά replica set shard mongos replica set shard replica set

    shard delayed replica delayed replica delayed replica mongoc
  40. ͜͜·Ͱίʔυͷมߋ͸
 ΄ͱΜͲඞཁ͋Γ·ͤΜ

  41. Point! ͸͡Ί͔Βେن໛ͳDBΛߏ੒͢Δඞཁ͸͋Γ·ͤΜ
 ·ͣ͸ϛχϚϜʹ࢝ΊͯɺϏδωεͷ੒௕ʹ߹Θͤͯ
 MongoDB΋εέʔϧͤ͞Δ͜ͱ͕Ͱ͖·͢

  42. ݱ࣮ͷ੍໿ Node.js ͱͷ૬ੑ ➡ ૒ํ޲௨৴ͷͨΊʹ socket.io͕ඞਢͩͬͨ ϗεςΟϯάαʔϏεͷ༗ແ ➡ গ਺ਫ਼ӶͰαʔϏεʹूத͔ͨͬͨ͠ ӦۀͱσʔλαΠΤϯςΟετ΋ѻ͑Δ

  43. αʔϏεʹूத͢ΔͨΊʹ ϗεςΟϯάαʔϏεΛར༻͢Δͱ͍͏
 બ୒͸ݕ౼ͷՁ஋͋Γ http://www.slideshare.net/yujiosaka/starting-mongo-db-on-hosting-services

  44. MongoDB͕
 ద͞ͳ͔ͬͨέʔε

  45. ίϨΫγϣϯͷδϣΠϯ͕Ͱ͖ͳ͍ ίϨΫγϣϯΛ·͕ͨΔ
 τϥϯβΫγϣϯΛ؅ཧͰ͖ͳ͍ υΩϡϝϯταΠζ͕༧ଌͰ͖ͳ͍৔߹ʹ
 σΟεΫޮ཰͕ѱ͍ MongoDBͷۤख෼໺

  46. http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/

  47. http://blog.scrapinghub.com/2013/05/13/mongo-bad-for-scraped-data/

  48. εΩʔϚσβΠϯʹࣦഊ͍ͯ͠Δ ෳࡶͳτϥϯβΫγϣϯ͕ඞཁͳσʔλΛѻ͍ͬͯΔ υΩϡϝϯταΠζ͕༧ଌͰ͖ͳ͍ ద͞ͳ͔ͬͨཧ༝

  49. DB୯ҐͰϩοΫ͕͔͔ΓɺCPUΛޮ཰ྑ͘࢖͑ͳ͍ ϗοτσʔλ͕ͳ͍Α͏ͳσʔλͷ؅ཧ͕ۤख MongoDB 2.6Ҏલͷ໰୊

  50. গ͠ා͕Βͤͯ
 ͠·͍·ͨ͠…

  51. ͔͠͠ɺDBͷબ୒͸ຊདྷ
 ৻ॏͰ͋Δ΂͖Ͱ͢

  52. Point! MongoDB 3.0Ͱ͸MMAPv1ͷCollection Level΍
 Pluggable Storage Engine͕࣮૷͞Εɺগͣͭ͠
 ۤख෼໺Λࠀ෰ͭͭ͋͠Γ·͢

  53. Topics ͳͥMongoDBΛબΜͩͷ͔ Ϗδωε͕ٸ଎ʹ੒௕͢ΔཪͰɺ
 ͲͷΑ͏ͳ໰୊ʹ௚໘͠ɺղܾ͖͔ͯͨ͠

  54. Ϗδωε͕ٸ଎ʹ੒௕͢ΔཪͰɺ
 ͲͷΑ͏ͳ໰୊ʹ௚໘͠ɺղܾ͖͔ͯͨ͠

  55. 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
  56. Low total costs
 ίετɾύϑΥʔϚϯεͷ໰୊΋ͳ͘αʔϏεΛఏڙͰ͖͍ͯΔ More hardware
 Ϗδωεͷ੒௕Λࢧ͑ΔͨΊʹ౤ࢿΛ͢Δ࣌ظ Costs too high!

    optimize
 ίετ΁ͷܯࠂ্͕͕ΓɺΞʔΩςΫνϟͷݟ௚͕͠ٻΊΒΕΔ Optimization
 ΞʔΩςΫνϟ͕ܦࡁతʹ΋ύϑΥʔϚϯεతʹ΋࠷దԽ͞ΕΔ ϑΣʔζ Changing the Growth Formula https://www.compose.io/articles/changing-the-growth-formula/
  57. 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
  58. ݄ؒ10ԯPV ಉ࣌઀ଓ਺5ສ ݄ؒ10TBอଘ db. ZenClerk .stats()

  59. Economy Of Scale

  60. Ϗδωεͷ੒௕ʹͭΕͯ
 εέʔϧϝϦοτ͕͖͘

  61. ΫϥΠΞϯτ1ࣾ͋ͨΓͷ
 ίετ͸ࣗવͱԼ͕͍ͬͯ͘

  62. ඞཁͳ͜ͱ͸εέʔϧ͢Δ
 γεςϜΛߏங͢Δ͜ͱ

  63. Problem ݱ࣮ͷੈք͸ࢥͬͨ௨Γʹ͍͔ͳ͍ͷ͕ৗͰ͋Δ

  64. ޮ཰Խ͠ͳ͚Ε͹
 ίετ͸૿͑ଓ͚ΔҰํ

  65. Solution ϞχλϦϯά ϘτϧωοΫղফ Ծઆݕূ

  66. MMS

  67. ஗͍ΫΤϦͷ؂ࢹ

  68. ϘτϧωοΫΛݟ͚ͭͯɺ
 ҰͭҰͭղফ͍ͯ͘͠ https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan

  69. ΠϯσοΫεΛνϡʔχϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan

  70. ΠϯσοΫεΛ͞Βʹνϡʔχϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan

  71. ৗʹϗοτσʔλΛ࢖͏Α͏ʹҙࣝͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan

  72. ΫΤϦΛνϡʔχϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan

  73. ηΧϯμϦ΁ͷΫΤϦ͕޲͘Α͏ʹͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan

  74. ΞοϓσʔτΛνϡʔχϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan

  75. RedisΛ࢖ͬͯόοϑΝϦϯάͨ͠Γ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan

  76. ໨తʹԠͯ͡DBΛ෼͚ͨΓ… https://speakerdeck.com/yujiosaka/yue-jian-10yi-pvkaraxue-ndamongodbantipatan

  77. Point! MongoDB͸ {“key”:”value”} ͷܗࣜͰσʔλΛ
 ֨ೲ͢ΔͨΊɺσʔλͷ૿Ճ΋ແࢹͰ͖ͳ͍ ఆظతͳόοΫΞοϓˍ࡟আ΋େ੾

  78. ஍ಓͳνϡʔχϯά͕ඞཁ

  79. ۜͷ஄ؙ͸ଘࡏ͠ͳ͍ ʢ͋Δ͍͸͓ߴ͍ʣ

  80. To Shard-First, Or Not to?

  81. ·ͣ͸γϟʔσΟϯάʹ
 པΒͳ͍ͱ͍͏ఏҊ

  82. Inefficiency ඇޮ཰ͳ··ͩͱ

  83. ඇޮ཰ੑ΋ਫฏ෼ࢄ͢Δ Inefficiency Inefficiency Inefficiency

  84. γεςϜશମΛޮ཰Խͤ͞Δ

  85. Ͱ΋ɺͦΕҎ্ʹେ੾ͳ͜ͱ

  86. ਖ਼͍ٕ͠ज़͸
 Ϗδωεͷཁ݅Λຬͨ͢ Business Tech ਖ਼͍ٕ͠ज़

  87. Throw Garbage Away, Discover New Gold

  88. ϏδωεʹՁ஋ͷͳ͍
 σʔλ͸ࣺͯͯ͠·͏

  89. Ձ஋ͷ͋Δσʔλͷ
 ͨΊʹίετΛ෷͏

  90. Customer Count Total Costs 1όΠτͷՁ஋ 1όΠτͷՁ஋ ޮ཰Խ

  91. Technology scales business We are hiring ;)