mongodb: what, why, when
DESCRIPTION
Massimo Brignoli @ MEAN Conference - 9 giugno 2014TRANSCRIPT
![Page 1: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/1.jpg)
MongoDB: What, why, when.
Solutions Architect, MongoDB Inc.
Massimo Brignoli
#mongodb
![Page 2: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/2.jpg)
Who Am I?
• Solutions Architect/Evangelist in MongoDB Inc.
• 24 years of experience in databases and software development
• Former MySQL employee
• Previous life: web, web, web
![Page 3: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/3.jpg)
Innovation
![Page 4: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/4.jpg)
Understanding Big Data – It’s Not Very “Big”
from Big Data Executive Summary – 50+ top executives from Government and F500 firms
64% - Ingest diverse, new data in real-time
15% - More than 100TB of data20% - Less than 100TB (average of all? <20TB)
![Page 5: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/5.jpg)
“I have not failed. I've just found 10,000 ways that won't work.” ― Thomas A. Edison
![Page 6: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/6.jpg)
Back in 1970…Cars Were Great!
![Page 7: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/7.jpg)
Lots of Great Innovations Since 1970
![Page 8: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/8.jpg)
Would you use these technologies for your business today?
![Page 9: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/9.jpg)
Including the Relational Database
![Page 10: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/10.jpg)
For which computers the relational model has been designed for?
![Page 11: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/11.jpg)
So Were Computers!
![Page 12: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/12.jpg)
And Storage!
![Page 13: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/13.jpg)
RDBMS Makes Development Hard
Relational DatabaseObject Relational
MappingApplication
Code XML Config DB Schema
![Page 14: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/14.jpg)
And Even Harder To Iterate
New Table
New Table
New Column
Name Pet Phone Email
New Column
3 months later…
![Page 15: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/15.jpg)
RDBMS
From Complexity to Simplicity
MongoDB
{ _id : ObjectId("4c4ba5e5e8aabf3"), employee_name: "Dunham, Justin", department : "Marketing", title : "Product Manager, Web", report_up: "Neray, Graham", pay_band: “C", benefits : [ { type : "Health", plan : "PPO Plus" }, { type : "Dental", plan : "Standard" } ] }
![Page 16: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/16.jpg)
MongoDB
The leading NoSQL database
Document Database
Open-Source
General Purpose
![Page 17: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/17.jpg)
7,000,000+ MongoDB Downloads
150,000+ Online Education Registrants
25,000+ MongoDB User Group Members
25,000+ MongoDB Days Attendees
20,000+ MongoDB Management Service (MMS) Users
Global Community
![Page 18: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/18.jpg)
To provide the best database for how we build and run apps today
MongoDB Vision
Build
– New and complex data
– Flexible
– New languages
– Faster development
Run
– Big Data scalability
– Real-time
– Commodity hardware
– Cloud
![Page 19: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/19.jpg)
Enterprise Big Data Stack
EDWHadoop
Man
agem
ent &
Mon
itorin
gSecurity &
Auditing
RDBMS
CRM, ERP, Collaboration, Mobile, BI
OS & Virtualization, Compute, Storage, Network
RDBMS
Applications
Infrastructure
Data Management
Online Data Offline Data
![Page 20: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/20.jpg)
Agile
MongoDB Overview
Scalable
![Page 21: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/21.jpg)
Operational Database Landscape
![Page 22: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/22.jpg)
Key → Value
• One-dimensional storage
• Single value is a blob
• Query on key only
• No schema
• Value cannot be updated, only replaced
Key Blob
![Page 23: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/23.jpg)
Relational/Wide Column
• Two-dimensional storage (tuples)
• Each field contains a single value
• Query on any field
• Very structured schema (table)
• In-place updates
• Normalization process requires many tables, joins, indexes, and poor data locality
Primary Key
![Page 24: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/24.jpg)
Document
• N-dimensional storage
• Each field can contain 0, 1, many, or embedded values
• Query on any field & level
• Flexible schema
• Inline updates *
• Embedding related data has optimal data locality, requires fewer indexes, has better performance
_id
![Page 25: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/25.jpg)
Document Data Model
Relational MongoDB
{ first_name: ‘Paul’, surname: ‘Miller’, city: ‘London’, location: [45.123,47.232], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] }
![Page 26: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/26.jpg)
Document Model Benefits
• Agility and flexibility – Data models can evolve easily – Companies can adapt to changes quickly
• Intuitive, natural data representation – Developers are more productive – 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
![Page 27: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/27.jpg)
Developers are more productive
![Page 28: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/28.jpg)
Developers are more productive
![Page 29: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/29.jpg)
Automatic Sharding
• Three types of sharding: hash-based, range-based, tag-aware!
• Increase or decrease capacity as you go!• Automatic balancing
![Page 30: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/30.jpg)
Query Routing
• Multiple query optimization models!• Each sharding option appropriate for different apps!
![Page 31: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/31.jpg)
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
![Page 32: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/32.jpg)
Replica Sets
• Replica Set – two or more copies!• “Self-healing” shard!• Addresses many concerns:!
- High Availability!
- Disaster Recovery!
- Maintenance
![Page 33: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/33.jpg)
Strong Consistency
![Page 34: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/34.jpg)
Delayed Consistency
![Page 35: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/35.jpg)
Write Concern
• Network acknowledgement
• Wait for error
• Wait for journal sync
• Wait for replication
![Page 36: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/36.jpg)
Unacknowledged
![Page 37: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/37.jpg)
MongoDB Acknowledged (wait for error)
![Page 38: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/38.jpg)
Wait for Journal Sync
![Page 39: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/39.jpg)
Wait for Replication
![Page 40: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/40.jpg)
Tagging
• Control where data is written to, and read from
• Each member can have one or more tags – tags: {dc: "ny"} – tags: {dc: "ny",
subnet: "192.168", rack: "row3rk7"}
• Replica set defines rules for write concerns
• Rules can change without changing app code
![Page 41: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/41.jpg)
{! _id : "mySet",! members : [! {_id : 0, host : "A", tags : {"dc": "ny"}},! {_id : 1, host : "B", tags : {"dc": "ny"}},! {_id : 2, host : "C", tags : {"dc": "sf"}},! {_id : 3, host : "D", tags : {"dc": "sf"}},! {_id : 4, host : "E", tags : {"dc": "cloud"}}],! settings : {! getLastErrorModes : {! allDCs : {"dc" : 3},! someDCs : {"dc" : 2}} }!}!> db.blogs.insert({...})!> db.runCommand({getLastError : 1, w : "someDCs"})
Tagging Example
![Page 42: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/42.jpg)
Wait for Replication (Tagging)
![Page 43: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/43.jpg)
Read Preference Modes
• 5 modes – primary (only) - Default – primaryPreferred – secondary – secondaryPreferred – Nearest !
When more than one node is possible, closest node is used for reads (all modes but primary)
![Page 44: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/44.jpg)
Single Data Center
• Automated failover !• Tolerates server failures!• Tolerates rack failures!• Number of replicas
defines failure tolerance
Primary – A Primary – B Primary – C
Secondary – A Secondary – ASecondary – B
Secondary – BSecondary – CSecondary – C
![Page 45: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/45.jpg)
Active/Standby Data Center
• Tolerates server and rack failure!• Standby data center
Data Center - West
Primary – A Primary – B Primary – C
Secondary – ASecondary – B Secondary – C
Data Center - East
Secondary – A Secondary – B Secondary – C
![Page 46: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/46.jpg)
Active/Active Data Center
• Tolerates server, rack, data center failures, network partitions
Data Center - West
Primary – A Primary – B Primary – C
Secondary – A Secondary – BSecondary – C
Data Center - East
Secondary – A Secondary – B Secondary – C
Secondary – B Secondary – C Secondary – A
Data Center - Central
Arbiter – A Arbiter – B Arbiter – C
![Page 47: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/47.jpg)
Global Data Distribution
Real-time
Real-time Real-time
Real-time
Real-time
Real-time
Real-time
Primary
Secondary
Secondary
Secondary
Secondary
Secondary
Secondary
Secondary
![Page 48: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/48.jpg)
Read Global/Write Local
Primary:NYC
Secondary:NYC
Primary:LON
Primary:SYD
Secondary:LON
Secondary:NYC
Secondary:SYD
Secondary:LON
Secondary:SYD
![Page 49: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/49.jpg)
Common Use Cases
![Page 50: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/50.jpg)
High Volume Data Feeds
••More machine forms, sensors & data ••Variably structured
Machine Generated Data
••High frequency trading ••Daily closing priceSecurities Data
••Multiple data sources ••Each changes their format consistently ••Student Scores, ISP logs
Social Media /
General Public
![Page 51: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/51.jpg)
Operational Intelligence
••Large volume of users ••Very strict latency requirements ••Sentiment Analysis
Ad Targeting
••Expose data to millions of customers ••Reports on large volumes of data ••Reports that update in real time
Real time dashboards
••Join the conversation ••Catered Games ••Customized Surveys
Social Media Monitoring
![Page 52: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/52.jpg)
Metadata
••Diverse product portfolio ••Complex querying and filtering ••Multi-faceted product attributes
Product Catalogue
••Data mining ••Call records ••Insurance Claims
Data analysis
••Retina Scans ••FingerprintsBiometric
![Page 53: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/53.jpg)
Content Management
••Comments and user generated content ••Personalization of content and layoutNews Site
••Generate layout on the fly ••No need to cache static pages
Multi-device rendering
••Store large objects ••Simpler modeling of metadataSharing
![Page 54: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/54.jpg)
Questions?
![Page 55: MongoDB: What, why, when](https://reader034.vdocuments.net/reader034/viewer/2022052618/554bcda7b4c905ac708b475a/html5/thumbnails/55.jpg)
Thanks!
@massimobrignoli
Massimo Brignoli
#MongoDB
Solutions Architect, MongoDB Inc.