Introduction to MongoDB

7,673 views
7,497 views

Published on

Published in: Technology
1 Comment
11 Likes
Statistics
Notes
  • Please ignore the 'Partition balancing' mention on page 102. That is the wrong term and taken out of context could be taken wrong. More info on sharding and partition balancing: http://www.mongodb.org/display/DOCS/Sharding+Administration#ShardingAdministration-Balancing
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
7,673
On SlideShare
0
From Embeds
0
Number of Embeds
130
Actions
Shares
0
Downloads
312
Comments
1
Likes
11
Embeds 0
No embeds

No notes for slide

Introduction to MongoDB

  1. 1. MongoDBJustin Smestad@jsmestadjustin@mongomachine.com
  2. 2. whoamiSoftware Engineer (Ruby, Javascript, and Clojure)User Experience & Design on the sidePassion for DevOpsChicagoland native
  3. 3. whoamiSoftware Engineer (Ruby, Javascript, and Clojure)User Experience & Design on the sidePassion for DevOpsChicagoland native
  4. 4. whoamiSoftware Engineer (Ruby, Javascript, and Clojure)User Experience & Design on the sidePassion for DevOpsChicagoland native
  5. 5. whoamiSoftware Engineer (Ruby, Javascript, and Clojure)User Experience & Design on the sidePassion for DevOpsChicagoland native
  6. 6. BackgroundJava Engineer @ Orbitz Worldwide Brought Ruby and RSpec/Cucumber to replace Fitness TestingApplication Developer @ Factory Design Labs Brand & Campaign sites for Audi, Oakley, and TNFIndependent Contractor Development team for TechStars alumni
  7. 7. BackgroundJava Engineer @ Orbitz Worldwide Brought Ruby and RSpec/Cucumber to replace Fitness TestingApplication Developer @ Factory Design Labs Brand & Campaign sites for Audi, Oakley, and TNFIndependent Contractor Development team for TechStars alumni
  8. 8. BackgroundJava Engineer @ Orbitz Worldwide Brought Ruby and RSpec/Cucumber to replace Fitness TestingApplication Developer @ Factory Design Labs Brand & Campaign sites for Audi, Oakley, and TNFIndependent Contractor Development team for TechStars alumni
  9. 9. mongo machine hosted MongoDB wherever you need it
  10. 10. What’s mongo machine ?
  11. 11. mongo machine hosted MongoDB + data management http://mongomachine.com
  12. 12. mongo machine hosted MongoDB + data managementOur Goals Educate and promote best practices Increase customer efficiency Promote transparency
  13. 13. Our Product
  14. 14. Hosted MongoDBProvide the best managed MongoDBexperience, on any platform.
  15. 15. mongo machine hosted MongoDB + data managementManaged MongoDB Infrastructure Our infrastructure on AWS or Rackspace Automated Deployments to your own infrastructureManagement Console Instantly create new databases Track database trends Scale up & down on-demand
  16. 16. Management ConsoleAnalytics data about what your DB is doing.
  17. 17. Management ConsoleAnalytics data about what your DB is doing.
  18. 18. “NoSQL”hasn’t this been tried before?why should I care now?
  19. 19. So what is MongoDB? (10,000ft view)
  20. 20. MongoDB (from "humongous") is ascalable, high-performance, open source, schema-free, document-oriented database. -- mongodb.org
  21. 21. Who is using MongoDB?
  22. 22. Fortune 500 <=> Startups
  23. 23. GithubBug Tracking & Analytics
  24. 24. FoursquareCheck-in System
  25. 25. New York Times Photo Submissions
  26. 26. The list is large and growing fasthttp://www.mongodb.org/display/DOCS/Production+Deployments
  27. 27. Philosophy
  28. 28. Philosophy “One size DOESN’T fit”
  29. 29. Philosophy Non-relational (de-normalized) DBs are easier to scale, especially horizontally
  30. 30. Philosophy DBs should be an on-demand commodity (cloud-like)
  31. 31. Philosophy Focus on performance, flexibility and scalability (CA)
  32. 32. Philosophy Not concerned with transactional stuff or relational semantics
  33. 33. PhilosophyMongo aims for theperformance of key-value stores whilemaintainingfunctionality oftraditional RDBMS
  34. 34. Features
  35. 35. FeaturesStandard database stuff Indexing Traditional master-slave Database References (no concept of JOINS)
  36. 36. FeaturesStandard database stuff Indexing Traditional master-slave Database References (no concept of JOINS)
  37. 37. FeaturesStandard database stuff Indexing Traditional master-slave Database References (no concept of JOINS)
  38. 38. FeaturesStandard database stuff Indexing Traditional master-slave Database References (no concept of JOINS)
  39. 39. FeaturesSpeedin-memory dataset with fsync to disk
  40. 40. FeaturesDurabilitysolve with replication, or use journaling
  41. 41. FeaturesDocument-oriented database
  42. 42. Features: Document Storage Documents are stored in BSON (binary JSON)
  43. 43. Features: Document Storage BSON is a binary serialization of JSON-like objects
  44. 44. Features: Document Storage Large BSON documents are served in chunks (GridFS)
  45. 45. Features: Document Storage This is extremely powerful, b/c it means mongo understands JSON natively
  46. 46. Features: Document Storage Any valid JSON can be easily imported and queried
  47. 47. Features: Document Storage Documents can contain embedded documents (nested hashes) without losing any indexing capabilities.
  48. 48. FeaturesSchema-less; very flexibleno more blocking ALTER TABLE or NULL debates
  49. 49. FeaturesReplica Sets and Sharding make horizontal scaling easy.
  50. 50. Features: Replica Set Traditional Master-Slave, but automatic failover Each server holds all data (CA) One is elected master at a given time Arbitration process detects failover New election within seconds
  51. 51. Features: Replica Set Traditional Master-Slave, but automatic failover Each server holds all data (CA) One is elected master at a given time Arbitration process detects failover New election within seconds
  52. 52. Features: Replica Set Traditional Master-Slave, but automatic failover Each server holds all data (CA) One is elected master at a given time Arbitration process detects failover New election within seconds
  53. 53. Features: Replica Set Traditional Master-Slave, but automatic failover Each server holds all data (CA) One is elected master at a given time Arbitration process detects failover New election within seconds
  54. 54. Features: Replica Set Traditional Master-Slave, but automatic failover Each server holds all data (CA) One is elected master at a given time Arbitration process detects failover New election within seconds
  55. 55. FeaturesMap/ReduceMap Reduce operations are written in Javascript.
  56. 56. Features: QueryingRich, javascript-based query syntax Allows us to do deep, nested queries
  57. 57. Features: QueryingRich, javascript-based query syntax Allows us to do deep, nested queries
  58. 58. Features: QueryingRich, javascript-based query syntax Allows us to do deep, nested queries db.order.find( { shipping: { carrier: "usps" } } );
  59. 59. Features: QueryingRich, javascript-based query syntax Allows us to do deep, nested queries db.order.find( { shipping: { carrier: "usps" } } ); shipping is an embedded document (object)
  60. 60. Featuresatomic operationsupserts, $set, $inc, $push, $pull, $pop, $addToSet, ...
  61. 61. Features Official Drivers .NET, Java, Javascript, Ruby, Node.js, PHP, Haskell, C/C++, Perl
  62. 62. Features Community & Market Growth MongoDB works alongside your existing technologies
  63. 63. Concepts
  64. 64. Concepts: Document-oriented Think of “documents” as objects / database records
  65. 65. Concepts: Document-oriented Think of “documents” as objects / database records Documents are basically just JSON in binary
  66. 66. Concept: Document-oriented Think of “documents” as objects / database records Documents are basically just JSON in binary Ability to store information all together
  67. 67. Concept MappingRDBMS (mysql, postgres) MongoDB Tables Collections
  68. 68. Concept MappingRDBMS (mysql, postgres) MongoDB Tables Collections Records/rows Documents/objects
  69. 69. Concept MappingRDBMS (mysql, postgres) MongoDB Tables Collections Records/rows Documents/objects Queries return record(s) Queries return a cursor
  70. 70. Concept MappingRDBMS (mysql, postgres) MongoDB Tables Collections Records/rows Documents/objectsQueries return record(s) Queries return a cursor ???
  71. 71. Concepts: CursorsQueries return “cursors” instead of collections
  72. 72. Concepts: CursorsQueries return “cursors” instead of collections A cursor allows you to iterate through the result set
  73. 73. Concepts: CursorsQueries return “cursors” instead of collections A cursor allows you to iterate through the result set A big reason for this is performance
  74. 74. Concepts: CursorsQueries return “cursors” instead of collections A cursor allows you to iterate through the result set A big reason for this is performance Much more efficient than loading all objects into memory
  75. 75. Concepts: CursorsThe find() function returns a cursor object
  76. 76. Concepts: CursorsThe find() function returns a cursor object var cursor = db.logged_requests.find({ status_code : 200 }) cursor.hasNext() // "true" cursor.forEach( function(item) { print(tojson(item)) } ); cursor.hasNext() // "false"
  77. 77. Cool Features
  78. 78. Cool FeaturesCapped collections Fixed-sized, limited operation, auto-LRU age-out collections Fixed insertion order Extremely performant Ideal for logging and caching
  79. 79. Cool FeaturesCapped collections Fixed-sized, limited operation, auto-LRU age-out collections Fixed insertion order Extremely performant Ideal for logging and caching
  80. 80. Cool FeaturesCapped collections Fixed-sized, limited operation, auto-LRU age-out collections Fixed insertion order Extremely performant Ideal for logging and caching
  81. 81. Cool FeaturesCapped collections Fixed-sized, limited operation, auto-LRU age-out collections Fixed insertion order Extremely performant Ideal for logging and caching
  82. 82. Cool FeaturesCapped collections Fixed-sized, limited operation, auto-LRU age-out collections Fixed insertion order Extremely performant Ideal for logging and caching
  83. 83. Use Cases
  84. 84. Use CasesData Warehouse Mongo understands JSON natively Very powerful map-reduce for analytics Nested hashes make roll-up (RRDtool) systems natural
  85. 85. Use CasesData Warehouse Mongo understands JSON natively Very powerful map-reduce for analytics Nested hashes make roll-up (RRDtool) systems natural
  86. 86. Use CasesData Warehouse Mongo understands JSON natively Very powerful map-reduce for analytics Nested hashes make roll-up (RRDtool) systems natural
  87. 87. Use CasesData Warehouse Mongo understands JSON natively Very powerful map-reduce for analytics Nested hashes make roll-up (RRDtool) systems natural
  88. 88. Use CasesAudit Trails Nested documents allow you to store audit trails in context.
  89. 89. Use CasesAudit Trails Nested documents allow you to store audit trails in context. { ‘name’: ‘Justin Smestad’, ‘address’: ‘1441 Central St’, ‘history’: [ { ‘name’: ‘Justin Smestad’, ‘address’: ‘350 S Jackson St’ },....] }
  90. 90. Limitations
  91. 91. Limitations Transaction support Relational integrity (normalization) Partition balancing Map / Reduce is single threaded Data compaction
  92. 92. Limitations Transaction support Relational integrity (normalization) Partition balancing Map / Reduce is single threaded Data compaction
  93. 93. Limitations Transaction support Relational integrity (normalization) Partition balancing Map / Reduce is single threaded Data compaction
  94. 94. Limitations Transaction support Relational integrity (normalization) Partition balancing Map / Reduce is single threaded Data compaction
  95. 95. Limitations Transaction support Relational integrity (normalization) Partition balancing Map / Reduce is single threaded Data compaction
  96. 96. Why not `other db` ?CouchDB, Cassandra, Riak, Membase, Redis, ...
  97. 97. Why not `other db`? FLEXIBILITY MongoDB’s design choices empower developers and administrators with features that allow you to implement their own solutions. *
  98. 98. Questions?@jsmestad / @mongo_machine

×