SlideShare uma empresa Scribd logo
1 de 31
Staffel 1: MongoDB
Applikationsentwicklung
Marc Schwering
@m4rcsch
#MongoDBBasics
Einführung in MongoDB – “Back to Basics”
2
• Fragen im Chat oder via Twitter:
#MonogDBBasics
• Das Webinar ist auf deutsch, die Folien sind in
englisch
• Die Serie wird ist in zwei Staffeln gegliedert
– Applikationsentwicklung mit MongoDB
– MongoDB in produktion / „operations“
• Das Webinar wird aufgezeichnet
Generelle Informationen
3
• About the Webinar Series
• Data Model
• Query Model
• Scalability
• Availability
• Deployment Architectures
• Performance
• Next Session
Introduction
4
• Split into 2 seasons
– Application Development (4 parts)
• Schema Design
• Interacting with the database query and update operators
• Indexing
• Aggregation & Reporting
– Operations (3 parts)
• Deployment – scale out and high availability
• Monitoring and performance tuning
• Backup and recovery
Series Outline & Approach
5
• Content Management System
– Will utilise :
• Query & update operators
• Aggregation Framework
• Geospatial queries
• Pre Aggregated reports for fast analytics
• Polymorphic documents
• And more…
• Take away framework
• An approach that you can reuse in your own
applications
Application Overview
6
• Virtual Genius Bar
– Use the chat to post
questions
– EMEA Solution
Architecture team are
on hand
– Make use of them
during the sessions!!!
Q & A
MongoDB
8
Operational Database
9
Document Data Model
Relational - Tables
{ first_name: ‘Paul’,
surname: ‘Miller’,
city: ‘London’,
location: {
type: “Point”,
coordinates :
[-0.128, 51.507]
},
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
}
}
Document - Collections
10
Document Model
• Agility and flexibility – dynamic schema
– Data models can evolve easily
– Companies can adapt to changes quickly
• Intuitive, natural data representation
– Remove impedance mismatch
– Many types of applications are a good fit
• Reduces the need for joins, disk seeks
– Programming is more simple
– Performance can be delivered at scale
11
Simplify development
12
Simplify development
13
Rich database interaction
Query Model
15
Shell
Command-line shell for
interacting directly with
database
Shell and Drivers
Drivers
Drivers for most popular
programming languages and
frameworks
> db.collection.insert({company:“10gen”,
product:“MongoDB”})
>
> db.collection.findOne()
{
“_id” : ObjectId(“5106c1c2fc629bfe52792e86”),
“company” : “10gen”
“product” : “MongoDB”
}
Java
Python
Perl
Ruby
Haskell
JavaScript
16
MongoDB is full featured
Queries
• Find Paul’s cars
• Find everybody in London with a car
built between 1970 and 1980
Geospatial
• Find all of the car owners within 5km of
Trafalgar Sq.
Text Search
• Find all the cars described as having
leather seats
Aggregation
• Calculate the average value of Paul’s
car collection
Map Reduce
• What is the ownership pattern of colors
by geography over time? (is purple
trending up in China?)
{ first_name: ‘Paul’,
surname: ‘Miller’,
city: ‘London’,
location: {
type: “Point”,
coordinates :
[-0.128, 51.507]
},
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
}
}
17
Query Example
Rich Queries
• Find Paul’s cars
• Find everybody in London with a car
built between 1970 and 1980
db.cars.find({
first_name: ‘Paul’
})
db.cars.find({
city: ‘London’,
”cars.year" : {
$gte : 1970,
$lte : 1980
}
})
{ first_name: ‘Paul’,
surname: ‘Miller’,
city: ‘London’,
location: {
type: “Point”,
coordinates :
[-0.128, 51.507]
},
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
}
}
18
Geo Spatial Example
db.cars.find( {
location:
{ $near :
{ $geometry :
{ type: 'Point' ,
coordinates :
[-0.128,
51.507]
}
},
$maxDistance :5000
}
} )
Geospatial
• Find all of the car owners within 5km of
Trafalgar Sq.
{ first_name: ‘Paul’,
surname: ‘Miller’,
city: ‘London’,
location: {
type: “Point”,
coordinates :
[-0.128, 51.507]
},
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
}
}
19
Aggregation Framework Example
db.cars.aggregate( [
{$match : {"first_name" : "Paul"}},
{$project : {"first_name":1,"cars":1}},
{$unwind : "$cars"},
{ $group : {_id:"$first_name",
average : {
$avg : "$cars.value"}}}
])
{ "_id" : "Paul", "average" : 215000 }
Aggregation
• Calculate the average value of Paul’s
car collection
{ first_name: ‘Paul’,
surname: ‘Miller’,
city: ‘London’,
location: {
type: “Point”,
coordinates :
[-0.128, 51.507]
},
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
}
}
Scalability
21
Automatic Sharding
• Three types of sharding: hash-based, range-based, tag-
aware
• Increase or decrease capacity as you go
• Automatic balancing
22
Query Routing
• Multiple query optimization models
• Each sharding option appropriate for different apps
Availability
24
• High Availability – Ensure application availability during
many types of failures
• Disaster Recovery – Address the RTO and RPO goals
for business continuity
• Maintenance – Perform upgrades and other maintenance
operations with no application downtime
Availability Considerations
25
Replica Sets
• Replica Set – two or more copies
• “Self-healing” shard
• Addresses many concerns:
- High Availability
- Disaster Recovery
- Maintenance
26
Replica Set Benefits
Business Needs Replica Set Benefits
High Availability Automated failover
Disaster Recovery Hot backups offsite
Maintenance Rolling upgrades
Low Latency Locate data near users
Workload Isolation Read from non-primary replicas
Data Privacy Restrict data to physical location
Data Consistency Tunable Consistency
Performance
28
Better Data
Locality
Performance
In-Memory
Caching
In-Place
Updates
29
• Document Model
– Simplify development
– Simplify scale out
– Improve performance
• MongoDB
– Rich general purpose database
– Built in High Availability and Failover
– Built in scale out
Summary
30
• Marc Schwering
– Schema design for the CMS application
• Collections
• Design decisions
– Application architecture
• Example technologies
• RESTful interface
• We’ve chosen python for the examples
– Code Examples
Next Week – 7th May
S01 e00 einfuehrung-in_mongodb

