SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
MWLUG 2017
Moving Collaboration Forward
MongoDB Performance
Kim Greene
Kim Greene Consulting, Inc.
kim@kimgreene.com
MWLUG 2017
Moving Collaboration Forward
About Me
{
“name”: “Kim Greene”,
“email”: “kim@kimgreene.com”,
“company”: “Kim Greene Consulting, Inc.”,
“website”: “www.kimgreene.com”,
“twitter”: “@iSeriesDomino”,
}
MWLUG 2017
Moving Collaboration Forward
Agenda
• Why companies are turning to MongoDB
• Hardware
• Sharding
• Database choice
• Schema design
• Indexes
MWLUG 2017
Moving Collaboration Forward
Why Customers are Turning to
MongoDB
MWLUG 2017
Moving Collaboration Forward
Inserting Data: MongoDB vs. MySQL
• Inserting 1,615 chemical compound records into two parent-
child tables
• Turned off foreign keys during insert and used string builder to
create bulk insert SQL statement in MySQL
MWLUG 2017
Moving Collaboration Forward
MongoDB vs. S3 Performance
• Download 220 KB object from MongoDB was
7x faster cold, and 3x faster when warm
MWLUG 2017
Moving Collaboration Forward
Hardware
MWLUG 2017
Moving Collaboration Forward
Hardware Requirements
• Can use commodity hardware all way up to
IBM Power and zSeries
– Use multi-core systems when possible
• Ensure indexes and most frequently accessed
data (working set) fits in RAM
• RAM is the most important factor for
hardware
• db.serverStatus()
– Use to obtain info on current working set
MWLUG 2017
Moving Collaboration Forward
Hardware Requirements
• Data placement is key!
– Use SSDs for:
• Write-heavy data
• Placement of journals
• Compression
– Can reduces footprint by up to 80%
– Equals fewer bits read from disk
MWLUG 2017
Moving Collaboration Forward
Compression
• WiredTiger has native compression
• Compression options for documents and indexes
– Snappy
• Default, balance between high document and journal
compression ratios
• Low CPU overhead
– zlib
• Higher compression
• Additional CPU overhead
– Prefix
• What indexes use by default, reduces size ~50%
MWLUG 2017
Moving Collaboration Forward
Compression
• Snappy and SSDs
– Use for frequently accessed data
• zlib and rotational disks
– Use for older, less frequently accessed data
MWLUG 2017
Moving Collaboration Forward
Sharding
MWLUG 2017
Moving Collaboration Forward
Sharding
• Place a portion of data on certain servers
• Use with
– Very large data sets
– High throughput demands
– Needs for geo location of data
MWLUG 2017
Moving Collaboration Forward
Sharding
MWLUG 2017
Moving Collaboration Forward
Sharding
• Distribute data across cluster based on query
patterns or data locality
• Types of sharding:
– Range
– Hash
– Zone
MWLUG 2017
Moving Collaboration Forward
Sharding
• Range sharding
– Divides data into ranges based on shard key values
– Efficient queries when reading documents in a contiguous range
– Can have poor read and write performance with poor shard key
range selection
• Hash sharding
– More even data distribution
– Can impact performance of range-based queries
• Zone sharding
– Used to improve locality of data
• By geographic region
• By hardware configuration for tiered storage-architectures
• By application feature
MWLUG 2017
Moving Collaboration Forward
Database Choice
MWLUG 2017
Moving Collaboration Forward
4 Types of Databases
• WiredTiger
– Most commonly used database type, the default
• Encrypted
– For highly sensitive data
• In-memory
– For performance critical data
• MMAPv1
– Improved version of database used in earlier
versions of MongoDB
MWLUG 2017
Moving Collaboration Forward
In-Memory Database
• Doesn’t maintain any on-disk data, including
configuration data, indexes, user credentials,
etc.
• Entire database needs to be able to fit into
memory
– Key to know true “working set”
MWLUG 2017
Moving Collaboration Forward
Schema Design
MWLUG 2017
Moving Collaboration Forward
Schema Design
• Schema design is critical
– Most performance problems are because of poor
schema design
• RDBMS schema design
– What answers do I have?
• MongoDB schema design
– What questions will I have?
MWLUG 2017
Moving Collaboration Forward
Schema Design
• Key items of focus
–How will the data be accessed
–What is the projected read to write ratio
–How large will documents become
• Want to structure data to match how it is
queried and updated
MWLUG 2017
Moving Collaboration Forward
Schema Design
• Basic schema designs
– Embedding
– Referencing
– Denormalization
MWLUG 2017
Moving Collaboration Forward
Embedding
• To embed or not to embed
– Favor embedding unless there is a compelling
reason not to
– If an object needs to be accessed frequently on
it’s own, it’s best not to embed
MWLUG 2017
Moving Collaboration Forward
Embedding
MWLUG 2017
Moving Collaboration Forward
Embedding
• Use when all of the data is manipulated
together
• Relationship between collections is one-to-
one
• When able to be used, normally reduces
latency of get requests by 50%
MWLUG 2017
Moving Collaboration Forward
Referencing
• Link to other documents when:
– One to many relationships
– Need to access parts of data stand-alone
MWLUG 2017
Moving Collaboration Forward
Denormalizing
• Read/write ratio is key for deciding on
denormalizing
– Fields primarily read and rarely updated are good
candidates
– If a field is updated frequently, don’t do it
MWLUG 2017
Moving Collaboration Forward
Denormalization
• Limits having to perform application-level join
for denormalized fields
MWLUG 2017
Moving Collaboration Forward
Denormalization
• Consider the write/read ratio when
denormalizing
– A field that will mostly be read and only seldom
updated is a good candidate for denormalization
– As updates become more frequent relative to
queries, the savings from denormalization
decrease
MWLUG 2017
Moving Collaboration Forward
Back to Embedding
• Embed computed information when you write
it
– Prevents needing to retrieve and compute over
and over
– Works well if writes are infrequent
– Pushes work to the application on the write, result
is dramatically improved read time
MWLUG 2017
Moving Collaboration Forward
Back to Embedding
• What to look for when choosing referencing vs
embedding data in a document
– Things that don’t change often and aren’t read
often are best stored in a separate document
– Parent document contains a reference to the less
frequently accessed/updated document
MWLUG 2017
Moving Collaboration Forward
Schema Design
• The MongoDB data schema design of choice
depends – entirely – on your particular
application’s data access patterns
• Structure your data to match the ways that
your application queries and updates it
MWLUG 2017
Moving Collaboration Forward
Indexes
MWLUG 2017
Moving Collaboration Forward
Indexes
• ½ of all performance issues are due to missing
or incorrect secondary indexes
• Index early
• Index often
MWLUG 2017
Moving Collaboration Forward
Types of Secondary Indexes
• Unique
• Compound
• Array
• Time to Live (TTL)
• Geospatial
• Partial
• Sparse
• Text search
MWLUG 2017
Moving Collaboration Forward
Types of Secondary Indexes
• Unique
– Rejects insertion of new documents or the update
of a document with an existing value for the field
it is built over
• Compound
– Useful for queries that specify multiple predicates
• Example: Find customers based on last name, first
name, and city of residence
– Can reduce the need for single field indexes as any
leading field in a compound index can be used
MWLUG 2017
Moving Collaboration Forward
Types of Secondary Indexes
• Array
– For fields that contain an array, each array value is
stored as a separate index entry
• Time to Live (TTL)
– Specify a period of time after which the data is
automatically deleted from the database
MWLUG 2017
Moving Collaboration Forward
Types of Secondary Indexes
• Geospatial
– Allow MongoDB to optimize queries for
documents that contain points or a polygon that
are closest to a given point or line; that are within
a circle, rectangle, or polygon; or that intersect
with a circle, rectangle, or polygon
• Partial
– Use to include only documents that meet specific
conditions
MWLUG 2017
Moving Collaboration Forward
Types of Secondary Indexes
• Sparse
– Contain entries for documents that contain a
specified field
– Allow for smaller, more efficient indexes when
fields are not present in all documents
• Text search
– Specialized index for text search that uses
advanced, language-specific linguistic rules for
stemming, tokenization, case sensitivity and stop
words
MWLUG 2017
Moving Collaboration Forward
Indexing Tidbits
• Query optimizer
– Selects best index to use by periodically running query
plans
• Index intersection
– Allows MongoDB to use more than one index to
optimize ad-hoc queries at run-time
• Covered queries
– Return results containing only indexed fields
– Very efficient, results returned without reading from
source documents
MWLUG 2017
Moving Collaboration Forward
Aggregation Pipeline
• Replaces find in certain scenarios
• Improves performance significantly
– Moves processing from the client side to the
server
– Saves CPU and bandwidth
• Reduce the amount of data transmitted to the
application layer
MWLUG 2017
Moving Collaboration Forward
Where to Find More Information
MWLUG 2017
Moving Collaboration Forward
Where to Find More Information
• MongoDB University
– university.mongodb.com
• YouTube tutorials
– youtube.com/mongodb
• MongoDB Performance Best Practices white
paper
– mongodb.com/collateral/mongodb-performance-
best-practices

