Webinar: MongoDB for Content Management
 

Webinar: MongoDB for Content Management

on

  • 2,640 views

MongoDB's flexible schema makes it a great fit for your next content management application as its data model makes it easy to catalog multiple content types with diverse meta data. In this session, ...

MongoDB's flexible schema makes it a great fit for your next content management application as its data model makes it easy to catalog multiple content types with diverse meta data. In this session, we'll review schema design for content management, using GridFS for storing binary files, and how you can leverage MongoDB's auto-sharding to partition your content across multiple servers.

Statistics

Views

Total Views
2,640
Views on SlideShare
1,631
Embed Views
1,009

Actions

Likes
5
Downloads
39
Comments
0

5 Embeds 1,009

http://www.10gen.com 926
http://www.mongodb.com 49
http://www.linkedin.com 28
http://drupal1.10gen.cc 3
https://www.mongodb.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

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

Webinar: MongoDB for Content Management Webinar: MongoDB for Content Management Presentation Transcript

  • https://twitter.com/mongodbMongoDB for ContentManagementBryan ReineroConsulting Engineer, 10gen
  • Agenda• Sample Content Management System (CMS) Application• Schema Design Considerations• Viewing the Final Product• Building Feeds and Querying Data• Replication, Failover, and Scaling• Further Resources
  • Sample CMSApplication
  • CMS Application Overview• Business news service• Hundreds of stories per day• Millions of website visitors per month• Comments• Related stories• Tags
  • Viewing Stories (Web Site) Headline Date, Byline Tags Copy Related Stories Comments
  • Viewing Categories/Tags (Web Site) Headline Date, Byline Lead Text Headline Date, Byline Lead Text
  • Sample Article Headline Byline, Date, Comments Copy Image Related Stories
  • Schema DesignConsiderations
  • Sample Relational DB Structurestory author tag commentid id id Idheadline first_name name storyidcopy last_name … nameauthorid title Emailslug … comment_text… …related_story link_story_tagid Idstoryid storyidrelated_storyid tagid… …
  • Sample Relational DB Structure• Number of queries per page load?• Caching layers add complexity• Tables may grow to millions of rows• Joins will become slower over time as db increases in size• Schema changes• Scaling database to handle more reads
  • MongoDB Schema Design• “Schemaless”, however, schema design is important• JSON documents• Design for the use case and work backwards• Do not use a relational model in MongoDB• No joins or transactions, most related information should be contained in the same document• Atomic updates on documents, equivalent of transaction
  • Sample MongoDB Schema{ _id: 375, headline: ”Apple Reports Second Quarter Earnings", date: ISODate("2012-07-14T01:00:00+01:00"), slug: “apple-reports-second-quarter-earnings”, byline: { author: “Jason Zucchetto”, title: “Lead Business Editor” }, copy: “Apple reported second quarter revenue today…”, tags: [ ”AAPL", ”Earnings” ], Comments: [ { name: “Frank”, comment: “Great story!”} ]}
  • Adding Fields Based onStory{ _id: 375, headline: ”Apple Reports Second Quarter Earnings", date: ISODate("2012-07-14T01:00:00+01:00"), slug: “apple-reports-second-quarter-earnings”, byline: { author: “Jason Zucchetto”, title: “Lead Business Editor” }, copy: “Apple reported second quarter revenue today…”, tags: [ ”AAPL", ”Earnings” ], image: “/images/aapl/tim-cook.jpg”, ticker: “AAPL”}
  • High Comment Volume{ _id: 375, headline: ”Apple Reports Second Quarter Earnings", date: ISODate("2012-07-14T01:00:00+01:00"), slug: “apple-reports-second-quarter-earnings”, … copy: “Apple reported second quarter revenue today…”, tags: [ ”AAPL", ”Earnings” ], Last25Comments: [ { name: “Frank”, comment: “Great story!”}, { name: “John”, comment: “This is interesting”} … ]}
  • Managing Related Stories{ _id: 375, headline: ”Apple Reports Second Quarter Earnings", date: ISODate("2012-07-14T01:00:00+01:00"), slug: “apple-reports-second-quarter-earnings”, … RelatedStories: [ { headline: “Google Reports on Revenue”, date: ISODate("2012-07-15T01:00:00+01:00"), slug: “goog-revenue-third-quarter” }, { headline: “Yahoo Reports on Revenue”, date: ISODate("2012-07-15T01:00:00+01:00"), slug: “yhoo-revenue-third-quarter” } ]}
  • Full Sample Schema{ // Story Collection (sample document) _id: 375, headline: ”Apple Reports Second Quarter Earnings", date: ISODate("2012-07-14T01:00:00+01:00"), slug: “apple-reports-second-quarter-earnings”, byline: { author: “Jason Zucchetto”, title: “Lead Business Editor” }, copy: “Apple reported second quarter revenue today…”, tags: [ ”AAPL", ”Earnings” ], Last25Comments: [ { name: “Frank”, comment: “Great story!”}, { name: “John”, comment: “This is interesting”} ]
  • Full Sample Schema (Contd.) image: “/images/aapl/tim-cook.jpg”, ticker: “AAPL”, RelatedStories: [ { headline: “Google Reports on Revenue”, date: ISODate("2012-07-15T01:00:00+01:00"), slug: “goog-revenue-third-quarter” }, { headline: “Yahoo Reports on Revenue”, date: ISODate("2012-07-15T01:00:00+01:00"), slug: “yhoo-revenue-third-quarter” } ]}{ // Comment collection (sample document) _id: 1891, storyid: 375, name: “Frank”, comment: “Great story!”}
  • Querying and Indexing
  • Inserting and UpdatingStories// Inserting new stories are easy, just submit JSON documentdb.cms.insert( { headline: “Apple Reports Revenue”... });// Adding story tagsdb.cms.update( { _id : 375 }, { $addToSet : { tags : "AAPL" } } )// Adding a comment (if embedding comments in story)db.cms.update( { _id : 375 }, { $addToSet : { comments: {name: „Jason‟, „comment: „Great Story‟} } } )
  • MongoDB Indexes for CMS// Index on story slugdb.cms.ensureIndex( { slug : 1 });// Index on story tagsdb.cms.ensureIndex( { tags: 1 });
  • Querying MongoDB// All Story informationdb.cms.find( { slug : “apple-reports-second-quarter-earnings” });// All Stories for a given tagdb.cms.find( { tags: “Earnings” });
  • Building Custom RSSFeeds
  • Query Tags and Sort by Date// Very simple to gather specific information for a feeddb.cms.find( { tags: { $in : [“Earnings”, “AAPL”] } }).sort({ date : -1 });
  • Replication, Failover, andScaling
  • Replication• Extremely easy to set up• Replica node can trail primary node and maintain a copy of the primary database• Useful for disaster recovery, failover, backups, and specific workloads such as analytics• When Primary goes down, a Secondary will automatically become the new Primary
  • Replication
  • Reading from Secondaries (DelayedConsistency)Reading from Secondaries (DelayedConsistency)
  • Scaling Horizontally• Important to keep working data set in RAM• When working data set exceeds RAM, easy to add additional machines and segment data across machines (sharding)
  • Sharding with MongoDB
  • Additional Resources• Use Case Tutorials: http://docs.mongodb.org/manual/use-cases/• What others are doing: http://www.10gen.com/use-case/content- management• This presentation & video recording: https://www.10gen.com/presentations/webinar
  • https://twitter.com/mongodbThank YouBryan ReineroConsulting Engineer, 10gen