SlideShare a Scribd company logo
1 of 45
#mongodb 
Build your first app; 
an introduction to MongoDB 
Christian Amor Kvalheim 
Developer Experience Team Lead, MongoDB
Christian Kvalheim 
• Team Lead MongoDB Drivers 
• Node.js driver developer 
• Been using MongoDB for 5 years 
• Working at MongoDB last 3 years
What is MongoDB?
MongoDB is a ___________ 
database 
• Document 
• Open source 
• High performance 
• Horizontally scalable 
• Full featured
Document Database 
• Not for .PDF & .DOC files 
• A document is essentially an associative array 
• Document = JSON object 
• Document = PHP Array 
• Document = Python Dict 
• Document = Ruby Hash 
• etc
Open Source 
• MongoDB is an open source project 
• On GitHub 
• Licensed under the AGPL 
• Started & sponsored by MongoDB Inc 
• Commercial licenses available 
• Contributions welcome
High Performance 
• Written in C++ 
• Extensive use of memory-mapped files 
i.e. read-through write-through memory caching. 
• Runs nearly everywhere 
• Data serialized as BSON (fast parsing) 
• Full support for primary & secondary indexes 
• Document model = agile development
Database Landscape
Full Featured 
• Flexible schema 
• Rich ad-hoc queries 
• Real time aggregation 
• Strongly consistent 
• Geospatial features 
• Built-in automatic failover 
• Horizontally scalable reads/writes 
• Support for most programming languages
mongodb.org/downloads
Running MongoDB 
$ tar zxf mongodb-osx-x86_64-2.6.4.tgz 
$ cd mongodb-osx-x86_64-2.6.4/bin 
$ mkdir –p /data/db 
$ ./mongod
Mongo Shell 
$ mongo 
MongoDB shell version: 2.6.4 
connecting to: test 
> db.test.insert({text: 'Welcome to MongoDB'}) 
> db.test.find().pretty() 
{ 
"_id" : ObjectId("51c34130fbd5d7261b4cdb55"), 
"text" : "Welcome to MongoDB" 
}
Building an App with 
MongoDB
Terminology 
RDBMS MongoDB 
Table, View ➜ Collection 
Row ➜ Document 
Index ➜ Index 
Join ➜ Embedded Document 
Foreign Key ➜ Reference 
Partition ➜ Shard
Let’s Build a Monitoring System
First step in any application is 
Determine basic requirements
Basic Monitoring Requirements 
• Data generated at per-second intervals 
• Metrics to capture (ex. CPU, memory, IO) 
• Document structure for fast writes and easy reads
In a relational base app 
We would start by doing schema 
design
Relational Schema Options 
CPU Metrics 
Memory Metrics 
IO Metrics 
Events 
• Timestamp 
• CPU metrics 
• Memory metrics 
• IO metrics 
Or
In a MongoDB based app 
We start with a generic model 
and let the documents evolve
MongoDB Document Modeling 
Events 
Timestamp (min) 
CPU [] 
• Second 
• Metric 
Memory [] 
• Second 
• Metric 
IO [] 
• Second 
• Metric
Working With MongoDB
Start with the Mongo Shell 
$ mongo 
MongoDB shell version: 2.6.4 
connecting to: test 
> 
Full Javascript shell
Switch to Your DB 
> use monitoring 
switching to db monitoring 
DB files are created once you save a 
document
Create an Empty Event 
> var event = { 
ts: ISODate(“2014-09-16T09:00:00”), 
cpu: [ 0, 0, …, 0 ], 
memory: [ 0, 0, …, 0 ], 
io: [ 0, 0, …, 0 ], 
} 
Insert zeroed-out arrays to fill in later
Insert the Event 
> db.events.insert(event) 
No collection creation necessary
Find One Record 
> db.events.findOne() 
{ 
"_id" : ObjectId("50804d0bd94ccab2da652599"), 
”ts" : ISODate(“2014-09-16T09:00:00”), 
”cpu" : [ 0, 0, …, 0 ], 
”memory" : [ 0, 0, …, 0 ], 
“io” : [ 0, 0, …, 0 ] 
}
How do you capture events? 
Serve 
r 
Serve 
r 
Serve 
r 
MongoD 
B 
memory 
interaction 
interaction 
interaction
Adding a New Event 
> db.events.update( 
{ ts: ISODate(“2014-09-16T09:00:00”) } 
{ $set: { 
“cpu.0” : 50, 
“memory.0”: 1500, 
“io.0”: 10 } 
} 
) 
Use atomic in-place updates to add metric values
How do you plot charts?
Finding an Hour of Events 
> db.events.find({ 
ts: { 
$gte: ISODate(“2014-09-16T09:00:00”), 
$lt: ISODate(“2014-09-16T10:00:00”) 
} 
}).sort({ts:1}) 
Find using a range and sort results 
ascending
How do you roll up the data? 
Hour Avg Cpu 
0 50 
1 65 
2 75 
3 40 
4 45 
5 60 
6 25 
… … 
23 30
Aggregate Metrics 
> db.events.aggregate([ 
{ $match: { ts: { $gte: date0, $lt: date1 } } }, 
{ $project: { _id: 0, ts: 1, cpu: 1 } }, 
{ $unwind: “$cpu” }, 
{ $group: { 
_id: { $hour: “$ts” }, 
avg_cpu: { $avg: “$cpu” } } } 
]) 
Use Aggregation Framework to roll up data
How do you scale this workload 
• Replica Sets 
– Add data redundancy 
– Automatic failover 
– Tunable durability, consistency 
• Sharding 
– Scale reads and writes 
– Support dynamic data growth 
– Automatically partitions workload 
– Horizontally scalable
MongoDB Drivers
Real applications are not 
built in the shell
MongoDB has native 
bindings for over 12 
languages
MongoDB Drivers 
• Official Support for 12 languages 
• Community drivers for tons more 
• Drivers connect to MongoDB servers 
• Drivers translate BSON into native types 
• Shell is not a driver, but works like one in some ways 
• Installed using typical means (npm, pecl, gem, pip)
docs.mongodb.org
Online Training at MongoDB 
University
Suggestions for Talks 
• Talk to me at Meet the Experts 
– 11 am – 12 pm 
– 1 pm – 2 pm 
– Or catch me in the hallway 
• MongoDB for the internet of things 
• Socialite the Open Source Status Feed 
• The Future of MongoDB Storage
Questions?
#mongodb 
Thank You 
Christian Amor Kvalheim 
Developer Experience Team Lead, MongoDB

