• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
MongoDB Strange Loop 2009
 

MongoDB Strange Loop 2009

on

  • 2,935 views

Talk on MongoDB given at the first Strange Loop Conference in St. Louis, October 2009.

Talk on MongoDB given at the first Strange Loop Conference in St. Louis, October 2009.

Statistics

Views

Total Views
2,935
Views on SlideShare
2,928
Embed Views
7

Actions

Likes
1
Downloads
44
Comments
0

1 Embed 7

http://www.slideshare.net 7

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Mike Dirolf, 10gen <br /> sponsors MongoDB <br /> Thanks <br /> Plan: <br /> A little about what makes MongoDB interesting <br /> Some flavor for the API / querying possibilities <br /> Sharding <br /> Questions
  • C - The client perceives that a set of operations has occurred all at once <br /> A - Every operation must terminate in an intended response <br /> P - Operations will complete even if individual components are unavailable <br /> <br /> Horizontal scaling necessitates P, so forced to choose C or A
  • Transaction is all or none <br /> Consistent state at beginning + end of transaction <br /> Transaction behaves as if only operation <br /> Upon completion, operation will not be reversed <br /> <br /> Sacrifice consistency for availability
  • More complex than just Key-Value <br /> Secondary Indexes <br /> Embedded Documents
  • Compare to Couch
  • No Separate Caching Layer
  • Master-Slave <br /> Replica Pairs <br /> For Failover
  • Infinite Scalability
  • Collection (logical groupings of documents) <br /> Indexes are per-collection
  • Order Preserving Partitioning <br /> Split <br /> Migrate
  • Process Diagram <br /> <br /> Global vs Targeted Operations <br /> Config Servers Use Two Phase Commit
  • Server Layout
  • blog post <br /> twitter

MongoDB Strange Loop 2009 MongoDB Strange Loop 2009 Presentation Transcript

  • open-source, high-performance, schema-free, document-oriented database
  • RDBMS • Great for many applications • Shortcomings • Scalability • Flexibility
  • CAP theorem • Consistency • Availability • Tolerance to network Partitions • Pick two http://www.cs.berkeley.edu/~brewer/cs262b-2004/PODC-keynote.pdf
  • ACID vs BASE • Atomicity • Basically Available • Consistency • Soft state • Isolation • Eventually consistent • Durability
  • Compared to key-value stores
  • Compared to CouchDB
  • JSON-style documents
  • Schema-free • Loosening constraints - added flexibility • Dynamically typed languages • Migrations
  • Dynamic queries • Administration • Ease of development • Familiarity
  • Focus on performance
  • Replication
  • Auto-sharding
  • Many supported platforms / languages
  • Good at • The web • Caching • High volume data • Scalability
  • Less good at • Highly transactional • Ad-hoc business intelligence • Problems that require SQL
  • MongoDB Basics
  • Document • Unit of storage (think row) • BSON (Binary JSON)
  • Collection • Schema-free equivalent of a table • Logical groups of documents • Indexes are per-collection
  • _id • Special key • Present in all documents • Unique across a Collection • Any type you want
  • Blog back-end
  • Post {author: “mike”, date: new Date(), text: “my blog post...”, tags: [“mongodb”, “strange”, “loop”]}
  • Comment {author: “eliot”, date: new Date(), text: “great post!”}
  • New post post = {author: “mike”, date: new Date(), text: “my blog post...”, tags: [“mongodb”, “strange”, “loop”]} db.posts.save(post)
  • Embedding a comment c = {author: “eliot”, date: new Date(), text: “great post!”} db.posts.update({_id: post._id}, {$push: {comments: c}})
  • Posts by author db.posts.find({author: “mike”})
  • Last 10 posts db.posts.find() .sort({date: -1}) .limit(10)
  • Posts in the last week last_week = new Date(2009, 9, 9) db.posts.find({date: {$gt: last_week}})
  • Posts ending with ‘Loop’ db.posts.find({text: /loop$/})
  • Posts with a tag db.posts.find({tag: “mongodb”}) ... and fast db.posts.ensureIndex({tag: 1})
  • Counting posts db.posts.count() db.posts.find({author: “mike”}).count()
  • Basic paging page = 2 page_size = 15 db.posts.find().limit(page_size) .skip(page * page_size)
  • Migration: adding titles • Easy - just start adding them: post = {author: “mike”, date: new Date(), text: “another blog post...”, tags: [“strange”, “loop”], title: “Review from Strange Loop”} post_id = db.posts.save(post)
  • Advanced queries • $gt, $lt, $gte, $lte, $ne, $all, $in, $nin • where() db.posts.find({$where: “this.author == ‘mike’”})
  • Sharding
  • 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
  • Other cool stuff • Aggregation and map reduce • Capped collections • Unique indexes • Mongo shell • GridFS
  • • Download MongoDB http://www.mongodb.org • Try it out • Let us know what you think!
  • • http://www.mongodb.org • irc.freenode.net#mongodb • mongodb-user on google groups • @mongodb, @mdirolf • mike@10gen.com • http://www.slideshare.net/mdirolf