MongoDB at RuPy

3,088 views

Published on

Presentation on MongoDB given at RuPy in November of 2009.

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,088
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
49
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide
  • Order Preserving Partitioning
    Split
    Migrate
  • Server Layout
  • blog post
    twitter
  • MongoDB at RuPy

    1. 1. open-source, high-performance, schema-free, document-oriented database
    2. 2. RDBMS • Great for many applications • Shortcomings • Scalability • Availability • Flexibility
    3. 3. Key-value stores
    4. 4. CouchDB
    5. 5. JSON-style documents
    6. 6. Schema-free • Loosening constraints - added flexibility • Dynamically typed languages (RuPy!) • Migrations
    7. 7. Dynamic queries • Administration • Ease of development • Familiarity
    8. 8. Focus on performance
    9. 9. Replication
    10. 10. Auto-sharding
    11. 11. Many supported platforms / languages
    12. 12. Good at • The web • Caching • High volume data • Scalability
    13. 13. Less good at • Highly transactional • Ad-hoc business intelligence • Problems that require SQL
    14. 14. MongoDB Basics
    15. 15. Document • Unit of storage (think row) • BSON (Binary JSON) • Represented as a dict / Hash
    16. 16. Collection • Schema-free equivalent of a table • Logical groups of documents • Indexes are per-collection
    17. 17. _id • Special key • Present in all documents • Unique across a Collection • Any type you want
    18. 18. Blog back-end
    19. 19. Post {“author”: “mike”, “date”: datetime.datetime.utcnow(), “text”: “my blog post...”, “tags”: [“mongodb”, “python”, “ruby”]}
    20. 20. Comment {“author”: “eliot”, “date”: datetime.datetime.utcnow(), “text”: “great post!”}
    21. 21. New post post = {“author”: “mike”, “date”: datetime.datetime.utcnow(), “text”: “my blog post...”, “tags”: [“mongodb”, “python”, “ruby”]} post_id = db.posts.save(post)
    22. 22. Embedding a comment c = {“author”: “eliot”, “date”: datetime.datetime.utcnow(), “text”: “great post!”} db.posts.update({“_id”: post_id}, {“$push”: {“comments”: c}})
    23. 23. Posts by author db.posts.find({“author”: “mike”})
    24. 24. Last 10 posts query = db.posts.find() .sort(“date”, DESCENDING) .limit(10) for post in query: print post[“text”]
    25. 25. Posts in the last week last_week = datetime.datetime.utcnow() + datetime.timedelta(days=-7) db.posts.find({“date”: {“$gt”: last_week}})
    26. 26. Posts ending with ‘RuPy’ db.posts.find({“text”: re.compile(“RuPy$”)})
    27. 27. Posts with a tag db.posts.find({“tags”: “mongodb”}) ... and fast db.posts.create_index(“tags”)
    28. 28. Counting posts db.posts.count() db.posts.find({“author”: “mike”}).count()
    29. 29. Basic paging page = 2 page_size = 15 db.posts.find().limit(page_size) .skip(page * page_size)
    30. 30. Migration: adding titles • Easy - just start adding them: post = {“author”: “mike”, “date”: datetime.datetime.utcnow(), “text”: “another blog post...”, “tags”: [“conference”, “rupy”], “title”: “Review from RuPy”} post_id = db.posts.save(post)
    31. 31. Advanced queries • $gt, $lt, $gte, $lte, $ne, $all, $in, $nin • where() db.posts.find().where(“this.author==‘mike’ || this.title==‘hello’”) • group()
    32. 32. Other cool stuff • Aggregation and map reduce • Capped collections • Unique indexes • Mongo shell • GridFS • MongoKit, Mongoid, MongoMapper, etc.
    33. 33. Sharding
    34. 34. Terminology • Shard key • Chunk • Range of the value space • (collection, key, min_val, max_val) • Shard • Single node (or replica pair) • Responsible for set of chunks
    35. 35. client
    36. 36. mongos client
    37. 37. Shards mongod mongod mongod ... mongod mongod mongod mongos client
    38. 38. Shards mongod mongod mongod ... mongod mongod mongod mongos mongos ... client
    39. 39. Shards mongod mongod mongod ... Config mongod mongod mongod Servers mongod mongod mongod mongos mongos ... client
    40. 40. • Download MongoDB http://www.mongodb.org • Try it out • Let us know what you think! • Oh, and get stickers!
    41. 41. • http://www.mongodb.org • irc.freenode.net#mongodb • mongodb-user on google groups • @mongodb, @mdirolf • mike@10gen.com • http://www.slideshare.net/mdirolf

    ×