Weitere ähnliche Inhalte

Was ist angesagt?

An Introduction to MongoDB Compass
An Introduction to MongoDB CompassAn Introduction to MongoDB Compass
An Introduction to MongoDB CompassMongoDB
 
Moving Hudl from MS SQL to MongoDB: A Two Year Journey
Moving Hudl from MS SQL to MongoDB: A Two Year JourneyMoving Hudl from MS SQL to MongoDB: A Two Year Journey
Moving Hudl from MS SQL to MongoDB: A Two Year JourneyMongoDB
 
MongoDB and Our Journey from Old, Slow and Monolithic to Fast and Agile Micro...
MongoDB and Our Journey from Old, Slow and Monolithic to Fast and Agile Micro...MongoDB and Our Journey from Old, Slow and Monolithic to Fast and Agile Micro...
MongoDB and Our Journey from Old, Slow and Monolithic to Fast and Agile Micro...MongoDB
 
MongoDB Partner Program Update - November 2013
MongoDB Partner Program Update - November 2013MongoDB Partner Program Update - November 2013
MongoDB Partner Program Update - November 2013MongoDB
 
MongoDB Atlas - eHarmony’s New Message Store
MongoDB Atlas - eHarmony’s New Message StoreMongoDB Atlas - eHarmony’s New Message Store
MongoDB Atlas - eHarmony’s New Message StoreEvan Rodd
 
