SlideShare uma empresa Scribd logo
1 de 57
1
Evolvable Application Development with
MongoDB
Gerd Teniers
Bart Wullems
for .NET developers
WARNING – This session is rated as a ‘Grandma session’ (=Level 200)
3 goals of this presentations
When you leave this presentation you should have learned
How easy it is to get started using MongoDB
How using MongoDB changes the way you design and build your applications
How MongoDB’s flexibility supports evolutionary design
That giving speakers beer before a session is never a good idea
What is not cool?
White socks & sandals
What is not cool?
Dancing like Miley Cyrus
What is not cool?
Relational databases
What is cool?
Short pants and very large socks
What is cool?
Dancing like Psy
What is cool?
NO-SQL (=Not Only SQL)
ThoughtWork Technology Radar
Entity Framework 7 will support No-SQL
Gartner
What is MongoDB?
MongoDB
HuMongous
General purpose database
Document oriented database using JSON document syntax
Features:
- Flexibility
- Power
- Scaling
- Ease of Use
- Built-in Javascript
Users: Craigslist, eBay, Foursquare, SourceForge, and The New York Times.
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 = less work
High Performance
MongoDB Database Architecture: Document
{
_id: ObjectId("5099803df3f4948bd2f98391"),
name: { first: "Alan", last: "Turing" },
birth: new Date('Jun 23, 1912'),
death: new Date('Jun 07, 1954'),
contribs: [ "Turing machine", "Turing test", "Turingery" ],
views : NumberLong(1250000)
}
MongoDB Database Architecture: Collection
Logical group of documents
May or may not share same keys
Schema is dynamic/application maintained
Why should I use it?(or how do I convince my boss?)
Developer productivity
Avoid ORM pain, no mapping needed
Performance(again)
Scaling out is easy(or at least easier)
Optimized for reads
Flexibility
Dynamic schema
How to run it?
Exe
Windows service
Azure
3rd party commercial hosting
How to talk to it?
Mongo shell Official and non official drivers
>12 languages supported
DEMO 1 - PROTOTYPING
Schema design
23
First step in any application
is determine your
domain/entities
In a relational based app
We would start by doing
schema design
In a MongoDB based app
We start building our app
and let the schema evolve
Comparison
Album
- id
- artistid
- title
Track
- no
- name
- unitPrice
- popularity
Artist
- id
- name
Album
- _id
- title
- artist
- tracks[]
- _id
- name
Relational Document db
Modeling
Modeling
Start from application-specific queries
“What questions do I have?” vs “What answers”
“Data like the application wants it”
Base parent documents on
The most common usage
What do I want returned?
Modeling
Embedding vs Linking vs Hybrid
Album
- _id
- artist
- cover
- _id
- name
Artist
- _id
- name
- photo
Product
Single collection inheritance
Product
- _id
- price
Book
- author
- title
Album
- artist
- title
Jeans
- size
- color
- _id
- price
- author
- title
Relational Document db
- _id
- price
- size
- color
Product
Single collection inheritance
Product
- _id
- price
Book
- author
- title
Album
- artist
- title
Jeans
- size
- color
_type: Book
- _id
- price
- author
- title
Relational Document db
_type: Jeans
- _id
- price
- size
- color
One-to-many
Embedded array / array keys
Some queries get harder
You can index arrays!
Normalized approach
More flexibility
A lot less performance
BlogPost
- _id
- content
- tags: {“foo”, “bar”}
- comments: {“id1”, “id2”}
Demo 2 – MODELING
CRUD
CRUD operations
Create: insert, save
Read: find, findOne
Update: update, save
Delete: remove, drop
ACID Transactions
No support for multi-document
transactions commit/rollback
Atomic operations on document level
Multiple actions inside the same
document
Incl. embedded documents
By keeping transaction support
extremely simple, MongoDB can
provide greater performance
especially for partitioned or replicated systems
Demo 3 – CRUD
GridFS
Storing binary documents
Although MongoDB is a document database, it’s not good for documents :-S
Document != .PNG & .PDF files
Document size is limited
Max document size is 16MB
Recommended document size <250KB
Solution is GridFS
Mechanism for storing large binary files in MongoDB
Stores metadata in a single document inside the fs.files collection
Splits files into chunks and stores them inside the fs.chunks collection
GridFS implementation is handled completely by the client driver
Demo 4 – Evolving your domain model
------------& GRIDFS
Evolving your domain model
Great for small changes!
Hot swapping
Minimal impact on your application and database
Avoid Migrations
Handle changes in your application instead of your database
Performance
Avoid table collections scans by using indexes
> db.albums.ensureIndex({title: 1})
Compound indexes
Index on multiple fields
> db.albums.ensureIndex({title: 1, year: 1})
Indexes have their price
Every write takes longer
Max 64 indexes on a collection
Try to limit them
Indexes are useful as the number of records you want to return are limited
If you return >30% of a collection, check if a table scan is faster
Creating indexes
Aggregations with the Aggregation Framework
$project Select()
$unwind SelectMany()
$match Where()
$group GroupBy()
$sort OrderBy()
$skip Skip()
$limit Take()
Largely replaces the original Map/Reduce
Much faster!
Implemented in a multi-threaded C ++
No support in LINQ-provider yet (but in development)
Demo 5 – Optimizations
Conclusion
Benefits
Scalable: good for a lot of data & traffic
Horizontal scaling: to more nodes
Good for web-apps
Performance
No joins and constraints
Dev/user friendly
Data is modeled to how the app is going to use it
No conversion between object oriented > relational
No static schema = agile
Evolvable
Drawbacks
Forget what you have learned
New way of building and designing your application
Can collect garbage
No data integrity checks
Add a clean-up job
Database model is determined by usage
Requires insight in the usage
https://github.com/wullemsb/DemoTechoramaMongoDb
Things we didn’t talk about
Things we didn’t talk about…
 Security