More Related Content

What's hot

MongoDB : The Definitive Guide
MongoDB : The Definitive GuideMongoDB : The Definitive Guide
MongoDB : The Definitive Guide
Wildan Maulana
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Justin Smestad
 

What's hot (20)

Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
MongoDB : The Definitive Guide
MongoDB : The Definitive GuideMongoDB : The Definitive Guide
MongoDB : The Definitive Guide
 
Mongodb
MongodbMongodb
Mongodb
 
MongoDB
MongoDBMongoDB
MongoDB
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
Mastering the MongoDB Shell
Mastering the MongoDB ShellMastering the MongoDB Shell
Mastering the MongoDB Shell
 
Understanding and tuning WiredTiger, the new high performance database engine...
Understanding and tuning WiredTiger, the new high performance database engine...Understanding and tuning WiredTiger, the new high performance database engine...
Understanding and tuning WiredTiger, the new high performance database engine...
 
Back to Basics 2017: Introduction to Sharding
Back to Basics 2017: Introduction to ShardingBack to Basics 2017: Introduction to Sharding
Back to Basics 2017: Introduction to Sharding
 
Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011
 
MongoDB
MongoDBMongoDB
MongoDB
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB Application
 
Back to Basics Webinar 3: Introduction to Replica Sets
Back to Basics Webinar 3: Introduction to Replica SetsBack to Basics Webinar 3: Introduction to Replica Sets
Back to Basics Webinar 3: Introduction to Replica Sets
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Back to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDBBack to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDB
 
High Performance Applications with MongoDB
High Performance Applications with MongoDBHigh Performance Applications with MongoDB
High Performance Applications with MongoDB
 
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in GoPutting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
 
Webinar: Was ist neu in MongoDB 2.4
Webinar: Was ist neu in MongoDB 2.4Webinar: Was ist neu in MongoDB 2.4
Webinar: Was ist neu in MongoDB 2.4
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
 

Viewers also liked

Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revised
MongoDB
 
Internal Anatomy of an Update
Internal Anatomy of an UpdateInternal Anatomy of an Update
Internal Anatomy of an Update
MongoDB
 

Viewers also liked (9)

Why NoSQL Makes Sense
Why NoSQL Makes SenseWhy NoSQL Makes Sense
Why NoSQL Makes Sense
 
Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revised
 
Lightning Talk: MongoDB Migration Strategies
Lightning Talk: MongoDB Migration StrategiesLightning Talk: MongoDB Migration Strategies
Lightning Talk: MongoDB Migration Strategies
 