Unlocking Operational Intelligence from the Data Lake
Unlocking Operational Intelligence from the Data LakeUnlocking Operational Intelligence from the Data Lake
Unlocking Operational Intelligence from the Data LakeMongoDB
 
MongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of viewMongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of viewPierre Baillet
 
Webinar: What's New in MongoDB 3.2
Webinar: What's New in MongoDB 3.2Webinar: What's New in MongoDB 3.2
Webinar: What's New in MongoDB 3.2MongoDB
 
Business Track: How MongoDB Helps Telefonia Digital Accelerate Time to Market
Business Track: How MongoDB Helps Telefonia Digital Accelerate Time to MarketBusiness Track: How MongoDB Helps Telefonia Digital Accelerate Time to Market
Business Track: How MongoDB Helps Telefonia Digital Accelerate Time to MarketMongoDB
 
MongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewMongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewNorberto Leite
 
MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016Norberto Leite
 
Solr Under the Hood at S&P Global- Sumit Vadhera, S&P Global
Solr Under the Hood at S&P Global- Sumit Vadhera, S&P Global Solr Under the Hood at S&P Global- Sumit Vadhera, S&P Global
Solr Under the Hood at S&P Global- Sumit Vadhera, S&P Global Lucidworks
 
Webinar: Simplifying the Database Experience with MongoDB Atlas
Webinar: Simplifying the Database Experience with MongoDB AtlasWebinar: Simplifying the Database Experience with MongoDB Atlas
Webinar: Simplifying the Database Experience with MongoDB AtlasMongoDB
 
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
 
