Roger Bodamer @rogerb
Baseball
World Series
Giants lead 3-1 over Rangers
What is MongoDB?
quick introduction
design session
deploy mongodb
scaling
MongoDB adoption is very strong
90,000
Database
downloads
per month
Over 1,000 Production
Deployments
Platform and Language support
MongoDB is Implemented in C++ for best performance
Platforms 32/64 bit
• Windows
• Linux, Ma...
Platform and Language support
MongoDB is Implemented in C++ for best performance
Platforms 32/64 bit
• Windows
• Linux, Ma...
non-­‐relational,	
  next-­‐generation	
  
operational	
  datastores	
  and	
  databases
NoSQL Really
Means:
RDBMS
(Oracle,	
  MySQL)
RDBMS
(Oracle,	
  MySQL)
New Gen.
OLAP
(vertica,	
  aster,	
  
greenplum)
RDBMS
(Oracle,	
  MySQL)
New Gen.
OLAP
(vertica,	
  aster,	
  
greenplum)
Non-relational
Operational
Stores
(“NoSQL”)
Philosophy:	
  maximize	
  features	
  -­‐	
  up	
  to	
  the	
  “knee”	
  in	
  the	
  curve,	
  then	
  stop
depth	
  of...
Horizontally Scalable
Architectures
no	
  joins
no	
  complex	
  transactions+
New Data Models
no	
  joins
no	
  complex	
  transactions+
Improved ways to develop
New Data Models
-­‐>	
  
Terminology
RDBMS MongoDB
Table Collection
Row(s) JSON	
  Document
Index Index
Join Embedding	
  &	
  Linking