Mais conteúdo relacionado

Semelhante a S01 e00 einfuehrung-in_mongodb

Building your First MEAN App
Building your First MEAN AppBuilding your First MEAN App
Building your First MEAN App
MongoDB
 

Semelhante a S01 e00 einfuehrung-in_mongodb (20)

Webinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to BasicsWebinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to Basics
 
Building your First MEAN App
Building your First MEAN AppBuilding your First MEAN App
Building your First MEAN App
 
Python Ireland Conference 2016 - Python and MongoDB Workshop
Python Ireland Conference 2016 - Python and MongoDB WorkshopPython Ireland Conference 2016 - Python and MongoDB Workshop
Python Ireland Conference 2016 - Python and MongoDB Workshop
 
MongoDB Basics
MongoDB BasicsMongoDB Basics
MongoDB Basics
 
Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...
 
MongoDB Evenings DC: MongoDB - The New Default Database for Giant Ideas
MongoDB Evenings DC: MongoDB - The New Default Database for Giant IdeasMongoDB Evenings DC: MongoDB - The New Default Database for Giant Ideas
MongoDB Evenings DC: MongoDB - The New Default Database for Giant Ideas
 
tranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And When
tranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And WhentranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And When
tranSMART Community Meeting 5-7 Nov 13 - Session 2: MongoDB: What, Why And When
 
Webinar: “ditch Oracle NOW”: Best Practices for Migrating to MongoDB
 Webinar: “ditch Oracle NOW”: Best Practices for Migrating to MongoDB Webinar: “ditch Oracle NOW”: Best Practices for Migrating to MongoDB