- HTTPS/SSL
 Compile the code yourself
 Eventual Consistency
 Geospatial features
 Realtime Aggregation
Things we didn’t talk about…
 Many to Many
- Multiple approaches
 References on 1 site
 References on both sites
Things we didn’t talk about…
 Write Concerns
- Acknowledged vs Unacknowledged writes
- Stick with acknowledged writes(=default)
Things we didn’t talk about…
 GridFS disadvantages
- Slower performance: accessing files from
MongoDB will not be as fast as going directly
through the filesystem.
- You can only modify documents by deleting
them and resaving the whole thing.
- Drivers are required
Things we didn’t talk about…
 Schema Migrations
- Avoid it
- Make your app backwards compatible
- Add version field to your documents
Things we didn’t talk about…
 Why you should not use regexes
- Slow!
 Advanced Indexing
- Indexing objects and Arrays
- Unique vs Sparse Indexes
- Geospatial Indexes
- Full Text Indexes
 MapReduce
- Avoid it
- Very slow in MongoDB
- Use Aggregation FW instead
Things we didn’t talk about…
 Sharding
 Based on a shard key (= field)
 Commands are sent to the shard that includes
the relevant range of the data
 Data is evenly distributed across the shards
 Automatic reallocation of data when adding or
removing servers

Mais conteúdo relacionado

Mais procurados

Introducing MongoDB Atlas
Introducing MongoDB AtlasIntroducing MongoDB Atlas
Introducing MongoDB AtlasMongoDB
 
Managing a MongoDB Deployment
Managing a MongoDB DeploymentManaging a MongoDB Deployment
Managing a MongoDB DeploymentTony Tam
 
Keeping the Lights On with MongoDB
Keeping the Lights On with MongoDBKeeping the Lights On with MongoDB
Keeping the Lights On with MongoDBTony Tam
 
MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB present...
MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB  present...MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB  present...
MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB present...MongoDB
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Consjohnrjenson
 
MongoDB 3.4: Deep Dive on Views, Zones, and MongoDB Compass
MongoDB 3.4: Deep Dive on Views, Zones, and MongoDB CompassMongoDB 3.4: Deep Dive on Views, Zones, and MongoDB Compass
MongoDB 3.4: Deep Dive on Views, Zones, and MongoDB CompassMongoDB
 
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...Prasoon Kumar
 
Intro to NoSQL and MongoDB
Intro to NoSQL and MongoDBIntro to NoSQL and MongoDB
Intro to NoSQL and MongoDBDATAVERSITY
 
Thinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick JosevskiThinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick JosevskiNick Josevski
 
LatJUG. Google App Engine
LatJUG. Google App EngineLatJUG. Google App Engine
LatJUG. Google App Enginedenis Udod
 
Webinar: MongoDB Connector for Spark
Webinar: MongoDB Connector for SparkWebinar: MongoDB Connector for Spark
Webinar: MongoDB Connector for SparkMongoDB
 
MongoDB: What, why, when
MongoDB: What, why, whenMongoDB: What, why, when
MongoDB: What, why, whenEugenio Minardi
 
