Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Like this? Share it with your network

Share

MongoDB at RubyConf

  • 6,632 views
Uploaded on

MongoDB talk given at RubyConf 2009 (and at Pivotal Labs). Given in November '09.

MongoDB talk given at RubyConf 2009 (and at Pivotal Labs). Given in November '09.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
6,632
On Slideshare
6,613
From Embeds
19
Number of Embeds
2

Actions

Shares
Downloads
122
Comments
0
Likes
12

Embeds 19

http://www.slideshare.net 17
http://192.168.6.184:3000 2

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • Order Preserving Partitioning
    Split
    Migrate
  • blog post
    twitter

Transcript

  • 1. open-source, high-performance, schema-free, document-oriented database
  • 2. RDBMS • Great for many applications • Shortcomings • Scalability • Flexibility
  • 3. JSON-style documents
  • 4. Schema-free • Loosening constraints - added flexibility • Dynamically typed languages (like Ruby!) • Migrations
  • 5. Dynamic queries • Administration • Ease of development • Familiarity
  • 6. Focus on performance
  • 7. Replication
  • 8. Auto-sharding
  • 9. Many supported platforms / languages
  • 10. Good at • The web • Caching • High volume data • Scalability
  • 11. Less good at • Highly transactional • Ad-hoc business intelligence • Problems that require SQL
  • 12. MongoDB Basics
  • 13. Document • Unit of storage (think row) • BSON (Binary JSON) • Represented as a Hash
  • 14. Collection • Schema-free equivalent of a table • Logical groups of documents • Indexes are per-collection
  • 15. _id • Special key • Present in all documents • Unique across a Collection • Any type you want
  • 16. Blog back-end
  • 17. Post {:author => "mike", :date => Time.new, :text => "my blog post", :tags => ["mongodb", "ruby"]}
  • 18. Comment {:author => “eliot”, :date => Time.new, :text => “great post!”}
  • 19. New post post = {:author => "mike", :date => Time.new, :text => "my blog post", :tags => ["mongodb", "ruby"]} db[“posts”].save(post)
  • 20. Embedding a comment c = {:author => “eliot”, :date => Time.new, :text => “great post!”} db[“posts”].update({:_id => post[:_id]}, {:$push => {:comments => c}})
  • 21. Posts by author db[“posts”].find(:author => “mike”)
  • 22. Last 10 posts db[“posts”].find .sort([[:date, :desc]]) .limit(10)
  • 23. Posts in the last week last_week = Time.utc(2009, 11, 12) db[“posts”].find(:date => {:$gt => last_week})
  • 24. Posts ending with ‘Ruby’ db[“posts”].find(:text => /Ruby$/)
  • 25. Posts with a tag db[“posts”].find(:tags => “mongodb”) ... and fast db[“posts”].create_index(“tags”)
  • 26. Counting posts db[“posts”].count db[“posts”].find(:author => “mike”).count
  • 27. Basic paging page = 2 page_size = 15 db[“posts”].find.limit(page_size) .skip(page * page_size)
  • 28. Migration: adding titles • Easy - just start adding them: post = {:author => “mike”, :date => Time.new, :text => “another blog post”, :tags => [“RubyConf”], :title => “Review from RubyConf”} post_id = db[“posts”].save(post)
  • 29. Advanced queries • $gt, $lt, $gte, $lte, $ne, $all, $in, $nin • $where db[“posts”].find :$where => “this.author == ‘mike’ || this.title == ‘hello’”})
  • 30. MongoMapper, Mongoid, MongoRecord, etc.
  • 31. MongoMapper class User include MongoMapper::Document many :posts end class Post include MongoMapper::Document key :user_id, String key :title, String end user = User.create user.posts.create(:title => 'Foo') # would return post we just created user.posts.find_by_title('Foo')
  • 32. Other cool stuff • Aggregation and map reduce • Capped collections • Unique indexes • Mongo shell • GridFS
  • 33. Sharding
  • 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. client
  • 36. mongos client
  • 37. Shards mongod mongod mongod ... mongod mongod mongod mongos client
  • 38. Shards mongod mongod mongod ... mongod mongod mongod mongos mongos ... client
  • 39. Shards mongod mongod mongod ... Config mongod mongod mongod Servers mongod mongod mongod mongos mongos ... client
  • 40. • Download MongoDB http://www.mongodb.org • Try it out • Let us know what you think!
  • 41. • http://www.mongodb.org • irc.freenode.net#mongodb • mongodb-user on google groups • @mongodb, @mdirolf • mike@10gen.com • http://www.slideshare.net/mdirolf