Mongo db presentation

1,603 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
1,603
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Mongo db presentation

    1. 1. Julie Sommervillejsommerville@businessinsider.com
    2. 2. DB1 primary DB3 primary businessinsider bi_analytics 64GB 16GBWeb1 DB2 - Secondary arbiter businessinsider businessinsider port xxxxx arbiter bi_analytics bi_analytics port yyyyyy 32GB 16GB
    3. 3. It’s very easy to add a new nodes to a replica setStart the process on the new server: mkdir /data/db mongod --port xxx --dbpath /data/db --replSet setnameAdd the node on the Primary DB rs.add(“[hostname]:port”);
    4. 4. Most of the operations we perform on the analytics db are atomic in-place updates : analytics.heatmap.update( { homepage_id:"4ecfb4eefcda248b89000003", uri : "/ron-paul-slams-trump-joins-huntsman-in-sitting-out-circus-like-debate-2011-12" }, { $inc : {views : 1}, $set : {updated_at : {"sec":1329587057,"usec":175000}} }}, true // upsert)
    5. 5. Check this
    6. 6. Process
    7. 7. Example: adding a new field to an objectIn the console> var myObj = {name: julie, role: "developer"}//creates the foo collection and inserts an object> db.foo.save(myObj)> db.foo.find(){ "_id" : ObjectId("4f418251f4dd8d3d88a776ea"), "name" : "julie", "role" : "developer" }// Add a new fieldvar julie = db.foo.findOne(){ "_id" : ObjectId("4f418251f4dd8d3d88a776ea"), "name" : "julie", "role" : "developer"}> julie.last_name = "sommerville> db.foo.save(julie)> db.foo.find().pretty(){ "_id" : ObjectId("4f418251f4dd8d3d88a776ea"), "name" : "julie", "role" : "developer", "last_name" : "sommerville"}(pretty just makes it pretty)
    8. 8. Some Examples from our DBPost Object: contains comments, many posts will have way more than a couple of commentsdb.blog.posts.findOne({comments : {$exists:true}, comment_count : {$gte: 1}, ts : {$gte: start}}){ "_id" : ObjectId("4d4798c949e2aef0100d0000"), "attached_images" : [ ], "author" : "Ed Dolan", "author_id" : ObjectId("4d121ca0ccd1d5d337000000"), "autotweet" : false, "badges" : [ ], "browser_title" : null, "categories" : [ ], "cls" : "entry", "comment_count" : 1, "comment_thread_count" : 1, "comments" : [ { "cid" : ObjectId("4d482923cadcbb310a080000"), "ts" : ISODate("2011-02-01T15:39:15.541Z"), "ip" : "113.53.150.3", "author" : "kenhow", "email" : "info@howincorporated.com", "url" : "http://howincorporated.com", "user_id" : ObjectId("4d32fceaccd1d53d7b010000"), "text" : "In other words: nothing to worry about" } ],
    9. 9. We also store the Replies to comments : { "author" : "LS", "cid" : ObjectId("4eda72376bb3f72279000009"), "email" : "lawrenceshapiro@gmail.com", "flags" : [ ], "ip" : "74.68.112.217", "rate_down" : 0, "rate_up" : 6, "raters" : { "$ref" : "blog.comments.raters", "$id" : ObjectId("4eda72376bb3f72279000008") }, "replies" : [ { "cid" : ObjectId("4eda800b69beddf55900004f"), "author" : "Skepticus Maximus", "email" : "henry1807@yahoo.com", "flags" : [ ], "ip" : "66.159.194.20", "rate_down" : 0, "rate_up" : 1, "raters" : { "$ref" : "blog.comments.raters", "$id" : ObjectId("4eda800b69beddf55900004e") }, "reply" : ObjectId("4eda72376bb3f72279000009"), "reply_author" : "LS", "text" : "No, its perfectly natural - natures way to make sure the species continues", "ts" : ISODate("2011-12-03T20:01:15.930Z"), "url" : "", "session_id" : ObjectId("4eda76e3eab8ea9f4d00003d") },* Fast retrieval - no joins
    10. 10. MMS (MongoDB Monitoring Service)* Really nice stats with the ability to “zoom” in (minute, 5min, hour etc.).* If the data base is acting up you can go in and see where the problem may lie-- Num Collections-- Data Size in the DB and in storage-- Avg. doc size-- Index Sizes-- Replica Set Stats-- page faults-- the lock queue (reads and writes)
    11. 11. total number of contiguously allocated chunks of datafile space for the database
    12. 12. num commands index access and hits
    13. 13. secondary shouldn’t be more than this number hours behind
    14. 14. shows slow ops
    15. 15. Sharding- Probably on our main database- Help deal with load/num of connections

    ×