MongoDB at Baidu
MongoDB at BaiduMongoDB at Baidu
MongoDB at BaiduMat Keep
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMongoDB
 
Maximizing MongoDB Performance on AWS
Maximizing MongoDB Performance on AWSMaximizing MongoDB Performance on AWS
Maximizing MongoDB Performance on AWSMongoDB
 
MongoDB .local Munich 2019: Mastering MongoDB on Kubernetes – MongoDB Enterpr...
MongoDB .local Munich 2019: Mastering MongoDB on Kubernetes – MongoDB Enterpr...MongoDB .local Munich 2019: Mastering MongoDB on Kubernetes – MongoDB Enterpr...
MongoDB .local Munich 2019: Mastering MongoDB on Kubernetes – MongoDB Enterpr...MongoDB
 
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
 

Was ist angesagt? (20)

An Introduction to MongoDB Compass
An Introduction to MongoDB CompassAn Introduction to MongoDB Compass
An Introduction to MongoDB Compass
 
Moving Hudl from MS SQL to MongoDB: A Two Year Journey
Moving Hudl from MS SQL to MongoDB: A Two Year JourneyMoving Hudl from MS SQL to MongoDB: A Two Year Journey
Moving Hudl from MS SQL to MongoDB: A Two Year Journey
 
MongoDB and Our Journey from Old, Slow and Monolithic to Fast and Agile Micro...
MongoDB and Our Journey from Old, Slow and Monolithic to Fast and Agile Micro...MongoDB and Our Journey from Old, Slow and Monolithic to Fast and Agile Micro...
MongoDB and Our Journey from Old, Slow and Monolithic to Fast and Agile Micro...
 
MongoDB Partner Program Update - November 2013
MongoDB Partner Program Update - November 2013MongoDB Partner Program Update - November 2013
MongoDB Partner Program Update - November 2013
 
MongoDB Atlas - eHarmony’s New Message Store
MongoDB Atlas - eHarmony’s New Message StoreMongoDB Atlas - eHarmony’s New Message Store
MongoDB Atlas - eHarmony’s New Message Store
 
Unlocking Operational Intelligence from the Data Lake
Unlocking Operational Intelligence from the Data LakeUnlocking Operational Intelligence from the Data Lake
Unlocking Operational Intelligence from the Data Lake
 
MongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of viewMongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of view
 
Spark and MongoDB
Spark and MongoDBSpark and MongoDB
Spark and MongoDB
 
Webinar: What's New in MongoDB 3.2
Webinar: What's New in MongoDB 3.2Webinar: What's New in MongoDB 3.2
Webinar: What's New in MongoDB 3.2
 
Business Track: How MongoDB Helps Telefonia Digital Accelerate Time to Market
Business Track: How MongoDB Helps Telefonia Digital Accelerate Time to MarketBusiness Track: How MongoDB Helps Telefonia Digital Accelerate Time to Market
Business Track: How MongoDB Helps Telefonia Digital Accelerate Time to Market
 
MongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewMongoDB 3.2 Feature Preview
MongoDB 3.2 Feature Preview
 
MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016
 
Solr Under the Hood at S&P Global- Sumit Vadhera, S&P Global
Solr Under the Hood at S&P Global- Sumit Vadhera, S&P Global Solr Under the Hood at S&P Global- Sumit Vadhera, S&P Global
Solr Under the Hood at S&P Global- Sumit Vadhera, S&P Global
 
Webinar: Simplifying the Database Experience with MongoDB Atlas
Webinar: Simplifying the Database Experience with MongoDB AtlasWebinar: Simplifying the Database Experience with MongoDB Atlas
Webinar: Simplifying the Database Experience with MongoDB Atlas
 
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...
 