When to Use MongoDB
When to Use MongoDBWhen to Use MongoDB
When to Use MongoDBMongoDB
 
MongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewMongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewNorberto Leite
 
MongoDB Launchpad 2016: MongoDB 3.4: Your Database Evolved
MongoDB Launchpad 2016: MongoDB 3.4: Your Database EvolvedMongoDB Launchpad 2016: MongoDB 3.4: Your Database Evolved
MongoDB Launchpad 2016: MongoDB 3.4: Your Database EvolvedMongoDB
 
MongoDB and AWS Best Practices
MongoDB and AWS Best PracticesMongoDB and AWS Best Practices
MongoDB and AWS Best PracticesMongoDB
 

Mais procurados (20)

Mongo DB
Mongo DBMongo DB
Mongo DB
 
Mongo db 3.4 Overview
Mongo db 3.4 OverviewMongo db 3.4 Overview
Mongo db 3.4 Overview
 
Introducing MongoDB Atlas
Introducing MongoDB AtlasIntroducing MongoDB Atlas
Introducing MongoDB Atlas
 
Managing a MongoDB Deployment
Managing a MongoDB DeploymentManaging a MongoDB Deployment
Managing a MongoDB Deployment
 
Keeping the Lights On with MongoDB
Keeping the Lights On with MongoDBKeeping the Lights On with MongoDB
Keeping the Lights On with MongoDB
 
MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB present...
MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB  present...MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB  present...
MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB present...
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
 
MongoDB 3.4: Deep Dive on Views, Zones, and MongoDB Compass
MongoDB 3.4: Deep Dive on Views, Zones, and MongoDB CompassMongoDB 3.4: Deep Dive on Views, Zones, and MongoDB Compass
MongoDB 3.4: Deep Dive on Views, Zones, and MongoDB Compass
 
Mongodb tutorial at Easylearning Guru
Mongodb tutorial  at Easylearning GuruMongodb tutorial  at Easylearning Guru
Mongodb tutorial at Easylearning Guru
 
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...
 
Intro to NoSQL and MongoDB
Intro to NoSQL and MongoDBIntro to NoSQL and MongoDB
Intro to NoSQL and MongoDB
 
Thinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick JosevskiThinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick Josevski
 
MongoDB vs OrientDB
MongoDB vs OrientDBMongoDB vs OrientDB
MongoDB vs OrientDB
 
LatJUG. Google App Engine
LatJUG. Google App EngineLatJUG. Google App Engine
LatJUG. Google App Engine
 
Webinar: MongoDB Connector for Spark
Webinar: MongoDB Connector for SparkWebinar: MongoDB Connector for Spark
Webinar: MongoDB Connector for Spark
 
MongoDB: What, why, when
MongoDB: What, why, whenMongoDB: What, why, when
MongoDB: What, why, when
 
When to Use MongoDB
When to Use MongoDBWhen to Use MongoDB
When to Use MongoDB
 
MongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewMongoDB 3.2 Feature Preview
MongoDB 3.2 Feature Preview
 
MongoDB Launchpad 2016: MongoDB 3.4: Your Database Evolved
MongoDB Launchpad 2016: MongoDB 3.4: Your Database EvolvedMongoDB Launchpad 2016: MongoDB 3.4: Your Database Evolved
MongoDB Launchpad 2016: MongoDB 3.4: Your Database Evolved
 
MongoDB and AWS Best Practices
MongoDB and AWS Best PracticesMongoDB and AWS Best Practices
MongoDB and AWS Best Practices
 

Destaque

Git(hub) for windows developers
Git(hub) for windows developersGit(hub) for windows developers
Git(hub) for windows developersbwullems
 
Javascript omg!
Javascript omg!Javascript omg!
Javascript omg!bwullems
 
Tfs Monitor Windows Phone 7 App
Tfs Monitor Windows Phone 7 AppTfs Monitor Windows Phone 7 App
Tfs Monitor Windows Phone 7 Appbwullems
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernatebwullems
 
Convention over configuration in .Net 4.0
Convention over configuration in .Net 4.0Convention over configuration in .Net 4.0
Convention over configuration in .Net 4.0bwullems
 
Caliburn.micro
Caliburn.microCaliburn.micro
Caliburn.microbwullems
 
Modyul2 angdaigdigsaklasikalattransisyunalnapanahon-140807210600-phpapp01
Modyul2 angdaigdigsaklasikalattransisyunalnapanahon-140807210600-phpapp01Modyul2 angdaigdigsaklasikalattransisyunalnapanahon-140807210600-phpapp01
Modyul2 angdaigdigsaklasikalattransisyunalnapanahon-140807210600-phpapp01Dexter Reyes
 

