SlideShare a Scribd company logo
The Right (And Wrong) Use Cases for MongoDB 
Damon LaCaille 
damon.lacaille@mongodb.com
We’ll be covering... 
• About MongoDB 
• Benefits of using MongoDB 
• Specific Use Cases 
– Good: Single View, Mobile, Analytics 
– Not So Good... 
• Q&A
About MongoDB
Benefits of MongoDB 
• Performance 
• Availability and Scalability 
• Data Model 
• Query Model
Benefits of MongoDB 
Performance 
Scalability and Performance 
Depth of Functionality
Benefits of MongoDB 
Performance 
Scalability and Performance 
Key/Value Stores 
Cache Only 
Depth of Functionality
Benefits of MongoDB 
Performance 
Scalability and Performance 
Key/Value Stores 
Depth of Functionality 
RDBMS 
Cache Only 
Highly Transactional
Benefits of MongoDB 
Performance 
Scalability and Performance 
Key/Value Stores 
MongoDB 
Depth of Functionality 
RDBMS 
Mobile 
Content Mgmt. Analytics 
Cache Only 
Highly Transactional 
Internet of Things 
Single View 
Personalization 
Catalog
Benefits of MongoDB 
Availability and Scalability 
Application 
mongod 
mongod 
mongod
Benefits of MongoDB 
Availability and Scalability 
Application 
mongod 
mongod 
mongod 
mongod 
mongod 
mongod 
mongos 
[A-L] [M-Z]
Benefits of MongoDB 
Availability and Scalability 
Application 
mongod 
mongod 
mongod 
mongod 
mongod 
mongod 
mongos | mongos | 
mongos 
mongod 
mongod 
mongod 
mongod 
mongod 
mongod 
mongod 
mongod 
mongod 
[A-E] [P-T] 
[F-J] [K-O] [U-Z]
Benefits of MongoDB 
RDBMS -Hard to Make Changes 
New 
Table 
New 
Table 
New 
Column 
Name Age Phone Email
Benefits of MongoDB 
RDBMS vs. Document Data Model 
Mental model 
Relational model
Benefits of MongoDB 
RDBMS vs. Document Data Model 
Mental model 
Document model
Benefits of MongoDB 
{ 
: ‘Paul’, 
surname: ‘Miller’, 
cell: ‘+447557505611’ 
location: [45.123,47.232], 
profession: [banking, finance, 
trader], 
cars: [ 
{ model: ‘Bentley’, 
year: 1973, 
value: 100000, … }, 
{ model: ‘Rolls Royce’, 
year: 1965, 
value: 330000, … } 
] 
} 
Natural Data Model
Benefits of MongoDB 
{ 
: ‘Paul’, 
surname: ‘Miller’, 
cell: ‘+447557505611’ 
location: [45.123,47.232], 
profession: [banking, finance, 
trader], 
cars: [ 
{ model: ‘Bentley’, 
year: 1973, 
value: 100000, … }, 
{ model: ‘Rolls Royce’, 
year: 1965, 
value: 330000, … } 
] 
} 
Natural Data Model 
Field Names
Benefits of MongoDB 
{ 
: ‘Paul’, 
surname: ‘Miller’, 
cell: ‘+447557505611’ 
location: [45.123,47.232], 
profession: [banking, finance, 
trader], 
cars: [ 
{ model: ‘Bentley’, 
year: 1973, 
value: 100000, … }, 
{ model: ‘Rolls Royce’, 
year: 1965, 
value: 330000, … } 
] 
} 
Natural Data Model 
Field Names 
Typed field values
Benefits of MongoDB 
{ 
: ‘Paul’, 
surname: ‘Miller’, 
cell: ‘+447557505611’ 
location: [45.123,47.232], 
profession: [banking, finance, 
trader], 
cars: [ 
{ model: ‘Bentley’, 
year: 1973, 
value: 100000, … }, 
{ model: ‘Rolls Royce’, 
year: 1965, 
value: 330000, … } 
] 
} 
Natural Data Model 
Field Names 
Typed field values 
Fields can 
contain arrays
Benefits of MongoDB 
{ 
: ‘Paul’, 
surname: ‘Miller’, 
cell: ‘+447557505611’ 
location: [45.123,47.232], 
profession: [banking, finance, 
trader], 
cars: [ 
{ model: ‘Bentley’, 
year: 1973, 
value: 100000, … }, 
{ model: ‘Rolls Royce’, 
year: 1965, 
value: 330000, … } 
] 
} 
Natural Data Model 
Field Names 
Typed field values 
Fields can 
contain arrays 
} Fields can contain an array 
of sub-documents
Benefits of MongoDB 
Rich Query Model 
{ 
: ‘Paul’, 
surname: ‘Miller’, 
cell: ‘+447557505611’ 
location: [45.123,47.232], 
profession: [banking, finance, 
trader], 
cars: [ 
{ model: ‘Bentley’, 
year: 1973, 
value: 100000, … }, 
{ model: ‘Rolls Royce’, 
year: 1965, 
value: 330000, … } 
] 
} 
Rich 
Queries 
• Find Paul’s car 
• Find everybody in London with a 
car built between 1970 and 1980 
Geo 
• Find all car owners within 10m of 
Manhattan 
Text Search 
• Find all cars whose VIN starts with 
ZA1 
Aggregation 
• Calculate the average value of 
Paul’s car collection 
Map 
Reduce 
• What is the ownership pattern of 
colors by geography over time? (Is 
silver trending up in the US?)
Benefits of MongoDB 
Relational Database Challenges
Benefits of MongoDB 
Relational Database Challenges 
• Data Types 
• Unstructured data 
• Semi-structured data 
• Polymorphic data
Benefits of MongoDB 
Relational Database Challenges 
• Data Types 
• Unstructured data 
• Semi-structured data 
• Polymorphic data 
• Agile Development 
• Iterative 
• Short development cycles 
• New workloads
Benefits of MongoDB 
Relational Database Challenges 
• Data Types 
• Unstructured data 
• Semi-structured data 
• Polymorphic data 
• Agile Development 
• Iterative 
• Short development cycles 
• New workloads 
• New Architectures 
• Horizontal scaling 
• Commodity servers 
• Cloud computing
Benefits of MongoDB 
Relational Database Challenges 
• Data Types 
• Unstructured data 
• Semi-structured data 
• Polymorphic data 
• Agile Development 
• Iterative 
• Short development cycles 
• New workloads 
• Volume of Data 
• Petabytes of data 
• Trillions of records 
• Millions of queries per second 
• New Architectures 
• Horizontal scaling 
• Commodity servers 
• Cloud computing
Good Use Cases
Use Cases 
• Applications never before 
possible 
• Volume, Variety, Velocity 
• Developer Productivity
Use Case - Single View
Use Case - Single View 
• 70+ systems 
• 50 million policies 
• 118 million customers 
• 190 million documents
Use Case - Single View 
• 70+ systems 
• 50 million policies 
• 118 million customers 
• 190 million documents
Use Case - Single View 
• 70+ systems 
• 50 million policies 
• 118 million customers 
• 190 million documents 
• Rolling out internationally 
• A version for its sales force 
• Real time prediction of 
customer attrition rates.
Use Case -Mobile
Use Case -Mobile
Use Case -Mobile
Use Case -Mobile 
• 2 million requests per day 
• 40 million users w/ alerts
Use Case -Mobile 
• 2 million requests per day 
• 40 million users w/ alerts 
• Mobile backend as a service for Facebook 
• 270,000+ apps 
• Unknown workload types 
• API requests growing 500% annually
Use Case -Analytics
Use Case -Analytics
Use Case -Analytics 
• Pairs MongoDB-powered analytics with visual maps 
• Provides real-time and historical information 
• Finds trends and relationships
Use Case -Analytics 
• Pairs MongoDB-powered analytics with visual maps 
• Provides real-time and historical information 
• Finds trends and relationships 
What’s next? The SmartData Platform 
• Predict best ways to cut traffic congestion 
• Analyze energy usage trends to improve efficiency 
• Map crime stats and city data relationships so crime can actually be reduced
Use Case -Analytics 
Real Time Analytics 
• Light-weight analytics very quickly 
• Sub-second response times 
• High availability requirements
Use Case -Analytics 
Real Time Analytics Batch Analytics 
• Complex, long-running analyses 
• Slower response times (minutes/days) 
• Lower availability requirements 
• Light-weight analytics very quickly 
• Sub-second response times 
• High availability requirements
Use Case -Analytics 
Informs 
Populates
“Bad” Use Cases
Use Case - Cache Only
Wrong Use Case 
• Developer productivity and satisfaction is not a concern for 
you 
• Limited vertical scalability is a comfort blanket 
• “It’s always been done this way” 
• You can see the future and know all possibilities for your 
schema

