MongoDB
Debugging Performance Problems
@ConradIrwin
MongoDB Performance Debugging
20M crashes/day
2TB data / 50GB index
11 nodes / 3* availability zones
I don't care if MongoDB is slow
I care if my app is slow
How to make
app fast agai
it's slow bec
of the way I'm
What does slow mean?
MongoDB Performance Debugging
Performance over time
Performance over time
MongoDB Performance Debugging
It's slow :(
MongoDB Performance Debugging
MongoDB Performance Debugging
Solution 1
Denormalize
MongoDB Performance Debugging
It's fast :)
It's slow :(
db.errors.
find({project_id: x}).
sort({ _id: -1}).
limit(30)
db.errors.
find({project_id: x}).
sort({ _id: -1}).
limit(30).
explain()
{
"cursor":"BtreeCursor_id_reverse",
"isMultiKey":false,
"n":0,
"nscannedObjects":227756,
"nscanned":227756,
"nscannedObjectsAllPlans":227756,
"nscannedAllPlans":227756,
"scanAndOrder":false,
"indexOnly":false,
"nYields":1779,
"nChunkSkips":0,
"millis":461,
"indexBounds":{
"_id":[
[
{
"$maxElement":1
},
{
"$minElement":1
}
]
]
},
"server":"Jaroussky.local:27017",
"filterSet":false
}
{
"cursor" :
"BtreeCursor _id_ reverse",
"nscanned" : 227756,
"indexBounds" : {"_id" : [
[{"$maxElement" : 1},
{"$minElement" : 1}]
]
}
}
{
"cursor" :
"BtreeCursor _id_ reverse",
"nscanned" : 227756,
"indexBounds" : {"_id" : [
[{"$maxElement" : 1},
{"$minElement" : 1}]
]
}
}
Solution 2
Index
db.errors.ensureIndex(
{project_id: 1, id: -1}
)
{"cursor" : "BtreeCursor
project_id_1__id_1",
"nscanned" : 6,
"indexBounds" : {
"project_id" : [[
ObjectId(x),ObjectId(x)
]],
"_id" : [[
{"$minElement" : 1},
{"$maxElement" : 1}
]]
}}
It's fast :)
It's slow :(
Only 1 query...
Indexed properly...
mongostat
insert queryupdatedeletegetmorecommandflushesmapped
5 97 57 *0 95 127|0 0 320g
5 98 61 *0 113 146|0 0 320g
8 94 61 *0 95 137|0 0 320g
vsize resfaults lockeddbidxmiss% qr|qw ar|aw
641g 8.65g 7bugsnag:47.7% 0 0|0 0|0
641g 8.66g 2bugsnag:21.0% 0 0|0 0|0
641g 8.64g 3bugsnag:23.4% 0 0|0 0|0
netInnetOut conn setrepl time
47k 73k 145bugsnag1 PRI 06:34:05
63k 99k 146bugsnag1 PRI 06:34:06
98k 124k 146bugsnag1 PRI 06:34:07
command locked db time
127|0 bugsnag:47.7% 06:34:05
146|0 bugsnag:21.0% 06:34:06
137|0 bugsnag:23.4% 06:34:07
MongoDB Performance Debugging
Solution 3
Shard
MongoDB Performance Debugging
sh.shardCollection("errors"
{
project_id: 1,
_id: -1
})
command locked db time
83|0 bugsnag:3.1% 06:46:12
69|0 bugsnag:4.1% 06:46:13
73|0 bugsnag:2.4% 06:46:14
It's fast :)
It's slow :(
Only 1 query...
Indexed properly...
Lock % ok...
iostat
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/savgrq-sz
xvdi 0.00 2.00 15.00 743.00 436.00 7905.50 22.01
xvdi 0.00 2.00 0.00 663.00 0.00 6706.00 20.23
xvdi 0.00 1.00 0.00 726.00 0.00 5593.50 15.41
avgqu-sz awaitr_awaitw_await svctm %util
11.02 14.54 5.33 14.73 0.60 45.60
8.04 12.12 0.00 12.12 0.51 33.60
13.01 17.92 0.00 17.92 0.50 36.40
rkB/s wkB/s await %util
7660 138 14.73 83.60
2248 2043 12.12 65.20
7905 436 17.92 45.60
db.stats()['indexSize']
= 3852071824
= 3932614656
free -b(m3.medium)
Solution 4
Scale
db.stats()['indexSize']
= 3852071824
= 15775363072
free -b(r3.large)
It's fast :)
It's slow :(
Main query seems fine...
"Quick" queries sometimes slow...
mongotop
ns total read write 2
014-06-22T19:11:35
bugsnag.events 35ms 0ms 35ms
bugsnag.errors 30ms 6ms 24ms
bugsnag.system.namespaces 26ms 26ms 0ms
bugsnag.projects 12ms 5ms 7ms
bugsnag.users 15ms 2ms 13ms
bugsnag.error_aggregates 4ms 0ms 4ms
bugsnag.deploys 4ms 3ms 1ms
bugsnag.event_tallies 3ms 0ms 3ms
ns tot r w
bugsnag.events 35 0 35
bugsnag.errors 30 6 24
bugsnag.projects 12 5 7
bugsnag.users 15 7 8
Solution 5
Tag shards
It's fast :)
Solution 1
Denormalize
Solution 2
Index
Solution 3
Shard
Solution 4
Scale
Solution 5
Tag shards
Solution 6
...
NewRelic / Skylight
explain()
mongostat
iostat
...
It will
be slow
You can
speed it up
Thanks!@ConradIrwin