Destaque (7)

Git(hub) for windows developers
Git(hub) for windows developersGit(hub) for windows developers
Git(hub) for windows developers
 
Javascript omg!
Javascript omg!Javascript omg!
Javascript omg!
 
Tfs Monitor Windows Phone 7 App
Tfs Monitor Windows Phone 7 AppTfs Monitor Windows Phone 7 App
Tfs Monitor Windows Phone 7 App
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernate
 
Convention over configuration in .Net 4.0
Convention over configuration in .Net 4.0Convention over configuration in .Net 4.0
Convention over configuration in .Net 4.0
 
Caliburn.micro
Caliburn.microCaliburn.micro
Caliburn.micro
 
Modyul2 angdaigdigsaklasikalattransisyunalnapanahon-140807210600-phpapp01
Modyul2 angdaigdigsaklasikalattransisyunalnapanahon-140807210600-phpapp01Modyul2 angdaigdigsaklasikalattransisyunalnapanahon-140807210600-phpapp01
Modyul2 angdaigdigsaklasikalattransisyunalnapanahon-140807210600-phpapp01
 

Semelhante a Techorama - Evolvable Application Development with MongoDB

MongoDB.local Sydney: An Introduction to Document Databases with MongoDB
MongoDB.local Sydney: An Introduction to Document Databases with MongoDBMongoDB.local Sydney: An Introduction to Document Databases with MongoDB
MongoDB.local Sydney: An Introduction to Document Databases with MongoDBMongoDB
 
Introduction to MongoDB and its best practices
Introduction to MongoDB and its best practicesIntroduction to MongoDB and its best practices
Introduction to MongoDB and its best practicesAshishRathore72
 
how_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfhow_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfsarah david
 
MongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDB
MongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDBMongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDB
MongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDBMongoDB
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDBMongoDB
 
how_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxhow_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxsarah david
 
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYCHands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYCLaura Ventura
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialPHP Support
 
MongoDB Schema Design by Examples
MongoDB Schema Design by ExamplesMongoDB Schema Design by Examples
MongoDB Schema Design by ExamplesHadi Ariawan
 
Front Range PHP NoSQL Databases
Front Range PHP NoSQL DatabasesFront Range PHP NoSQL Databases
Front Range PHP NoSQL DatabasesJon Meredith
 
Redis vs. MongoDB: Comparing In-Memory Databases with Percona Memory Engine
Redis vs. MongoDB: Comparing In-Memory Databases with Percona Memory EngineRedis vs. MongoDB: Comparing In-Memory Databases with Percona Memory Engine
Redis vs. MongoDB: Comparing In-Memory Databases with Percona Memory EngineScaleGrid.io
 
MongoATL: How Sourceforge is Using MongoDB
MongoATL: How Sourceforge is Using MongoDBMongoATL: How Sourceforge is Using MongoDB
MongoATL: How Sourceforge is Using MongoDBRick Copeland
 
Jumpstart: Building Your First MongoDB App
Jumpstart: Building Your First MongoDB AppJumpstart: Building Your First MongoDB App
Jumpstart: Building Your First MongoDB AppMongoDB
 
Everything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptxEverything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptx75waytechnologies
 
How Cloud is Affecting Data Scientists
How Cloud is Affecting Data Scientists How Cloud is Affecting Data Scientists
How Cloud is Affecting Data Scientists CCG
 
TCO Comparison MongoDB & Oracle
TCO Comparison MongoDB & OracleTCO Comparison MongoDB & Oracle
TCO Comparison MongoDB & OracleEl Taller Web
 
Mongo db transcript
Mongo db transcriptMongo db transcript
Mongo db transcriptfoliba
 
Scaling Web Apps P Falcone
Scaling Web Apps P FalconeScaling Web Apps P Falcone
Scaling Web Apps P Falconejedt
 

Semelhante a Techorama - Evolvable Application Development with MongoDB (20)

MongoDB.local Sydney: An Introduction to Document Databases with MongoDB
MongoDB.local Sydney: An Introduction to Document Databases with MongoDBMongoDB.local Sydney: An Introduction to Document Databases with MongoDB
MongoDB.local Sydney: An Introduction to Document Databases with MongoDB
 
Introduction to MongoDB and its best practices
Introduction to MongoDB and its best practicesIntroduction to MongoDB and its best practices
Introduction to MongoDB and its best practices
 