More Related Content

The Right (and Wrong) Use Cases for MongoDB

  • 1. The Right (And Wrong) Use Cases for MongoDB Damon LaCaille damon.lacaille@mongodb.com
  • 2. We’ll be covering... • About MongoDB • Benefits of using MongoDB • Specific Use Cases – Good: Single View, Mobile, Analytics – Not So Good... • Q&A
  • 4. Benefits of MongoDB • Performance • Availability and Scalability • Data Model • Query Model
  • 5. Benefits of MongoDB Performance Scalability and Performance Depth of Functionality
  • 6. Benefits of MongoDB Performance Scalability and Performance Key/Value Stores Cache Only Depth of Functionality
  • 7. Benefits of MongoDB Performance Scalability and Performance Key/Value Stores Depth of Functionality RDBMS Cache Only Highly Transactional
  • 8. Benefits of MongoDB Performance Scalability and Performance Key/Value Stores MongoDB Depth of Functionality RDBMS Mobile Content Mgmt. Analytics Cache Only Highly Transactional Internet of Things Single View Personalization Catalog
  • 9. Benefits of MongoDB Availability and Scalability Application mongod mongod mongod
  • 10. Benefits of MongoDB Availability and Scalability Application mongod mongod mongod mongod mongod mongod mongos [A-L] [M-Z]
  • 11. Benefits of MongoDB Availability and Scalability Application mongod mongod mongod mongod mongod mongod mongos | mongos | mongos mongod mongod mongod mongod mongod mongod mongod mongod mongod [A-E] [P-T] [F-J] [K-O] [U-Z]
  • 12. Benefits of MongoDB RDBMS -Hard to Make Changes New Table New Table New Column Name Age Phone Email
  • 13. Benefits of MongoDB RDBMS vs. Document Data Model Mental model Relational model
  • 14. Benefits of MongoDB RDBMS vs. Document Data Model Mental model Document model
  • 15. Benefits of MongoDB { : ‘Paul’, surname: ‘Miller’, cell: ‘+447557505611’ location: [45.123,47.232], profession: [banking, finance, trader], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } Natural Data Model
  • 16. Benefits of MongoDB { : ‘Paul’, surname: ‘Miller’, cell: ‘+447557505611’ location: [45.123,47.232], profession: [banking, finance, trader], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } Natural Data Model Field Names
  • 17. Benefits of MongoDB { : ‘Paul’, surname: ‘Miller’, cell: ‘+447557505611’ location: [45.123,47.232], profession: [banking, finance, trader], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } Natural Data Model Field Names Typed field values
  • 18. Benefits of MongoDB { : ‘Paul’, surname: ‘Miller’, cell: ‘+447557505611’ location: [45.123,47.232], profession: [banking, finance, trader], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } Natural Data Model Field Names Typed field values Fields can contain arrays
  • 19. Benefits of MongoDB { : ‘Paul’, surname: ‘Miller’, cell: ‘+447557505611’ location: [45.123,47.232], profession: [banking, finance, trader], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } Natural Data Model Field Names Typed field values Fields can contain arrays } Fields can contain an array of sub-documents
  • 20. Benefits of MongoDB Rich Query Model { : ‘Paul’, surname: ‘Miller’, cell: ‘+447557505611’ location: [45.123,47.232], profession: [banking, finance, trader], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } Rich Queries • Find Paul’s car • Find everybody in London with a car built between 1970 and 1980 Geo • Find all car owners within 10m of Manhattan Text Search • Find all cars whose VIN starts with ZA1 Aggregation • Calculate the average value of Paul’s car collection Map Reduce • What is the ownership pattern of colors by geography over time? (Is silver trending up in the US?)
  • 21. Benefits of MongoDB Relational Database Challenges
  • 22. Benefits of MongoDB Relational Database Challenges • Data Types • Unstructured data • Semi-structured data • Polymorphic data
  • 23. Benefits of MongoDB Relational Database Challenges • Data Types • Unstructured data • Semi-structured data • Polymorphic data • Agile Development • Iterative • Short development cycles • New workloads
  • 24. Benefits of MongoDB Relational Database Challenges • Data Types • Unstructured data • Semi-structured data • Polymorphic data • Agile Development • Iterative • Short development cycles • New workloads • New Architectures • Horizontal scaling • Commodity servers • Cloud computing
  • 25. Benefits of MongoDB Relational Database Challenges • Data Types • Unstructured data • Semi-structured data • Polymorphic data • Agile Development • Iterative • Short development cycles • New workloads • Volume of Data • Petabytes of data • Trillions of records • Millions of queries per second • New Architectures • Horizontal scaling • Commodity servers • Cloud computing
  • 27. Use Cases • Applications never before possible • Volume, Variety, Velocity • Developer Productivity
  • 28. Use Case - Single View
  • 29. Use Case - Single View • 70+ systems • 50 million policies • 118 million customers • 190 million documents
  • 30. Use Case - Single View • 70+ systems • 50 million policies • 118 million customers • 190 million documents
  • 31. Use Case - Single View • 70+ systems • 50 million policies • 118 million customers • 190 million documents • Rolling out internationally • A version for its sales force • Real time prediction of customer attrition rates.
  • 35. Use Case -Mobile • 2 million requests per day • 40 million users w/ alerts
  • 36. Use Case -Mobile • 2 million requests per day • 40 million users w/ alerts • Mobile backend as a service for Facebook • 270,000+ apps • Unknown workload types • API requests growing 500% annually
  • 39. Use Case -Analytics • Pairs MongoDB-powered analytics with visual maps • Provides real-time and historical information • Finds trends and relationships
  • 40. Use Case -Analytics • Pairs MongoDB-powered analytics with visual maps • Provides real-time and historical information • Finds trends and relationships What’s next? The SmartData Platform • Predict best ways to cut traffic congestion • Analyze energy usage trends to improve efficiency • Map crime stats and city data relationships so crime can actually be reduced
  • 41. Use Case -Analytics Real Time Analytics • Light-weight analytics very quickly • Sub-second response times • High availability requirements
  • 42. Use Case -Analytics Real Time Analytics Batch Analytics • Complex, long-running analyses • Slower response times (minutes/days) • Lower availability requirements • Light-weight analytics very quickly • Sub-second response times • High availability requirements
  • 43. Use Case -Analytics Informs Populates
  • 45. Use Case - Cache Only
  • 46. Wrong Use Case • Developer productivity and satisfaction is not a concern for you • Limited vertical scalability is a comfort blanket • “It’s always been done this way” • You can see the future and know all possibilities for your schema