MongoDB at Baidu
MongoDB at BaiduMongoDB at Baidu
MongoDB at Baidu
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDB
 
Maximizing MongoDB Performance on AWS
Maximizing MongoDB Performance on AWSMaximizing MongoDB Performance on AWS
Maximizing MongoDB Performance on AWS
 
MongoDB .local Munich 2019: Mastering MongoDB on Kubernetes – MongoDB Enterpr...
MongoDB .local Munich 2019: Mastering MongoDB on Kubernetes – MongoDB Enterpr...MongoDB .local Munich 2019: Mastering MongoDB on Kubernetes – MongoDB Enterpr...
MongoDB .local Munich 2019: Mastering MongoDB on Kubernetes – MongoDB Enterpr...
 
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
 

Ähnlich wie IN106 Performance with MongoDB

MongoDB for Spatio-Behavioral Data Analysis and Visualization
MongoDB for Spatio-Behavioral Data Analysis and VisualizationMongoDB for Spatio-Behavioral Data Analysis and Visualization
MongoDB for Spatio-Behavioral Data Analysis and VisualizationMongoDB
 
Webinar: When to Use MongoDB
Webinar: When to Use MongoDBWebinar: When to Use MongoDB
Webinar: When to Use MongoDBMongoDB
 
When to Use MongoDB
When to Use MongoDBWhen to Use MongoDB
When to Use MongoDBMongoDB
 
Hackolade Tutorial - part 3 - Query-driven data modeling based on access patt...
Hackolade Tutorial - part 3 - Query-driven data modeling based on access patt...Hackolade Tutorial - part 3 - Query-driven data modeling based on access patt...
Hackolade Tutorial - part 3 - Query-driven data modeling based on access patt...PascalDesmarets1
 
Got documents - The Raven Bouns Edition
Got documents - The Raven Bouns EditionGot documents - The Raven Bouns Edition
Got documents - The Raven Bouns EditionMaggie Pint
 
Got documents Code Mash Revision
Got documents Code Mash RevisionGot documents Code Mash Revision
Got documents Code Mash RevisionMaggie Pint
 
Introduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDBIntroduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDBAhmed Farag
 
When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...MongoDB
 
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas SuravarapuGraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas SuravarapuNeo4j
 
MONGODB VASUDEV PRAJAPATI DOCUMENTBASE DATABASE
MONGODB VASUDEV PRAJAPATI DOCUMENTBASE DATABASEMONGODB VASUDEV PRAJAPATI DOCUMENTBASE DATABASE
MONGODB VASUDEV PRAJAPATI DOCUMENTBASE DATABASEvasustudy176
 
Make Text Search "Work" for Your Apps - JavaOne 2013
Make Text Search "Work" for Your Apps - JavaOne 2013Make Text Search "Work" for Your Apps - JavaOne 2013
Make Text Search "Work" for Your Apps - JavaOne 2013javagroup2006
 
introduction to NOSQL Database
introduction to NOSQL Databaseintroduction to NOSQL Database
introduction to NOSQL Databasenehabsairam
 
MongoDB World 2018: Data Analytics with MongoDB
MongoDB World 2018: Data Analytics with MongoDBMongoDB World 2018: Data Analytics with MongoDB
MongoDB World 2018: Data Analytics with MongoDBMongoDB
 
Scaling MongoDB - Presentation at MTP
Scaling MongoDB - Presentation at MTPScaling MongoDB - Presentation at MTP
Scaling MongoDB - Presentation at MTPdarkdata
 

Ähnlich wie IN106 Performance with MongoDB (20)

MongoDB for Spatio-Behavioral Data Analysis and Visualization
MongoDB for Spatio-Behavioral Data Analysis and VisualizationMongoDB for Spatio-Behavioral Data Analysis and Visualization
MongoDB for Spatio-Behavioral Data Analysis and Visualization
 
Webinar: When to Use MongoDB
Webinar: When to Use MongoDBWebinar: When to Use MongoDB
Webinar: When to Use MongoDB
 