how_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfhow_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdf
 
MongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDB
MongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDBMongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDB
MongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDB
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDB
 
how_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxhow_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptx
 
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYCHands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js Tutorial
 
MongoDB Schema Design by Examples
MongoDB Schema Design by ExamplesMongoDB Schema Design by Examples
MongoDB Schema Design by Examples
 
Front Range PHP NoSQL Databases
Front Range PHP NoSQL DatabasesFront Range PHP NoSQL Databases
Front Range PHP NoSQL Databases
 
Redis vs. MongoDB: Comparing In-Memory Databases with Percona Memory Engine
Redis vs. MongoDB: Comparing In-Memory Databases with Percona Memory EngineRedis vs. MongoDB: Comparing In-Memory Databases with Percona Memory Engine
Redis vs. MongoDB: Comparing In-Memory Databases with Percona Memory Engine
 
MongoATL: How Sourceforge is Using MongoDB
MongoATL: How Sourceforge is Using MongoDBMongoATL: How Sourceforge is Using MongoDB
MongoATL: How Sourceforge is Using MongoDB
 
Jumpstart: Building Your First MongoDB App
Jumpstart: Building Your First MongoDB AppJumpstart: Building Your First MongoDB App
Jumpstart: Building Your First MongoDB App
 
Everything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptxEverything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptx
 
How Cloud is Affecting Data Scientists
How Cloud is Affecting Data Scientists How Cloud is Affecting Data Scientists
How Cloud is Affecting Data Scientists
 
TCO Comparison MongoDB & Oracle
TCO Comparison MongoDB & OracleTCO Comparison MongoDB & Oracle
TCO Comparison MongoDB & Oracle
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
 
Mongo db transcript
Mongo db transcriptMongo db transcript
Mongo db transcript
 
Scaling Web Apps P Falcone
Scaling Web Apps P FalconeScaling Web Apps P Falcone
Scaling Web Apps P Falcone
 
Open source Technology
Open source TechnologyOpen source Technology
Open source Technology
 

Último

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 