Webinar Italiano: Back-to-Basics: Sessione 8 - Monitoraggio e Performance Tuning
Webinar Italiano: Back-to-Basics: Sessione 8 - Monitoraggio e Performance TuningWebinar Italiano: Back-to-Basics: Sessione 8 - Monitoraggio e Performance Tuning
Webinar Italiano: Back-to-Basics: Sessione 8 - Monitoraggio e Performance Tuning
 
Internal Anatomy of an Update
Internal Anatomy of an UpdateInternal Anatomy of an Update
Internal Anatomy of an Update
 
MongoDB and the Connectivity Map: Making Connections Between Genetics and Dis...
MongoDB and the Connectivity Map: Making Connections Between Genetics and Dis...MongoDB and the Connectivity Map: Making Connections Between Genetics and Dis...
MongoDB and the Connectivity Map: Making Connections Between Genetics and Dis...
 
Hidden Gems in the 2.6 Release
Hidden Gems in the 2.6 ReleaseHidden Gems in the 2.6 Release
Hidden Gems in the 2.6 Release
 
MongoDB IoT City Tour EINDHOVEN: Analysing the Internet of Things: Davy Nys, ...
MongoDB IoT City Tour EINDHOVEN: Analysing the Internet of Things: Davy Nys, ...MongoDB IoT City Tour EINDHOVEN: Analysing the Internet of Things: Davy Nys, ...
MongoDB IoT City Tour EINDHOVEN: Analysing the Internet of Things: Davy Nys, ...
 
Agility and Scalability with MongoDB
Agility and Scalability with MongoDBAgility and Scalability with MongoDB
Agility and Scalability with MongoDB
 

Similar to Dev Jumpstart: Build Your First App with MongoDB

Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesign
MongoDB APAC
 
Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDB
MongoDB
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
rfischer20
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 

Similar to Dev Jumpstart: Build Your First App with MongoDB (20)

Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesign
 
Dev Jumpstart: Building Your First App
Dev Jumpstart: Building Your First AppDev Jumpstart: Building Your First App
Dev Jumpstart: Building Your First App
 
Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDB
 
Webinar: Building Your First Application with MongoDB
Webinar: Building Your First Application with MongoDBWebinar: Building Your First Application with MongoDB
Webinar: Building Your First Application with MongoDB
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET Driver
 
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
 
Using MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesUsing MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 Minutes
 
10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
 
MongoDB
MongoDBMongoDB
MongoDB
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
MongoDB_ppt.pptx
MongoDB_ppt.pptxMongoDB_ppt.pptx
MongoDB_ppt.pptx
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overview
 
Webinar: Building Your First App
Webinar: Building Your First AppWebinar: Building Your First App
Webinar: Building Your First App
 
MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)
 
Conexión de MongoDB con Hadoop - Luis Alberto Giménez - CAPSiDE #DevOSSAzureDays
Conexión de MongoDB con Hadoop - Luis Alberto Giménez - CAPSiDE #DevOSSAzureDaysConexión de MongoDB con Hadoop - Luis Alberto Giménez - CAPSiDE #DevOSSAzureDays
Conexión de MongoDB con Hadoop - Luis Alberto Giménez - CAPSiDE #DevOSSAzureDays
 

More from MongoDB

