The Right (and Wrong) Use Cases for MongoDB

46
The Right (And Wrong) Use Cases for MongoDB Damon LaCaille [email protected]

description

Learn which use cases are an ideal fit for MongoDB.

Transcript of The Right (and Wrong) Use Cases for MongoDB

Page 1: The Right (and Wrong) Use Cases for MongoDB

The Right (And Wrong) Use Cases for MongoDB

Damon [email protected]

Page 2: The Right (and Wrong) Use Cases for MongoDB

We’ll be covering...

• About MongoDB• Benefits of using MongoDB• Specific Use Cases– Good: Single View, Mobile, Analytics– Not So Good...

• Q&A

Page 3: The Right (and Wrong) Use Cases for MongoDB

About MongoDB

Page 4: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDB

• Performance

• Availability and Scalability

• Data Model

• Query Model

Page 5: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBPerformance

Sca

labili

ty a

nd P

erf

orm

ance

Depth of Functionality

Page 6: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBPerformance

Sca

labili

ty a

nd P

erf

orm

ance

Depth of Functionality

Key/Value StoresCache Only

Page 7: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBPerformance

Sca

labili

ty a

nd P

erf

orm

ance

Depth of Functionality

Key/Value Stores

RDBMS

Cache Only

Highly Transactional

Page 8: The Right (and Wrong) Use Cases for MongoDB

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

Page 9: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBAvailability and Scalability

Application

mongod

mongod

mongod

Page 10: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBAvailability and Scalability

Application

mongod

mongod

mongod mongo

d

mongod

mongod

mongos

[A-L] [M-Z]

Page 11: The Right (and Wrong) Use Cases for MongoDB

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]

Page 12: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBRDBMS - Hard to Make Changes

New Table

New Table

New Colum

n

Page 13: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBRDBMS vs. Document Data Model

Mental model

Relational model

Page 14: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBRDBMS vs. Document Data Model

Mental model

Document model

Page 15: The Right (and Wrong) Use Cases for MongoDB

{ 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

Page 16: The Right (and Wrong) Use Cases for MongoDB

{ 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

Page 17: The Right (and Wrong) Use Cases for MongoDB

{ 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

Page 18: The Right (and Wrong) Use Cases for MongoDB

{ 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

Page 19: The Right (and Wrong) Use Cases for MongoDB

{ 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

Page 20: The Right (and Wrong) Use Cases for MongoDB

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?)

Page 21: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBRelational Database Challenges

Page 22: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBRelational Database Challenges

• Data Types• Unstructured data• Semi-structured data• Polymorphic data

Page 23: The Right (and Wrong) Use Cases for MongoDB

Benefits of MongoDBRelational Database Challenges

• Data Types• Unstructured data• Semi-structured data• Polymorphic data

• Agile Development• Iterative• Short development cycles• New workloads

Page 24: The Right (and Wrong) Use Cases for MongoDB

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

Page 25: The Right (and Wrong) Use Cases for MongoDB

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

Page 26: The Right (and Wrong) Use Cases for MongoDB

Good Use Cases

Page 27: The Right (and Wrong) Use Cases for MongoDB

Use Cases

• Applications never before

possible

• Volume, Variety, Velocity

• Developer Productivity

Page 28: The Right (and Wrong) Use Cases for MongoDB

Use Case - Single View

Page 29: The Right (and Wrong) Use Cases for MongoDB

Use Case - Single View

• 70+ systems• 50 million policies• 118 million customers• 190 million documents

Page 30: The Right (and Wrong) Use Cases for MongoDB

Use Case - Single View

• 70+ systems• 50 million policies• 118 million customers• 190 million documents

Page 31: The Right (and Wrong) Use Cases for MongoDB

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.

Page 32: The Right (and Wrong) Use Cases for MongoDB

Use Case - Mobile

Page 33: The Right (and Wrong) Use Cases for MongoDB

Use Case - Mobile

Page 34: The Right (and Wrong) Use Cases for MongoDB

Use Case - Mobile

Page 35: The Right (and Wrong) Use Cases for MongoDB

Use Case - Mobile

• 2 million requests per day• 40 million users w/ alerts

Page 36: The Right (and Wrong) Use Cases for MongoDB

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

Page 37: The Right (and Wrong) Use Cases for MongoDB

Use Case - Analytics

Page 38: The Right (and Wrong) Use Cases for MongoDB

Use Case - Analytics

Page 39: The Right (and Wrong) Use Cases for MongoDB

Use Case - Analytics

• Pairs MongoDB-powered analytics with visual maps

• Provides real-time and historical information

• Finds trends and relationships

Page 40: The Right (and Wrong) Use Cases for MongoDB

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

Page 41: The Right (and Wrong) Use Cases for MongoDB

Use Case - Analytics

Real Time Analytics

• Light-weight analytics very quickly

• Sub-second response times

• High availability requirements

Page 42: The Right (and Wrong) Use Cases for MongoDB

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

Page 43: The Right (and Wrong) Use Cases for MongoDB

Use Case - Analytics

Informs

Populates

Page 44: The Right (and Wrong) Use Cases for MongoDB

“Bad” Use Cases

Page 45: The Right (and Wrong) Use Cases for MongoDB

Use Case - Cache Only

Page 46: The Right (and Wrong) Use Cases for MongoDB

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