Último (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Techorama - Evolvable Application Development with MongoDB

  • 1. 1 Evolvable Application Development with MongoDB Gerd Teniers Bart Wullems for .NET developers
  • 2. WARNING – This session is rated as a ‘Grandma session’ (=Level 200)
  • 3. 3 goals of this presentations When you leave this presentation you should have learned How easy it is to get started using MongoDB How using MongoDB changes the way you design and build your applications How MongoDB’s flexibility supports evolutionary design That giving speakers beer before a session is never a good idea
  • 4. What is not cool? White socks & sandals
  • 5. What is not cool? Dancing like Miley Cyrus
  • 6. What is not cool? Relational databases
  • 7. What is cool? Short pants and very large socks
  • 9. What is cool? NO-SQL (=Not Only SQL)
  • 11. Entity Framework 7 will support No-SQL
  • 14. MongoDB HuMongous General purpose database Document oriented database using JSON document syntax Features: - Flexibility - Power - Scaling - Ease of Use - Built-in Javascript Users: Craigslist, eBay, Foursquare, SourceForge, and The New York Times.
  • 15. 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 = less work High Performance
  • 16. MongoDB Database Architecture: Document { _id: ObjectId("5099803df3f4948bd2f98391"), name: { first: "Alan", last: "Turing" }, birth: new Date('Jun 23, 1912'), death: new Date('Jun 07, 1954'), contribs: [ "Turing machine", "Turing test", "Turingery" ], views : NumberLong(1250000) }
  • 17. MongoDB Database Architecture: Collection Logical group of documents May or may not share same keys Schema is dynamic/application maintained
  • 18. Why should I use it?(or how do I convince my boss?) Developer productivity Avoid ORM pain, no mapping needed Performance(again) Scaling out is easy(or at least easier) Optimized for reads Flexibility Dynamic schema
  • 19. How to run it? Exe Windows service Azure 3rd party commercial hosting
  • 20. How to talk to it? Mongo shell Official and non official drivers >12 languages supported
  • 21. DEMO 1 - PROTOTYPING
  • 23. 23 First step in any application is determine your domain/entities
  • 24. In a relational based app We would start by doing schema design
  • 25. In a MongoDB based app We start building our app and let the schema evolve
  • 26. Comparison Album - id - artistid - title Track - no - name - unitPrice - popularity Artist - id - name Album - _id - title - artist - tracks[] - _id - name Relational Document db
  • 28. Modeling Start from application-specific queries “What questions do I have?” vs “What answers” “Data like the application wants it” Base parent documents on The most common usage What do I want returned?
  • 29. Modeling Embedding vs Linking vs Hybrid Album - _id - artist - cover - _id - name Artist - _id - name - photo
  • 30. Product Single collection inheritance Product - _id - price Book - author - title Album - artist - title Jeans - size - color - _id - price - author - title Relational Document db - _id - price - size - color
  • 31. Product Single collection inheritance Product - _id - price Book - author - title Album - artist - title Jeans - size - color _type: Book - _id - price - author - title Relational Document db _type: Jeans - _id - price - size - color
  • 32. One-to-many Embedded array / array keys Some queries get harder You can index arrays! Normalized approach More flexibility A lot less performance BlogPost - _id - content - tags: {“foo”, “bar”} - comments: {“id1”, “id2”}
  • 33. Demo 2 – MODELING
  • 34. CRUD
  • 35. CRUD operations Create: insert, save Read: find, findOne Update: update, save Delete: remove, drop
  • 36. ACID Transactions No support for multi-document transactions commit/rollback Atomic operations on document level Multiple actions inside the same document Incl. embedded documents By keeping transaction support extremely simple, MongoDB can provide greater performance especially for partitioned or replicated systems
  • 37. Demo 3 – CRUD
  • 39. Storing binary documents Although MongoDB is a document database, it’s not good for documents :-S Document != .PNG & .PDF files Document size is limited Max document size is 16MB Recommended document size <250KB Solution is GridFS Mechanism for storing large binary files in MongoDB Stores metadata in a single document inside the fs.files collection Splits files into chunks and stores them inside the fs.chunks collection GridFS implementation is handled completely by the client driver
  • 40. Demo 4 – Evolving your domain model ------------& GRIDFS
  • 41. Evolving your domain model Great for small changes! Hot swapping Minimal impact on your application and database Avoid Migrations Handle changes in your application instead of your database
  • 43. Avoid table collections scans by using indexes > db.albums.ensureIndex({title: 1}) Compound indexes Index on multiple fields > db.albums.ensureIndex({title: 1, year: 1}) Indexes have their price Every write takes longer Max 64 indexes on a collection Try to limit them Indexes are useful as the number of records you want to return are limited If you return >30% of a collection, check if a table scan is faster Creating indexes
  • 44. Aggregations with the Aggregation Framework $project Select() $unwind SelectMany() $match Where() $group GroupBy() $sort OrderBy() $skip Skip() $limit Take() Largely replaces the original Map/Reduce Much faster! Implemented in a multi-threaded C ++ No support in LINQ-provider yet (but in development)
  • 45. Demo 5 – Optimizations
  • 47. Benefits Scalable: good for a lot of data & traffic Horizontal scaling: to more nodes Good for web-apps Performance No joins and constraints Dev/user friendly Data is modeled to how the app is going to use it No conversion between object oriented > relational No static schema = agile Evolvable
  • 48. Drawbacks Forget what you have learned New way of building and designing your application Can collect garbage No data integrity checks Add a clean-up job Database model is determined by usage Requires insight in the usage
  • 50. Things we didn’t talk about
  • 51. Things we didn’t talk about…  Security - HTTPS/SSL  Compile the code yourself  Eventual Consistency  Geospatial features  Realtime Aggregation
  • 52. Things we didn’t talk about…  Many to Many - Multiple approaches  References on 1 site  References on both sites
  • 53. Things we didn’t talk about…  Write Concerns - Acknowledged vs Unacknowledged writes - Stick with acknowledged writes(=default)
  • 54. Things we didn’t talk about…  GridFS disadvantages - Slower performance: accessing files from MongoDB will not be as fast as going directly through the filesystem. - You can only modify documents by deleting them and resaving the whole thing. - Drivers are required
  • 55. Things we didn’t talk about…  Schema Migrations - Avoid it - Make your app backwards compatible - Add version field to your documents
  • 56. Things we didn’t talk about…  Why you should not use regexes - Slow!  Advanced Indexing - Indexing objects and Arrays - Unique vs Sparse Indexes - Geospatial Indexes - Full Text Indexes  MapReduce - Avoid it - Very slow in MongoDB - Use Aggregation FW instead
  • 57. Things we didn’t talk about…  Sharding  Based on a shard key (= field)  Commands are sent to the shard that includes the relevant range of the data  Data is evenly distributed across the shards  Automatic reallocation of data when adding or removing servers

Notas do Editor

  1. Documents contain: Values Arrays Embedded docs