More from 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...
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
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...
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Dev Jumpstart: Build Your First App with MongoDB

  • 1. #mongodb Build your first app; an introduction to MongoDB Christian Amor Kvalheim Developer Experience Team Lead, MongoDB
  • 2. Christian Kvalheim • Team Lead MongoDB Drivers • Node.js driver developer • Been using MongoDB for 5 years • Working at MongoDB last 3 years
  • 4. MongoDB is a ___________ database • Document • Open source • High performance • Horizontally scalable • Full featured
  • 5. Document Database • Not for .PDF & .DOC files • A document is essentially an associative array • Document = JSON object • Document = PHP Array • Document = Python Dict • Document = Ruby Hash • etc
  • 6. Open Source • MongoDB is an open source project • On GitHub • Licensed under the AGPL • Started & sponsored by MongoDB Inc • Commercial licenses available • Contributions welcome
  • 7. High Performance • Written in C++ • Extensive use of memory-mapped files i.e. read-through write-through memory caching. • Runs nearly everywhere • Data serialized as BSON (fast parsing) • Full support for primary & secondary indexes • Document model = agile development
  • 9. Full Featured • Flexible schema • Rich ad-hoc queries • Real time aggregation • Strongly consistent • Geospatial features • Built-in automatic failover • Horizontally scalable reads/writes • Support for most programming languages
  • 11. Running MongoDB $ tar zxf mongodb-osx-x86_64-2.6.4.tgz $ cd mongodb-osx-x86_64-2.6.4/bin $ mkdir –p /data/db $ ./mongod
  • 12. Mongo Shell $ mongo MongoDB shell version: 2.6.4 connecting to: test > db.test.insert({text: 'Welcome to MongoDB'}) > db.test.find().pretty() { "_id" : ObjectId("51c34130fbd5d7261b4cdb55"), "text" : "Welcome to MongoDB" }
  • 13. Building an App with MongoDB
  • 14. Terminology RDBMS MongoDB Table, View ➜ Collection Row ➜ Document Index ➜ Index Join ➜ Embedded Document Foreign Key ➜ Reference Partition ➜ Shard
  • 15. Let’s Build a Monitoring System
  • 16. First step in any application is Determine basic requirements
  • 17. Basic Monitoring Requirements • Data generated at per-second intervals • Metrics to capture (ex. CPU, memory, IO) • Document structure for fast writes and easy reads
  • 18. In a relational base app We would start by doing schema design
  • 19. Relational Schema Options CPU Metrics Memory Metrics IO Metrics Events • Timestamp • CPU metrics • Memory metrics • IO metrics Or
  • 20. In a MongoDB based app We start with a generic model and let the documents evolve
  • 21. MongoDB Document Modeling Events Timestamp (min) CPU [] • Second • Metric Memory [] • Second • Metric IO [] • Second • Metric
  • 23. Start with the Mongo Shell $ mongo MongoDB shell version: 2.6.4 connecting to: test > Full Javascript shell
  • 24. Switch to Your DB > use monitoring switching to db monitoring DB files are created once you save a document
  • 25. Create an Empty Event > var event = { ts: ISODate(“2014-09-16T09:00:00”), cpu: [ 0, 0, …, 0 ], memory: [ 0, 0, …, 0 ], io: [ 0, 0, …, 0 ], } Insert zeroed-out arrays to fill in later
  • 26. Insert the Event > db.events.insert(event) No collection creation necessary
  • 27. Find One Record > db.events.findOne() { "_id" : ObjectId("50804d0bd94ccab2da652599"), ”ts" : ISODate(“2014-09-16T09:00:00”), ”cpu" : [ 0, 0, …, 0 ], ”memory" : [ 0, 0, …, 0 ], “io” : [ 0, 0, …, 0 ] }
  • 28. How do you capture events? Serve r Serve r Serve r MongoD B memory interaction interaction interaction
  • 29. Adding a New Event > db.events.update( { ts: ISODate(“2014-09-16T09:00:00”) } { $set: { “cpu.0” : 50, “memory.0”: 1500, “io.0”: 10 } } ) Use atomic in-place updates to add metric values
  • 30. How do you plot charts?
  • 31. Finding an Hour of Events > db.events.find({ ts: { $gte: ISODate(“2014-09-16T09:00:00”), $lt: ISODate(“2014-09-16T10:00:00”) } }).sort({ts:1}) Find using a range and sort results ascending
  • 32. How do you roll up the data? Hour Avg Cpu 0 50 1 65 2 75 3 40 4 45 5 60 6 25 … … 23 30
  • 33. Aggregate Metrics > db.events.aggregate([ { $match: { ts: { $gte: date0, $lt: date1 } } }, { $project: { _id: 0, ts: 1, cpu: 1 } }, { $unwind: “$cpu” }, { $group: { _id: { $hour: “$ts” }, avg_cpu: { $avg: “$cpu” } } } ]) Use Aggregation Framework to roll up data
  • 34. How do you scale this workload • Replica Sets – Add data redundancy – Automatic failover – Tunable durability, consistency • Sharding – Scale reads and writes – Support dynamic data growth – Automatically partitions workload – Horizontally scalable
  • 36. Real applications are not built in the shell
  • 37. MongoDB has native bindings for over 12 languages
  • 38.
  • 39.
  • 40. MongoDB Drivers • Official Support for 12 languages • Community drivers for tons more • Drivers connect to MongoDB servers • Drivers translate BSON into native types • Shell is not a driver, but works like one in some ways • Installed using typical means (npm, pecl, gem, pip)
  • 42. Online Training at MongoDB University
  • 43. Suggestions for Talks • Talk to me at Meet the Experts – 11 am – 12 pm – 1 pm – 2 pm – Or catch me in the hallway • MongoDB for the internet of things • Socialite the Open Source Status Feed • The Future of MongoDB Storage
  • 45. #mongodb Thank You Christian Amor Kvalheim Developer Experience Team Lead, MongoDB