Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MongoDB - Riviera Dev 2018

38 views

Published on

MongoDB Deep Dive conférence at Riviera Dev 2018

Published in: Technology
  • Be the first to comment

  • Be the first to like this

MongoDB - Riviera Dev 2018

  1. 1. Creating scalable, resilient applications with MongoDB
  2. 2. 4 Battle Plan Intro • Presentation MongoDB – NoSQL – BigData – JSON/BSON – CRUD – Indexes – Replica Set – Read Preference – Write Concern – Read Concern • Presentation Mongo-IOT Project • Live coding mongo-iot server on localhost
  3. 3. 5 Battle Plan Cloud • Presentation MongoDB Atlas • Migrate to Atlas • Presentation Sharded Cluster • Migrate mongo-iot to AWS with VPC • Start generator • Real Time graphs and metrics in Atlas
  4. 4. 6 Battle Plan - MongoDB 3.6 • MongoDB Compass • Aggregation Framework in Compass • Demo 3.6 – Retryable Writes – Causal Consistency – Change Streams • Live coding analyser with change streams • Deploy analyser on AWS • Live coding alert-manager • Deploy alert-manager on AWS and Slack
  5. 5. 7 Battle Plan More • MongoDB Stitch • MongoDB 4.0 : Multi-document ACID Transactions.
  6. 6. 8 Document Model { first_name: ‘Paul’, surname: ‘Miller’, city: ‘London’, location: { type : ‘Point’, coordinates : [45.123,47.232] }, cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } MongoDB RDBMS
  7. 7. 9 Developer Agility - Documents { first_name: ‘Paul’, surname: ‘Miller’, ID: 125678, city: ‘London’, location: { type : ‘Point’, coordinates : [45.123,47.232] }, Profession: [‘banking’, ‘finance’, ‘trader’], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } Fields can contain an array of sub-documents Typed field values Fields can contain arrays String Number Geo-Location Fields
  8. 8. 10 Developer Agility – Flexible Schema { product_name: ‘Acme Paint’, sku: "123-567-845", color: [‘Red’, ‘Green’], size_oz: [8, 32], finish: [‘satin’, ‘eggshell’] } { product_name: ‘T-shirt’, sku : "123-589-234", size: [‘S’, ‘M’, ‘L’, ‘XL’], color: [‘Heather Gray’ … ], material: ‘100% cotton’, wash: ‘cold’, dry: ‘tumble dry low’ } { product_name: ‘Mountain Bike’, sku : "143-534-678", brake_style: ‘mechanical disc’, color: ‘grey’, frame_material: ‘aluminum’, no_speeds: 21, package_height: ‘7.5x32.9x55’, weight_lbs: 44.05, suspension_type: ‘dual’, wheel_size_in: 26 }
  9. 9. 11 CRUD & Indexes
  10. 10. 12 Developer Agility – Use Your Favourites Page 12 Morphia MEAN Stack
  11. 11. 13 Replica Set – Durability • Replica set – 2 to 50 copies • Replica sets make up a self-healing ‘shard’ • Data center awareness • Replica sets address: • High availability • Data durability, consistency • Maintenance (e.g., HW swaps) • Disaster Recovery Application Driver Primary Secondary Secondary Replication
  12. 12. 14 High Availability and Data Durability – Replica Sets SecondarySecondary Primary
  13. 13. 15 Replica Set Creation SecondarySecondary Primary Heartbeat
  14. 14. 16 Replica Set Node Failure SecondarySecondary Primary No Heartbeat
  15. 15. 17 Replica Set Recovery SecondarySecondary Heartbeat And Election
  16. 16. 18 New Replica Set – 2 Nodes SecondaryPrimary Heartbeat And New Primary
  17. 17. 19 Replica Set Repair SecondaryPrimary Secondary Rejoin and resync
  18. 18. 20 Replica Set Stable SecondaryPrimary Secondary Heartbeat
  19. 19. 21 Strong Consistency SecondarySecondary Primary Client Application Client Driver Write Read
  20. 20. 22 Eventual Consistency SecondarySecondary Primary Client Application Client Driver Write Read Read
  21. 21. Developing with MongoDB Application Driver mongod /data
  22. 22. Replica Set with MongoDB Application Driver Primary /data Secondary /data Secondary /data
  23. 23. 25 Replica Set Read Preference Write Concern Read Concern
  24. 24. 26 Mongo-IOT
  25. 25. MongoDB Atlas
  26. 26. 28 Operational Agility – Atlas - Database as a Service Self-service, elastic, and automated Secure by defaultGlobal and highly available Continuous backups Real-time monitoring and optimization Cloud agnostic
  27. 27. Aggregation Framework
  28. 28. 30 Developer Agility – The Aggregation Framework
  29. 29. 31 Developer Agility – Compass – MongoDB GUI Page 31 Debug & Optimize Visualize & Explore Insert, Modify, & Delete
  30. 30. Sharded Cluster
  31. 31. 33 Replica Set Bottlenecks Application Driver Primary /data Secondary /data Secondary /data RAM Limits on single server CPU Limits on single server Network Bandwidth Disk I/O
  32. 32. 34 Reasons to Shard Performance Data locality Recovery Time Objective (RTO)
  33. 33. 35 Construction • Build Cluster • Identify shard key • Sharding happens on individual collections • To shard a collection: sh.shardcollections( "MUGS.members",{ "members.member_id" : 1 } )
  34. 34. 36 What Is Sharding? Application mongos mongos mongos Driver
  35. 35. 37 But There is More Application mongos mongos mongos Driver Config Server
  36. 36. 38 Chunk is a Section on the Range
  37. 37. 39 Chunk Splitting
  38. 38. 40 How Data Is Distributed • Initially 1 chunk • Default max chunk size: 64mb • MongoDB automatically splits & migrates chunks when max reached Shard 1 Shard 2
  39. 39. 41 Balancing The Cluster Shard 1 Shard 2 MongosMongosMongos Primary Config Server
  40. 40. 42 Moving The Chunk Shard 1 Shard 2 Mongos Primary Config Server
  41. 41. 43 Commiting The Migration Shard 1 Shard 2 Mongos Primary Config Server
  42. 42. 44 Clean Up Shard 1 Shard 2 Mongos Primary Config Server
  43. 43. 45 Demo!
  44. 44. 46 Conclusion @MBeugnet MaBeuLux88
  45. 45. 47 Community is awesome! https://mongo-db.slack.com https://mongodb.influitive.com/
  46. 46. 48 MongoDB Events MongoDB .local Paris

×