Consulting Engineer, 10genJason Zucchettohttps://twitter.com/mongodbMongoDB for ContentManagement
Agenda• MongoDB Features and Overview• Sample Content Management System (CMS)Application• Schema Design Considerations• Bu...
MongoDB Features• JSON Document Model withDynamic Schemas• Auto-Sharding for HorizontalScalability• Text Search• Aggregati...
Sample CMSApplication
CMS Application Overview• Business news service• Hundreds of stories per day• Millions of website visitors per month• Comm...
Viewing Stories (Web Site)HeadlineDate, BylineCopyCommentsTagsRelated Stories
Viewing Categories/Tags (WebSite)HeadlineDate, BylineLead TextHeadlineDate, BylineLead Text
Sample ArticleHeadlineByline, Date, CommentsCopyRelated StoriesImage
Schema DesignConsiderations
Sample Relational DB Structurestoryidheadlinecopyauthoridslug…authoridfirst_namelast_nametitle…tagidname…commentIdstoryidn...
Sample Relational DB Structure• Number of queries per page load?• Caching layers add complexity• Tables may grow to millio...
MongoDB Schema Design• “Dynamic Schema”, however, schema design isimportant• JSON documents• Design for the use case and w...
{_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-14T01:00:00+01:00"),url: “apple-reports...
{_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-14T01:00:00+01:00"),url: “apple-reports...
{_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-14T01:00:00+01:00"),url: “apple-reports...
{_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-14T01:00:00+01:00"),url: “apple-reports...
{ // Story Collection (sample document)_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-1...
image: “/images/aapl/tim-cook.jpg”,ticker: “AAPL”,relatedstories: [{headline: “Google Reports on Revenue”,date: ISODate("2...
story{headlinedateurl…relatedstories : []last25comments : []…companyid}CMS Collectionscomment{story_idnamecomment}company{...
Querying and Indexing
// Display a story, related stories, and first page of commentsdb.story.find( { url: “apple-reports-second-quarter-earning...
// Display data for a company, latest storiesdb.company.find( { url: “apple-inc” });// Display data for a company, all sto...
// Inserting new stories are easy, just submit JSON documentdb.story.insert( { headline: “Apple Reports Revenue”... });// ...
// Index on story slugdb.story.ensureIndex( { url: 1 });// Index on story tagsdb.story.ensureIndex( { tags: 1 });MongoDB I...
Building Custom RSSFeeds
// Very simple to gather specific information for a feeddb.story.find( { tags: { $in : [“Earnings”, “AAPL”] } }).sort({ da...
Replication, Failover, andScaling
Replication• Extremely easy to set up• Replica node can trail primary node andmaintain a copy of the primary database• Use...
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 toadd additional ...
Sharding with MongoDB
Case Studies
Runs unified data store serving hundreds ofdiverse web properties on MongoDBCase StudyProblem Why MongoDB Results• Hundred...
Serves targeted content to users using MongoDB-powered identity systemCase StudyProblem Why MongoDB Results• 20M+ unique v...
Powers content-serving web platform on MongoDBto deliver dynamic data to usersCase StudyProblem Why MongoDB Results• Stati...
Resource LocationMongoDB Downloads 10gen.com/downloadFree Online Training education.10gen.comWebinars and Events 10gen.com...
Consulting Engineer, 10genJason Zucchettohttps://twitter.com/mongodbThank You
Upcoming SlideShare
Loading in...5
×

Webinar: MongoDB for Content Management

1,972

Published on

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.

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

No Downloads
Views
Total Views
1,972
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • MongoDB provides agility, scalability, and performance without sacrificing the functionality of relational databases, like full index support and rich queriesIndexes: secondary, compound, text search (with MongoDB 2.4), geospatial, and more
  • Transcript of "Webinar: MongoDB for Content Management"

    1. 1. Consulting Engineer, 10genJason Zucchettohttps://twitter.com/mongodbMongoDB for ContentManagement
    2. 2. Agenda• MongoDB Features and Overview• Sample Content Management System (CMS)Application• Schema Design Considerations• Building Feeds and Querying Data• Replication, Failover, and Scaling• Case Studies• Further Resources
    3. 3. MongoDB Features• JSON Document Model withDynamic Schemas• Auto-Sharding for HorizontalScalability• Text Search• Aggregation Framework andMapReduce• Full, Flexible Index Supportand Rich Queries• Built-In Replication for HighAvailability• Advanced Security• Large Media Storage withGridFS
    4. 4. Sample CMSApplication
    5. 5. CMS Application Overview• Business news service• Hundreds of stories per day• Millions of website visitors per month• Comments• Related stories• Tags• Company profiles
    6. 6. Viewing Stories (Web Site)HeadlineDate, BylineCopyCommentsTagsRelated Stories
    7. 7. Viewing Categories/Tags (WebSite)HeadlineDate, BylineLead TextHeadlineDate, BylineLead Text
    8. 8. Sample ArticleHeadlineByline, Date, CommentsCopyRelated StoriesImage
    9. 9. Schema DesignConsiderations
    10. 10. Sample Relational DB Structurestoryidheadlinecopyauthoridslug…authoridfirst_namelast_nametitle…tagidname…commentIdstoryidnameEmailcomment_text…related_storyidstoryidrelated_storyid…link_story_tagIdstoryidtagid…
    11. 11. 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 dbincreases in size• Schema changes• Scaling database to handle more reads
    12. 12. MongoDB Schema Design• “Dynamic Schema”, however, schema design isimportant• JSON documents• Design for the use case and work backwards• Avoid a relational model in MongoDB• No joins or transactions, most related informationshould be contained in the same document• Atomic updates on documents, equivalent oftransaction
    13. 13. {_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-14T01:00:00+01:00"),url: “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!”}]}Sample MongoDB Schema
    14. 14. {_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-14T01:00:00+01:00"),url: “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”}Adding Fields Based onStory
    15. 15. {_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-14T01:00:00+01:00"),url: “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”}…]}High Comment Volume
    16. 16. {_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-14T01:00:00+01:00"),url: “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”}]}Managing Related Stories
    17. 17. { // Story Collection (sample document)_id: 375,headline: ”Apple Reports Second Quarter Earnings",date: ISODate("2012-07-14T01:00:00+01:00"),url: “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 Story Schema
    18. 18. 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”}]}Full Sample Story Schema
    19. 19. story{headlinedateurl…relatedstories : []last25comments : []…companyid}CMS Collectionscomment{story_idnamecomment}company{nameurllocationtickerlast25stories : []}
    20. 20. Querying and Indexing
    21. 21. // Display a story, related stories, and first page of commentsdb.story.find( { url: “apple-reports-second-quarter-earnings” });// Display a story, related stories, and second page of commentsdb.story.find( { url: “apple-reports-second-quarter-earnings” });db.comment.find( { story_id : 1234 }).limit(25).skip(25).sort({ date: -1 });// All Stories for a given tagdb.story.find( { tags: “Earnings” });Querying MongoDB
    22. 22. // Display data for a company, latest storiesdb.company.find( { url: “apple-inc” });// Display data for a company, all storiesdb.company.find( { url: “apple-inc” });db.story.find( { company_id : 1234 });Querying MongoDB
    23. 23. // Inserting new stories are easy, just submit JSON documentdb.story.insert( { headline: “Apple Reports Revenue”... });// Adding story tagsdb.story.update( { _id : 375 }, { $addToSet : { tags : "AAPL" } })// Adding a comment (if embedding comments in story)db.story.update( { _id : 375 }, { $push: { comments: { name:„Jason‟, „comment: „Great Story‟} } } )Inserting and UpdatingStories
    24. 24. // Index on story slugdb.story.ensureIndex( { url: 1 });// Index on story tagsdb.story.ensureIndex( { tags: 1 });MongoDB Indexes for CMS
    25. 25. Building Custom RSSFeeds
    26. 26. // Very simple to gather specific information for a feeddb.story.find( { tags: { $in : [“Earnings”, “AAPL”] } }).sort({ date : -1 });Query Tags and Sort by Date
    27. 27. Replication, Failover, andScaling
    28. 28. Replication• Extremely easy to set up• Replica node can trail primary node andmaintain a copy of the primary database• Useful for disasterrecovery, failover, backups, and specificworkloads such as analytics• When Primary goes down, a Secondary willautomatically become the new Primary
    29. 29. Replication
    30. 30. Reading from Secondaries (DelayedConsistency)Reading from Secondaries (DelayedConsistency)
    31. 31. Scaling Horizontally• Important to keep working data set in RAM• When working data set exceeds RAM, easy toadd additional machines and segment dataacross machines (sharding)
    32. 32. Sharding with MongoDB
    33. 33. Case Studies
    34. 34. Runs unified data store serving hundreds ofdiverse web properties on MongoDBCase StudyProblem Why MongoDB Results• Hundreds of diverseweb properties built onJava-based CMS• Rich documents forcedinto ill-suited model• Adding new datatypes, tables to RDBMSkilled read performance• Flexible schema• Rich querying and supportfor secondary indexsupport• Easy to managereplication and scaling• Developers can focus onend-user features insteadof back-end storage• Simplified day-to-dayoperations• Simple to add newbrands, content types, etc.to platform
    35. 35. Serves targeted content to users using MongoDB-powered identity systemCase StudyProblem Why MongoDB Results• 20M+ unique visitorsper month• Rigid relational schemaunable to evolve withchanging data typesand new features• Slow developmentcycles• Easy-to-managedynamic data modelenables limitlessgrowth, interactivecontent• Support for ad hocqueries• Highly extensible• Rapid rollout of newfeatures• Customized, socialconversationsthroughout site• Tracks user data toincreaseengagement, revenue
    36. 36. Powers content-serving web platform on MongoDBto deliver dynamic data to usersCase StudyProblem Why MongoDB Results• Static web content• Siloed datastores, disparatetechnologies• Unable to aggregateand integrate data fordynamic content• Support for agiledevelopment• Easy to use andmaintain• Low subscription andHW costs• Ability to serve dynamiccontent• Decreased TCO• Replaced multipletechnologies with singleMongoDB database
    37. 37. Resource LocationMongoDB Downloads 10gen.com/downloadFree Online Training education.10gen.comWebinars and Events 10gen.com/eventsWhite Papers 10gen.com/white-papersCase Studies 10gen.com/customersPresentations 10gen.com/presentationsDocumentation docs.mongodb.orgAdditional Info info@10gen.comFor More InformationResource Location
    38. 38. Consulting Engineer, 10genJason Zucchettohttps://twitter.com/mongodbThank You

    ×