Webinar: “ditch Oracle NOW”: Best Practices for Migrating to MongoDB
 
Webinar: General Technical Overview of MongoDB for Ops Teams
Webinar: General Technical Overview of MongoDB for Ops TeamsWebinar: General Technical Overview of MongoDB for Ops Teams
Webinar: General Technical Overview of MongoDB for Ops Teams
 
Building your first MEAN application
Building your first MEAN applicationBuilding your first MEAN application
Building your first MEAN application
 
MongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and Implications
 
Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101
 
Novedades de MongoDB 3.6
Novedades de MongoDB 3.6Novedades de MongoDB 3.6
Novedades de MongoDB 3.6
 
Introduction to new high performance storage engines in mongodb 3.0
Introduction to new high performance storage engines in mongodb 3.0Introduction to new high performance storage engines in mongodb 3.0
Introduction to new high performance storage engines in mongodb 3.0
 
Webinar: Schema Patterns and Your Storage Engine
Webinar: Schema Patterns and Your Storage EngineWebinar: Schema Patterns and Your Storage Engine
Webinar: Schema Patterns and Your Storage Engine
 
Agility and Scalability with MongoDB
Agility and Scalability with MongoDBAgility and Scalability with MongoDB
Agility and Scalability with MongoDB
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
 
MongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 Minutes
MongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 MinutesMongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 Minutes
MongoDB World 2018: Tutorial - MongoDB & NodeJS: Zero to Hero in 80 Minutes
 
Webinar: When to Use MongoDB
Webinar: When to Use MongoDBWebinar: When to Use MongoDB
Webinar: When to Use MongoDB
 
Confluent & MongoDB APAC Lunch & Learn
Confluent & MongoDB APAC Lunch & LearnConfluent & MongoDB APAC Lunch & Learn
Confluent & MongoDB APAC Lunch & Learn
 

Mais de MongoDB

Mais de MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

