Upload
mongodb
View
1.233
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Learn which use cases are an ideal fit for MongoDB.
Citation preview
The Right (And Wrong) Use Cases for MongoDB
Damon [email protected]
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 MongoDBPerformance
Sca
labili
ty a
nd P
erf
orm
ance
Depth of Functionality
Benefits of MongoDBPerformance
Sca
labili
ty a
nd P
erf
orm
ance
Depth of Functionality
Key/Value StoresCache Only
Benefits of MongoDBPerformance
Sca
labili
ty a
nd P
erf
orm
ance
Depth of Functionality
Key/Value Stores
RDBMS
Cache Only
Highly Transactional
Benefits of MongoDBPerformance
Sca
labili
ty a
nd P
erf
orm
ance
Depth of Functionality
Key/Value Stores
RDBMS
MongoDBMobile
AnalyticsContent Mgmt.
Cache Only
Highly Transactional
Internet of Things
Single View
PersonalizationCatalog
Benefits of MongoDBAvailability and Scalability
Application
mongod
mongod
mongod
Benefits of MongoDBAvailability and Scalability
Application
mongod
mongod
mongod mongo
d
mongod
mongod
mongos
[A-L] [M-Z]
Benefits of MongoDBAvailability and Scalability
Application
mongod
mongod
mongod
mongod
mongod
mongod
mongos | mongos | mongos
[A-E] [P-T]
mongod
mongod
mongod
mongod
mongod
mongodmongo
d
mongod
mongod
[F-J] [K-O] [U-Z]
Benefits of MongoDBRDBMS - Hard to Make Changes
New Table
New Table
New Colum
n
Benefits of MongoDBRDBMS vs. Document Data Model
Mental model
Relational model
Benefits of MongoDBRDBMS vs. Document Data Model
Mental model
Document model
{ first_name: ‘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, … } ]}
Benefits of MongoDBNatural Data Model
{ first_name: ‘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, … } ]}
Benefits of MongoDBNatural Data Model
Field Names
{ first_name: ‘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, … } ]}
Benefits of MongoDBNatural Data Model
Field NamesTyped field values
String
Geo coordinatesNumber
{ first_name: ‘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, … } ]}
Benefits of MongoDBNatural Data Model
Field NamesTyped field values
String
Geo coordinatesNumber
Fields cancontain arrays
{ first_name: ‘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, … } ]}
Benefits of MongoDBNatural Data Model
Field NamesTyped field values
String
Geo coordinatesNumber
}Fields can contain an arrayof sub-documents
Fields cancontain arrays
Benefits of MongoDBRich Query Model
{ first_name: ‘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 MongoDBRelational Database Challenges
Benefits of MongoDBRelational Database Challenges
• Data Types• Unstructured data• Semi-structured data• Polymorphic data
Benefits of MongoDBRelational Database Challenges
• Data Types• Unstructured data• Semi-structured data• Polymorphic data
• Agile Development• Iterative• Short development cycles• New workloads
Benefits of MongoDBRelational 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 MongoDBRelational 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
• 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
What’s next? The SmartData Platform
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