When to Use MongoDB
When to Use MongoDBWhen to Use MongoDB
When to Use MongoDB
 
Hackolade Tutorial - part 3 - Query-driven data modeling based on access patt...
Hackolade Tutorial - part 3 - Query-driven data modeling based on access patt...Hackolade Tutorial - part 3 - Query-driven data modeling based on access patt...
Hackolade Tutorial - part 3 - Query-driven data modeling based on access patt...
 
Got documents?
Got documents?Got documents?
Got documents?
 
Got documents - The Raven Bouns Edition
Got documents - The Raven Bouns EditionGot documents - The Raven Bouns Edition
Got documents - The Raven Bouns Edition
 
Got documents Code Mash Revision
Got documents Code Mash RevisionGot documents Code Mash Revision
Got documents Code Mash Revision
 
Introduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDBIntroduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDB
 
When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...
 
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas SuravarapuGraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
 
MONGODB VASUDEV PRAJAPATI DOCUMENTBASE DATABASE
MONGODB VASUDEV PRAJAPATI DOCUMENTBASE DATABASEMONGODB VASUDEV PRAJAPATI DOCUMENTBASE DATABASE
MONGODB VASUDEV PRAJAPATI DOCUMENTBASE DATABASE
 
Mongo db 3.4 Overview
Mongo db 3.4 OverviewMongo db 3.4 Overview
Mongo db 3.4 Overview
 
Make Text Search "Work" for Your Apps - JavaOne 2013
Make Text Search "Work" for Your Apps - JavaOne 2013Make Text Search "Work" for Your Apps - JavaOne 2013
Make Text Search "Work" for Your Apps - JavaOne 2013
 
introduction to NOSQL Database
introduction to NOSQL Databaseintroduction to NOSQL Database
introduction to NOSQL Database
 
NoSQL and MongoDB
NoSQL and MongoDBNoSQL and MongoDB
NoSQL and MongoDB
 
NoSql Brownbag
NoSql BrownbagNoSql Brownbag
NoSql Brownbag
 
MongoDB World 2018: Data Analytics with MongoDB
MongoDB World 2018: Data Analytics with MongoDBMongoDB World 2018: Data Analytics with MongoDB
MongoDB World 2018: Data Analytics with MongoDB
 
UNIT-2.pptx
UNIT-2.pptxUNIT-2.pptx
UNIT-2.pptx
 
Overview di MongoDB
Overview di MongoDBOverview di MongoDB
Overview di MongoDB
 
Scaling MongoDB - Presentation at MTP
Scaling MongoDB - Presentation at MTPScaling MongoDB - Presentation at MTP
Scaling MongoDB - Presentation at MTP
 