S01 e00 einfuehrung-in_mongodb

  • 1. Staffel 1: MongoDB Applikationsentwicklung Marc Schwering @m4rcsch #MongoDBBasics Einführung in MongoDB – “Back to Basics”
  • 2. 2 • Fragen im Chat oder via Twitter: #MonogDBBasics • Das Webinar ist auf deutsch, die Folien sind in englisch • Die Serie wird ist in zwei Staffeln gegliedert – Applikationsentwicklung mit MongoDB – MongoDB in produktion / „operations“ • Das Webinar wird aufgezeichnet Generelle Informationen
  • 3. 3 • About the Webinar Series • Data Model • Query Model • Scalability • Availability • Deployment Architectures • Performance • Next Session Introduction
  • 4. 4 • Split into 2 seasons – Application Development (4 parts) • Schema Design • Interacting with the database query and update operators • Indexing • Aggregation & Reporting – Operations (3 parts) • Deployment – scale out and high availability • Monitoring and performance tuning • Backup and recovery Series Outline & Approach
  • 5. 5 • Content Management System – Will utilise : • Query & update operators • Aggregation Framework • Geospatial queries • Pre Aggregated reports for fast analytics • Polymorphic documents • And more… • Take away framework • An approach that you can reuse in your own applications Application Overview
  • 6. 6 • Virtual Genius Bar – Use the chat to post questions – EMEA Solution Architecture team are on hand – Make use of them during the sessions!!! Q & A
  • 9. 9 Document Data Model Relational - Tables { first_name: ‘Paul’, surname: ‘Miller’, city: ‘London’, location: { type: “Point”, coordinates : [-0.128, 51.507] }, cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } } } Document - Collections
  • 10. 10 Document Model • Agility and flexibility – dynamic schema – Data models can evolve easily – Companies can adapt to changes quickly • Intuitive, natural data representation – Remove impedance mismatch – Many types of applications are a good fit • Reduces the need for joins, disk seeks – Programming is more simple – Performance can be delivered at scale
  • 15. 15 Shell Command-line shell for interacting directly with database Shell and Drivers Drivers Drivers for most popular programming languages and frameworks > db.collection.insert({company:“10gen”, product:“MongoDB”}) > > db.collection.findOne() { “_id” : ObjectId(“5106c1c2fc629bfe52792e86”), “company” : “10gen” “product” : “MongoDB” } Java Python Perl Ruby Haskell JavaScript
  • 16. 16 MongoDB is full featured Queries • Find Paul’s cars • Find everybody in London with a car built between 1970 and 1980 Geospatial • Find all of the car owners within 5km of Trafalgar Sq. Text Search • Find all the cars described as having leather seats Aggregation • Calculate the average value of Paul’s car collection Map Reduce • What is the ownership pattern of colors by geography over time? (is purple trending up in China?) { first_name: ‘Paul’, surname: ‘Miller’, city: ‘London’, location: { type: “Point”, coordinates : [-0.128, 51.507] }, cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } } }
  • 17. 17 Query Example Rich Queries • Find Paul’s cars • Find everybody in London with a car built between 1970 and 1980 db.cars.find({ first_name: ‘Paul’ }) db.cars.find({ city: ‘London’, ”cars.year" : { $gte : 1970, $lte : 1980 } }) { first_name: ‘Paul’, surname: ‘Miller’, city: ‘London’, location: { type: “Point”, coordinates : [-0.128, 51.507] }, cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } } }
  • 18. 18 Geo Spatial Example db.cars.find( { location: { $near : { $geometry : { type: 'Point' , coordinates : [-0.128, 51.507] } }, $maxDistance :5000 } } ) Geospatial • Find all of the car owners within 5km of Trafalgar Sq. { first_name: ‘Paul’, surname: ‘Miller’, city: ‘London’, location: { type: “Point”, coordinates : [-0.128, 51.507] }, cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } } }
  • 19. 19 Aggregation Framework Example db.cars.aggregate( [ {$match : {"first_name" : "Paul"}}, {$project : {"first_name":1,"cars":1}}, {$unwind : "$cars"}, { $group : {_id:"$first_name", average : { $avg : "$cars.value"}}} ]) { "_id" : "Paul", "average" : 215000 } Aggregation • Calculate the average value of Paul’s car collection { first_name: ‘Paul’, surname: ‘Miller’, city: ‘London’, location: { type: “Point”, coordinates : [-0.128, 51.507] }, cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } } }
  • 21. 21 Automatic Sharding • Three types of sharding: hash-based, range-based, tag- aware • Increase or decrease capacity as you go • Automatic balancing
  • 22. 22 Query Routing • Multiple query optimization models • Each sharding option appropriate for different apps
  • 24. 24 • High Availability – Ensure application availability during many types of failures • Disaster Recovery – Address the RTO and RPO goals for business continuity • Maintenance – Perform upgrades and other maintenance operations with no application downtime Availability Considerations
  • 25. 25 Replica Sets • Replica Set – two or more copies • “Self-healing” shard • Addresses many concerns: - High Availability - Disaster Recovery - Maintenance
  • 26. 26 Replica Set Benefits Business Needs Replica Set Benefits High Availability Automated failover Disaster Recovery Hot backups offsite Maintenance Rolling upgrades Low Latency Locate data near users Workload Isolation Read from non-primary replicas Data Privacy Restrict data to physical location Data Consistency Tunable Consistency
  • 29. 29 • Document Model – Simplify development – Simplify scale out – Improve performance • MongoDB – Rich general purpose database – Built in High Availability and Failover – Built in scale out Summary
  • 30. 30 • Marc Schwering – Schema design for the CMS application • Collections • Design decisions – Application architecture • Example technologies • RESTful interface • We’ve chosen python for the examples – Code Examples Next Week – 7th May