Partition Sh...
MongoDB Design Session
MongoDB Design Session
Blog Post Document
	
  p	
  =	
  {author:	
  “roger”,
	
  	
  	
  	
  	
  	
  	
  	
  date:	
  new	...
Query Posts Collection
>db.posts.find()
{ _id : ObjectId("4c4ba5c0672c685e5e8aabf3"),
author : "roger",
date : "Sat Jul 24 ...
Create index on any Field in Document
// 1 means ascending, -1 means descending
>db.posts.ensureIndex({author: 1})
>db.pos...
Query operators
Conditional operators:
$ne, $in, $nin, $mod, $all, $size, $exists, $type, ..
$lt, $lte, $gt, $gte, $ne, .....
Query operators
Conditional operators:
$ne, $in, $nin, $mod, $all, $size, $exists, $type, ..
$lt, $lte, $gt, $gte, $ne,
//...
Query operators
Conditional operators:
$ne, $in, $nin, $mod, $all, $size, $exists, $type, ..
$lt, $lte, $gt, $gte, $ne,
//...
Extending the Schema
comment = {author: “fred”,
date: new Date(),
text: “Best Movie Ever”}
update = { ‘$push’: {comments: ...
{ _id : ObjectId("4c4ba5c0672c685e5e8aabf3"),
author : "roger",
date : "Sat Jul 24 2010 19:47:11 GMT-0700 (PDT)",
text : "...
// create index on nested documents:
>db.posts.ensureIndex({"comments.author": 1})
>db.posts.find({comments.author:”Fred”})...
Deploying MongoDB
Deploying MongoDB
Primary
Read	
  /	
  Write
Deploying MongoDB
Primary
Secondary
Read	
  /	
  Write
Replication
Setting Up MongoDB
Primary
Secondary
Read	
  /	
  Write
Secondary	
  for	
  Backup
Replication
Replication
Setting Up MongoDB
Primary
Secondary
Read	
  /	
  Write
Secondary	
  for	
  Backup
Read Replication
Replication
Setting Up MongoDB
Primary
Secondary
Read	
  /	
  Write
Secondary	
  for	
  Backup
Read Replication
Replication
Replicaset
Read Scalability : Replication
write
read
ReplicaSet	
  1
Primary
Secondary
Secondary
Write Scalability: Sharding
write
read
ReplicaSet	
  1
Primary
Secondary
Secondary
ReplicaSet	
  2
Primary
Secondary
Secon...
Monitoring
• We like Munin ..
• ... but other frameworks
work as well
• Primary function:
• Measure stats over time
• Tell...
MongoDB makes building
applications easy
Designed a Blog Schema
Evolved the Schema
Deployed MongoDB
Scale MongoDB
MongoDB makes building
applications easy
Map / Reduce
Capped Collections
Tail-able Cursors
Geo Indexing
.. and much more !...
@mongodb
conferences,	
  appearances,	
  and	
  meetups
http://www.10gen.com/events
http://bit.ly/mongoG	
  
Facebook	
  	...
Upcoming SlideShare
Loading in …5
×

Mongo db japan

4,625 views

Published on

Tokyo, nov 1st 2010.

Mongo db japan

  1. 1. Roger Bodamer @rogerb
  2. 2. Baseball World Series Giants lead 3-1 over Rangers
  3. 3. What is MongoDB? quick introduction design session deploy mongodb scaling
  4. 4. MongoDB adoption is very strong 90,000 Database downloads per month
  5. 5. Over 1,000 Production Deployments
  6. 6. Platform and Language support MongoDB is Implemented in C++ for best performance Platforms 32/64 bit • Windows • Linux, Mac OS-X, FreeBSD, Solaris
  7. 7. Platform and Language support MongoDB is Implemented in C++ for best performance Platforms 32/64 bit • Windows • Linux, Mac OS-X, FreeBSD, Solaris Language drivers for • Ruby / Ruby-on-Rails • Java / C# / JavaScript • C / C++ • Erlang • Python, Perl • others... .. and much more ! ..
  8. 8. non-­‐relational,  next-­‐generation   operational  datastores  and  databases NoSQL Really Means:
  9. 9. RDBMS (Oracle,  MySQL)
  10. 10. RDBMS (Oracle,  MySQL) New Gen. OLAP (vertica,  aster,   greenplum)
  11. 11. RDBMS (Oracle,  MySQL) New Gen. OLAP (vertica,  aster,   greenplum) Non-relational Operational Stores (“NoSQL”)
  12. 12. Philosophy:  maximize  features  -­‐  up  to  the  “knee”  in  the  curve,  then  stop depth  of  functionality scalability  &  performance • memcached • key/value • RDBMS
  13. 13. Horizontally Scalable Architectures no  joins no  complex  transactions+
  14. 14. New Data Models no  joins no  complex  transactions+
  15. 15. Improved ways to develop New Data Models -­‐>  
  16. 16. Terminology RDBMS MongoDB Table Collection Row(s) JSON  Document Index Index Join Embedding  &  Linking Partition Shard Partition  Key Shard  Key
  17. 17. MongoDB Design Session
  18. 18. MongoDB Design Session Blog Post Document  p  =  {author:  “roger”,                date:  new  Date(),                text:  “Spirited  Away”,                tags:  [“Tezuka”,  “Manga”]} >db.posts.save(p)
  19. 19. Query Posts Collection >db.posts.find() { _id : ObjectId("4c4ba5c0672c685e5e8aabf3"), author : "roger", date : "Sat Jul 24 2010 19:47:11 GMT-0700 (PDT)", text : "Spirited Away", tags : [ "Tezuka", "Manga" ] } Notes: - _id is unique, but can be anything you’d like
  20. 20. Create index on any Field in Document // 1 means ascending, -1 means descending >db.posts.ensureIndex({author: 1}) >db.posts.find({author: 'roger'}) { _id : ObjectId("4c4ba5c0672c685e5e8aabf3"), author : "roger", ... } Secondary Index
  21. 21. Query operators Conditional operators: $ne, $in, $nin, $mod, $all, $size, $exists, $type, .. $lt, $lte, $gt, $gte, $ne, ... // find posts with any tags >db.posts.find({tags: {$exists: true}})
  22. 22. Query operators Conditional operators: $ne, $in, $nin, $mod, $all, $size, $exists, $type, .. $lt, $lte, $gt, $gte, $ne, // find posts with any tags >db.posts.find({tags: {$exists: true}}) Regular expressions: // posts where author starts with r >db.posts.find({author: /^r*/i })
  23. 23. Query operators Conditional operators: $ne, $in, $nin, $mod, $all, $size, $exists, $type, .. $lt, $lte, $gt, $gte, $ne, // find posts with any tags >db.posts.find({tags: {$exists: true}}) Regular expressions: // posts where author starts with k >db.posts.find({author: /^k*/i }) Counting: // posts written by roger    >db.posts.find({author:  “roger”}).count()
  24. 24. Extending the Schema comment = {author: “fred”, date: new Date(), text: “Best Movie Ever”} update = { ‘$push’: {comments: comment}}  >db.posts.update({_id:  “...”  },  update) Adding Comments to Blog
  25. 25. { _id : ObjectId("4c4ba5c0672c685e5e8aabf3"), author : "roger", date : "Sat Jul 24 2010 19:47:11 GMT-0700 (PDT)", text : "Spirited Away", tags : [ "Tezuka", "Manga" ], comments : [ { author : "Fred", date : "Sat Jul 24 2010 20:51:03 GMT-0700 (PDT)", text : "Best Movie Ever" } ]}
  26. 26. // create index on nested documents: >db.posts.ensureIndex({"comments.author": 1}) >db.posts.find({comments.author:”Fred”}) Secondary Index
  27. 27. Deploying MongoDB
  28. 28. Deploying MongoDB Primary Read  /  Write
  29. 29. Deploying MongoDB Primary Secondary Read  /  Write Replication
  30. 30. Setting Up MongoDB Primary Secondary Read  /  Write Secondary  for  Backup Replication Replication
  31. 31. Setting Up MongoDB Primary Secondary Read  /  Write Secondary  for  Backup Read Replication Replication
  32. 32. Setting Up MongoDB Primary Secondary Read  /  Write Secondary  for  Backup Read Replication Replication Replicaset
  33. 33. Read Scalability : Replication write read ReplicaSet  1 Primary Secondary Secondary
  34. 34. Write Scalability: Sharding write read ReplicaSet  1 Primary Secondary Secondary ReplicaSet  2 Primary Secondary Secondary ReplicaSet  3 Primary Secondary Secondary key  range   0  ..  30 key  range   31  ..  60 key  range   61  ..  100
  35. 35. Monitoring • We like Munin .. • ... but other frameworks work as well • Primary function: • Measure stats over time • Tells you what is going on with your system
  36. 36. MongoDB makes building applications easy Designed a Blog Schema Evolved the Schema Deployed MongoDB Scale MongoDB
  37. 37. MongoDB makes building applications easy Map / Reduce Capped Collections Tail-able Cursors Geo Indexing .. and much more ! ..
  38. 38. @mongodb conferences,  appearances,  and  meetups http://www.10gen.com/events http://bit.ly/mongoG   Facebook                    |                  Twitter                  |                  LinkedIn http://linkd.in/joinmongo download at mongodb.org We’re Hiring ! roger@10gen.com

×