More Related Content

PDF
Cassandra 101
PDF
MariaDB 10.5 binary install (바이너리 설치)
PDF
[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우
PDF
Evolution of MongoDB Replicaset and Its Best Practices
PPTX
MySQL_MariaDB-성능개선-202201.pptx
PDF
GeoServer 2.4.x 한국어 사용자 지침서
PDF
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
PPTX
CockroachDB
Cassandra 101
MariaDB 10.5 binary install (바이너리 설치)
[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우
Evolution of MongoDB Replicaset and Its Best Practices
MySQL_MariaDB-성능개선-202201.pptx
GeoServer 2.4.x 한국어 사용자 지침서
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
CockroachDB

What's hot (20)

PPTX
Indexing with MongoDB
PDF
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
PDF
How to Manage Scale-Out Environments with MariaDB MaxScale
PDF
MySQLレプリケーションあれやこれや
PDF
MySQLを割と一人で300台管理する技術
PPTX
Grunt - The JavaScript Task Runner
PDF
ETL With Cassandra Streaming Bulk Loading
PDF
Percona XtraDB Cluster
PDF
Cassandra overview
PDF
いろいろ考えると日本語の全文検索もMySQLがいいね!
PDF
MariaDB Administrator 교육
PDF
メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月
PPTX
What you need to know about ceph
PPTX
오픈소스 GIS 교육 - PostGIS
PDF
Introduction of Redis as NoSQL Database
PDF
Galera Cluster: Synchronous Multi-Master Replication for MySQL HA
PDF
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
PPTX
Open Source GIS 기초교육 4일차 - GeoServer 기초 2014년 7월판
PDF
An Introduction to Redis for Developers.pdf
PDF
1.mysql disk io 모니터링 및 분석사례
Indexing with MongoDB
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
How to Manage Scale-Out Environments with MariaDB MaxScale
MySQLレプリケーションあれやこれや
MySQLを割と一人で300台管理する技術
Grunt - The JavaScript Task Runner
ETL With Cassandra Streaming Bulk Loading
Percona XtraDB Cluster
Cassandra overview
いろいろ考えると日本語の全文検索もMySQLがいいね!
MariaDB Administrator 교육
メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月
What you need to know about ceph
오픈소스 GIS 교육 - PostGIS
Introduction of Redis as NoSQL Database
Galera Cluster: Synchronous Multi-Master Replication for MySQL HA
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
Open Source GIS 기초교육 4일차 - GeoServer 기초 2014년 7월판
An Introduction to Redis for Developers.pdf
1.mysql disk io 모니터링 및 분석사례
Ad

Similar to MongoDB Performance Debugging (20)

PDF
Mongodb debugging-performance-problems
PDF
Optimizing Slow Queries with Indexes and Creativity
PDF
Top Node.js Metrics to Watch
PPTX
MongoDB Chunks - Distribution, Splitting, and Merging
PDF
MongoDB Indexing Constraints and Creative Schemas
PDF
Zero, one, two, Freddy's coming for you
PDF
Philipp Krenn "Make Your Data FABulous"
PDF
Philipp Krenn | Make Your Data FABulous | Codemotion Madrid 2018
PDF
Nodejs性能分析优化和分布式设计探讨
PPTX
Building a Generic Search Screen using Dynamic SQL
PPTX
자바 성능 강의
PDF
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
PPTX
GC Tuning & Troubleshooting Crash Course
ODP
Beyond PHP - it's not (just) about the code
PDF
MongoDB Europe 2016 - Debugging MongoDB Performance
PDF
Scaling MongoDB; Sharding Into and Beyond the Multi-Terabyte Range
ODP
Beyond PHP - it's not (just) about the code
PPTX
Architecting Secure and Compliant Applications with MongoDB
ODP
Beyond php - it's not (just) about the code
ODP
Beyond PHP - It's not (just) about the code
Mongodb debugging-performance-problems
Optimizing Slow Queries with Indexes and Creativity
Top Node.js Metrics to Watch
MongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Indexing Constraints and Creative Schemas
Zero, one, two, Freddy's coming for you
Philipp Krenn "Make Your Data FABulous"
Philipp Krenn | Make Your Data FABulous | Codemotion Madrid 2018
Nodejs性能分析优化和分布式设计探讨
Building a Generic Search Screen using Dynamic SQL
자바 성능 강의
Robert Pankowecki - Czy sprzedawcy SQLowych baz nas oszukali?
GC Tuning & Troubleshooting Crash Course
Beyond PHP - it's not (just) about the code
MongoDB Europe 2016 - Debugging MongoDB Performance
Scaling MongoDB; Sharding Into and Beyond the Multi-Terabyte Range
Beyond PHP - it's not (just) about the code
Architecting Secure and Compliant Applications with MongoDB
Beyond php - it's not (just) about the code
Beyond PHP - It's not (just) about the code
Ad

More from MongoDB (20)

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

Recently uploaded (20)

PDF
August Patch Tuesday
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
observCloud-Native Containerability and monitoring.pptx
DOCX
search engine optimization ppt fir known well about this
PDF
Unlock new opportunities with location data.pdf
PDF
CloudStack 4.21: First Look Webinar slides
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
Tartificialntelligence_presentation.pptx
PDF
Architecture types and enterprise applications.pdf
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
August Patch Tuesday
WOOl fibre morphology and structure.pdf for textiles
Taming the Chaos: How to Turn Unstructured Data into Decisions
Univ-Connecticut-ChatGPT-Presentaion.pdf
NewMind AI Weekly Chronicles – August ’25 Week III
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
observCloud-Native Containerability and monitoring.pptx
search engine optimization ppt fir known well about this
Unlock new opportunities with location data.pdf
CloudStack 4.21: First Look Webinar slides
A comparative study of natural language inference in Swahili using monolingua...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Tartificialntelligence_presentation.pptx
Architecture types and enterprise applications.pdf
sustainability-14-14877-v2.pddhzftheheeeee
Assigned Numbers - 2025 - Bluetooth® Document
A novel scalable deep ensemble learning framework for big data classification...
Web Crawler for Trend Tracking Gen Z Insights.pptx

MongoDB Performance Debugging