Kürzlich hochgeladen

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...Miguel Araújo
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
[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.pdfhans926745
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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.pdfUK Journal
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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.pptxHampshireHUG
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
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.pdfsudhanshuwaghmare1
 
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 2024The Digital Insurer
 
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 Processorsdebabhi2
 
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?Antenna Manufacturer Coco
 

Kürzlich hochgeladen (20)

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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
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
 
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
 
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?
 

IN106 Performance with MongoDB

  • 1. MWLUG 2017 Moving Collaboration Forward MongoDB Performance Kim Greene Kim Greene Consulting, Inc. kim@kimgreene.com
  • 2. MWLUG 2017 Moving Collaboration Forward About Me { “name”: “Kim Greene”, “email”: “kim@kimgreene.com”, “company”: “Kim Greene Consulting, Inc.”, “website”: “www.kimgreene.com”, “twitter”: “@iSeriesDomino”, }
  • 3. MWLUG 2017 Moving Collaboration Forward Agenda • Why companies are turning to MongoDB • Hardware • Sharding • Database choice • Schema design • Indexes
  • 4. MWLUG 2017 Moving Collaboration Forward Why Customers are Turning to MongoDB
  • 5. MWLUG 2017 Moving Collaboration Forward Inserting Data: MongoDB vs. MySQL • Inserting 1,615 chemical compound records into two parent- child tables • Turned off foreign keys during insert and used string builder to create bulk insert SQL statement in MySQL
  • 6. MWLUG 2017 Moving Collaboration Forward MongoDB vs. S3 Performance • Download 220 KB object from MongoDB was 7x faster cold, and 3x faster when warm
  • 8. MWLUG 2017 Moving Collaboration Forward Hardware Requirements • Can use commodity hardware all way up to IBM Power and zSeries – Use multi-core systems when possible • Ensure indexes and most frequently accessed data (working set) fits in RAM • RAM is the most important factor for hardware • db.serverStatus() – Use to obtain info on current working set
  • 9. MWLUG 2017 Moving Collaboration Forward Hardware Requirements • Data placement is key! – Use SSDs for: • Write-heavy data • Placement of journals • Compression – Can reduces footprint by up to 80% – Equals fewer bits read from disk
  • 10. MWLUG 2017 Moving Collaboration Forward Compression • WiredTiger has native compression • Compression options for documents and indexes – Snappy • Default, balance between high document and journal compression ratios • Low CPU overhead – zlib • Higher compression • Additional CPU overhead – Prefix • What indexes use by default, reduces size ~50%
  • 11. MWLUG 2017 Moving Collaboration Forward Compression • Snappy and SSDs – Use for frequently accessed data • zlib and rotational disks – Use for older, less frequently accessed data
  • 13. MWLUG 2017 Moving Collaboration Forward Sharding • Place a portion of data on certain servers • Use with – Very large data sets – High throughput demands – Needs for geo location of data
  • 15. MWLUG 2017 Moving Collaboration Forward Sharding • Distribute data across cluster based on query patterns or data locality • Types of sharding: – Range – Hash – Zone
  • 16. MWLUG 2017 Moving Collaboration Forward Sharding • Range sharding – Divides data into ranges based on shard key values – Efficient queries when reading documents in a contiguous range – Can have poor read and write performance with poor shard key range selection • Hash sharding – More even data distribution – Can impact performance of range-based queries • Zone sharding – Used to improve locality of data • By geographic region • By hardware configuration for tiered storage-architectures • By application feature
  • 17. MWLUG 2017 Moving Collaboration Forward Database Choice
  • 18. MWLUG 2017 Moving Collaboration Forward 4 Types of Databases • WiredTiger – Most commonly used database type, the default • Encrypted – For highly sensitive data • In-memory – For performance critical data • MMAPv1 – Improved version of database used in earlier versions of MongoDB
  • 19. MWLUG 2017 Moving Collaboration Forward In-Memory Database • Doesn’t maintain any on-disk data, including configuration data, indexes, user credentials, etc. • Entire database needs to be able to fit into memory – Key to know true “working set”
  • 20. MWLUG 2017 Moving Collaboration Forward Schema Design
  • 21. MWLUG 2017 Moving Collaboration Forward Schema Design • Schema design is critical – Most performance problems are because of poor schema design • RDBMS schema design – What answers do I have? • MongoDB schema design – What questions will I have?
  • 22. MWLUG 2017 Moving Collaboration Forward Schema Design • Key items of focus –How will the data be accessed –What is the projected read to write ratio –How large will documents become • Want to structure data to match how it is queried and updated
  • 23. MWLUG 2017 Moving Collaboration Forward Schema Design • Basic schema designs – Embedding – Referencing – Denormalization
  • 24. MWLUG 2017 Moving Collaboration Forward Embedding • To embed or not to embed – Favor embedding unless there is a compelling reason not to – If an object needs to be accessed frequently on it’s own, it’s best not to embed
  • 25. MWLUG 2017 Moving Collaboration Forward Embedding
  • 26. MWLUG 2017 Moving Collaboration Forward Embedding • Use when all of the data is manipulated together • Relationship between collections is one-to- one • When able to be used, normally reduces latency of get requests by 50%
  • 27. MWLUG 2017 Moving Collaboration Forward Referencing • Link to other documents when: – One to many relationships – Need to access parts of data stand-alone
  • 28. MWLUG 2017 Moving Collaboration Forward Denormalizing • Read/write ratio is key for deciding on denormalizing – Fields primarily read and rarely updated are good candidates – If a field is updated frequently, don’t do it
  • 29. MWLUG 2017 Moving Collaboration Forward Denormalization • Limits having to perform application-level join for denormalized fields
  • 30. MWLUG 2017 Moving Collaboration Forward Denormalization • Consider the write/read ratio when denormalizing – A field that will mostly be read and only seldom updated is a good candidate for denormalization – As updates become more frequent relative to queries, the savings from denormalization decrease
  • 31. MWLUG 2017 Moving Collaboration Forward Back to Embedding • Embed computed information when you write it – Prevents needing to retrieve and compute over and over – Works well if writes are infrequent – Pushes work to the application on the write, result is dramatically improved read time
  • 32. MWLUG 2017 Moving Collaboration Forward Back to Embedding • What to look for when choosing referencing vs embedding data in a document – Things that don’t change often and aren’t read often are best stored in a separate document – Parent document contains a reference to the less frequently accessed/updated document
  • 33. MWLUG 2017 Moving Collaboration Forward Schema Design • The MongoDB data schema design of choice depends – entirely – on your particular application’s data access patterns • Structure your data to match the ways that your application queries and updates it
  • 35. MWLUG 2017 Moving Collaboration Forward Indexes • ½ of all performance issues are due to missing or incorrect secondary indexes • Index early • Index often
  • 36. MWLUG 2017 Moving Collaboration Forward Types of Secondary Indexes • Unique • Compound • Array • Time to Live (TTL) • Geospatial • Partial • Sparse • Text search
  • 37. MWLUG 2017 Moving Collaboration Forward Types of Secondary Indexes • Unique – Rejects insertion of new documents or the update of a document with an existing value for the field it is built over • Compound – Useful for queries that specify multiple predicates • Example: Find customers based on last name, first name, and city of residence – Can reduce the need for single field indexes as any leading field in a compound index can be used
  • 38. MWLUG 2017 Moving Collaboration Forward Types of Secondary Indexes • Array – For fields that contain an array, each array value is stored as a separate index entry • Time to Live (TTL) – Specify a period of time after which the data is automatically deleted from the database
  • 39. MWLUG 2017 Moving Collaboration Forward Types of Secondary Indexes • Geospatial – Allow MongoDB to optimize queries for documents that contain points or a polygon that are closest to a given point or line; that are within a circle, rectangle, or polygon; or that intersect with a circle, rectangle, or polygon • Partial – Use to include only documents that meet specific conditions
  • 40. MWLUG 2017 Moving Collaboration Forward Types of Secondary Indexes • Sparse – Contain entries for documents that contain a specified field – Allow for smaller, more efficient indexes when fields are not present in all documents • Text search – Specialized index for text search that uses advanced, language-specific linguistic rules for stemming, tokenization, case sensitivity and stop words
  • 41. MWLUG 2017 Moving Collaboration Forward Indexing Tidbits • Query optimizer – Selects best index to use by periodically running query plans • Index intersection – Allows MongoDB to use more than one index to optimize ad-hoc queries at run-time • Covered queries – Return results containing only indexed fields – Very efficient, results returned without reading from source documents
  • 42. MWLUG 2017 Moving Collaboration Forward Aggregation Pipeline • Replaces find in certain scenarios • Improves performance significantly – Moves processing from the client side to the server – Saves CPU and bandwidth • Reduce the amount of data transmitted to the application layer
  • 43. MWLUG 2017 Moving Collaboration Forward Where to Find More Information
  • 44. MWLUG 2017 Moving Collaboration Forward Where to Find More Information • MongoDB University – university.mongodb.com • YouTube tutorials – youtube.com/mongodb • MongoDB Performance Best Practices white paper – mongodb.com/collateral/mongodb-performance- best-practices