SlideShare a Scribd company logo
Mongo performance

  Stuff that matters
     Monitoring
        Tuning
     Conclusion

    vladimir.malyk@gmail.com
Mongo performance




Stuff that matters
Mongo Pain. Write lock

Multiple readers / Single-writer lock
( http://en.wikipedia.org/wiki/Readers-writer_lock)

ver < 2.0 - has a process-wide write lock

2.1.1+ per-database locking
( https://jira.mongodb.org/browse/SERVER-4328 )

per-collection locking
( https://jira.mongodb.org/browse/SERVER-1240 )
Mongo Pain. mmap
      http://docs.mongodb.org/manual/faq/storage/

Page faults: will occur if you’re attempting to access part
of a memory-mapped file that isn’t in memory.
( http://docs.mongodb.org/manual/reference/glossary/#term-page-fault )

Performance: page fault can take around 40,000 times
longer than a nonfaulting memory operation

   ver 2.0+, this is addressed by detecting the likelihood of a page fault and
              releasing the lock before faulting - YIELD operation;

                      SSD is a doctor's stuff in this case;
Mongo Atomicity

Write operations are atomic on the level of a single
document: no single write operation can atomically affect more
than one document or more than one collection.
(http://docs.mongodb.org/manual/tutorial/isolate-sequence-of-operations/)

hint: isolates a write operation that affects multiple documents
from other write operations
(http://docs.mongodb.org/manual/reference/operator/isolated/)

http://docs.mongodb.org/manual/reference/command/findAndModify/
Mongo performance




Monitoring
Monitoring: HTTP Console
 http://docs.mongodb.org/ecosystem/tools/http-interf
                aces/#http-console

   http://dbhost.net:28017/

   Replica Set Admin UI, Oplog status

   clients

   DBTOP

  write lock % time in write lock, by 4 sec periods (form ~12% to
~6%)

   Log - By default the slow operation threshold is 100 millis
Monitoring: SSH Console


netstat -n | wc -l

ps aux | grep mongodb

cat /proc/{pid}/limits | grep "Max open files"

ulimit -n 65000
(http://www.andrewrollins.com/2010/10/20/mongodb-open-file-limit/)
Monitoring: Custom
     http://sj.malyk/admin/MongoProfileLog/
milestone marks: do fake update before and after app execution

http://docs.mongodb.org/manual/tutorial/manage-the-database-profi
ler/

http://docs.mongodb.org/manual/reference/database-profiler/

https://gist.github.com/vladimir-malyk/5047107

https://gist.github.com/kgorman/995a3aa5b35e92e5ab57
Mongo performance




Tuning
Tuning: Heavy tricks



degradation - don't write to an unimportant
collections;

partitioning - move an unimportant
collections to a separate replicaset.
Tuning: Indexes
* Create Indexes to Support Your Queries
* Use Compound Indexes to Support Several Different Queries
    * -10% write performance for each additional index
(http://www.slideshare.net/mongodb/mongodb-performance-tuning)
* Create Indexes that Support Covered Queries
* Use Indexes to Sort Query Results
    * http://blog.mongolab.com/2012/06/cardinal-ins/
        * First, fields on which you will query for exact values.
        * Second, fields on which you will sort.
        * Finally, fields on which you will query for a range of val.
* Ensure Indexes Fit RAM
* Creating index on a big collection takes a lot of time with write
lock
Tuning: Common tricks

  http://blog.serverdensity.com/mongodb-schema-design-pitfalls/

* Avoid growing documents (“moved” in system.profile)
* Use field modifiers: Instead of sending a whole new document
to update an existing one, you can set or remove specific fields
* Preallocate documents: preallocate the document with
placeholder values, then use the $set field modifier to change the
actual value later
* Field names take up space:
http://blog.serverdensity.com/on-shortened-field-names-in-mongod
b/
* Consider using _id for your own purposes
Tuning: Explain

 http://docs.mongodb.org/manual/reference/explain/

* http://docs.mongodb.org/manual/reference/explain/#explain.cursor
* http://docs.mongodb.org/manual/reference/explain/#explain.net
* http://docs.mongodb.org/manual/reference/explain/#explain.nscanned
* http://docs.mongodb.org/manual/reference/explain/#explain.n
* http://docs.mongodb.org/manual/reference/explain/#explain.scanAndOrder
* http://docs.mongodb.org/manual/reference/explain/#explain.indexOnly
* http://docs.mongodb.org/manual/reference/explain/#explain.nYields
* http://docs.mongodb.org/manual/reference/explain/#explain.allPlans
Mongo performance




Conclusion
Mongo: Tips and tricks


* deal with db disk fragmentation:
    * manual defragmentation (via replica resync);
    * http://docs.mongodb.org/manual/reference/command/compact/

* Can't take a write lock while out of disk space:
   * you need some free space - db defrag will help you;
Mongo: Concurrency
            http://docs.mongodb.org/manual/faq/concurrency/

http://docs.mongodb.org/manual/faq/concurrency/#how-do-i-see-the-status-
of-locks-on-my-mongod-instances

http://docs.mongodb.org/manual/faq/concurrency/#which-operations-lock-th
e-database

http://docs.mongodb.org/manual/faq/concurrency/#which-administrative-co
mmands-lock-the-database
    * db.auth() - lock the database but only hold the lock for a very short time

   http://blog.serverdensity.com/goodbye-global-lock-mongodb-2-0-vs-2-2/
               why it's a good idea to upgrade your mongodb
Mongo: Some links



http://www.slideshare.net/mongodb/mongodb-performance-tuning

http://blog.pythonisito.com/2011/12/mongodbs-write-lock.html

More Related Content

What's hot

MongoDB WiredTiger Internals
MongoDB WiredTiger InternalsMongoDB WiredTiger Internals
MongoDB WiredTiger Internals
Norberto Leite
 
Introduction to MongoDB with PHP
Introduction to MongoDB with PHPIntroduction to MongoDB with PHP
Introduction to MongoDB with PHP
fwso
 
Mongodb
MongodbMongodb
Mongodb
Scott Motte
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
Jerwin Roy
 
How to monitor MongoDB
How to monitor MongoDBHow to monitor MongoDB
How to monitor MongoDB
Server Density
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
NexThoughts Technologies
 
Postgres connections at scale
Postgres connections at scalePostgres connections at scale
Postgres connections at scale
Mydbops
 
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in GoPutting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
MongoDB
 
Distributed computing in browsers as client side attack
Distributed computing in browsers as client side attackDistributed computing in browsers as client side attack
Distributed computing in browsers as client side attackIvan Novikov
 
Containers > VMs
Containers > VMsContainers > VMs
Containers > VMs
David Timothy Strauss
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
Chris Westin
 
Challenges with MongoDB
Challenges with MongoDBChallenges with MongoDB
Challenges with MongoDB
Stone Gao
 
Connecting NodeJS & MongoDB
Connecting NodeJS & MongoDBConnecting NodeJS & MongoDB
Connecting NodeJS & MongoDB
Enoch Joshua
 
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
MongoDB
 
Data normalization weaknesses
Data normalization weaknessesData normalization weaknesses
Data normalization weaknessesIvan Novikov
 
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Severalnines
 
Engage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data CollectionEngage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data CollectionWebtrends
 
Back to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentBack to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production Deployment
MongoDB
 
Large Scale Log collection using LogStash & mongoDB
Large Scale Log collection using LogStash & mongoDB Large Scale Log collection using LogStash & mongoDB
Large Scale Log collection using LogStash & mongoDB
Gaurav Bhardwaj
 
Background Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbitBackground Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbit
Redis Labs
 

What's hot (20)

MongoDB WiredTiger Internals
MongoDB WiredTiger InternalsMongoDB WiredTiger Internals
MongoDB WiredTiger Internals
 
Introduction to MongoDB with PHP
Introduction to MongoDB with PHPIntroduction to MongoDB with PHP
Introduction to MongoDB with PHP
 
Mongodb
MongodbMongodb
Mongodb
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
 
How to monitor MongoDB
How to monitor MongoDBHow to monitor MongoDB
How to monitor MongoDB
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
Postgres connections at scale
Postgres connections at scalePostgres connections at scale
Postgres connections at scale
 
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in GoPutting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
 
Distributed computing in browsers as client side attack
Distributed computing in browsers as client side attackDistributed computing in browsers as client side attack
Distributed computing in browsers as client side attack
 
Containers > VMs
Containers > VMsContainers > VMs
Containers > VMs
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
 
Challenges with MongoDB
Challenges with MongoDBChallenges with MongoDB
Challenges with MongoDB
 
Connecting NodeJS & MongoDB
Connecting NodeJS & MongoDBConnecting NodeJS & MongoDB
Connecting NodeJS & MongoDB
 
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
 
Data normalization weaknesses
Data normalization weaknessesData normalization weaknesses
Data normalization weaknesses
 
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
 
Engage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data CollectionEngage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data Collection
 
Back to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentBack to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production Deployment
 
Large Scale Log collection using LogStash & mongoDB
Large Scale Log collection using LogStash & mongoDB Large Scale Log collection using LogStash & mongoDB
Large Scale Log collection using LogStash & mongoDB
 
Background Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbitBackground Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbit
 

Similar to Mongo performance tuning: tips and tricks

Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
Sam Keen
 
What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24
Jim Jagielski
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Lyzun Oleksandr
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
Matteo Moretti
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsMarcelo Pinheiro
 
Odoo command line interface
Odoo command line interfaceOdoo command line interface
Odoo command line interface
Jalal Zahid
 
Pandora FMS: MongoDB plugin
Pandora FMS: MongoDB pluginPandora FMS: MongoDB plugin
Pandora FMS: MongoDB plugin
Pandora FMS
 
ApacheConNA 2015: What's new in Apache httpd 2.4
ApacheConNA 2015: What's new in Apache httpd 2.4ApacheConNA 2015: What's new in Apache httpd 2.4
ApacheConNA 2015: What's new in Apache httpd 2.4
Jim Jagielski
 
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Aleksey Tkachenko
 
Mongo-Drupal
Mongo-DrupalMongo-Drupal
Mongo-Drupal
Forest Mars
 
Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)
Valerii Kravchuk
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
Angus Li
 
Mdb dn 2016_09_34_features
Mdb dn 2016_09_34_featuresMdb dn 2016_09_34_features
Mdb dn 2016_09_34_features
Daniel M. Farrell
 
Strategies for Context Data Persistence
Strategies for Context Data PersistenceStrategies for Context Data Persistence
Strategies for Context Data Persistence
FIWARE
 
Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisation
grooverdan
 
0628阙宏宇
0628阙宏宇0628阙宏宇
0628阙宏宇zhu02
 
Drupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case StudyDrupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case Study
hernanibf
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
Bastian Feder
 
Topology backend using kafka
Topology backend using kafkaTopology backend using kafka
Topology backend using kafka
Andriansyah Yusuf Rizal
 
Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes Demystified
Claudio Procida
 

Similar to Mongo performance tuning: tips and tricks (20)

Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento Cloud
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
Odoo command line interface
Odoo command line interfaceOdoo command line interface
Odoo command line interface
 
Pandora FMS: MongoDB plugin
Pandora FMS: MongoDB pluginPandora FMS: MongoDB plugin
Pandora FMS: MongoDB plugin
 
ApacheConNA 2015: What's new in Apache httpd 2.4
ApacheConNA 2015: What's new in Apache httpd 2.4ApacheConNA 2015: What's new in Apache httpd 2.4
ApacheConNA 2015: What's new in Apache httpd 2.4
 
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...
 
Mongo-Drupal
Mongo-DrupalMongo-Drupal
Mongo-Drupal
 
Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
 
Mdb dn 2016_09_34_features
Mdb dn 2016_09_34_featuresMdb dn 2016_09_34_features
Mdb dn 2016_09_34_features
 
Strategies for Context Data Persistence
Strategies for Context Data PersistenceStrategies for Context Data Persistence
Strategies for Context Data Persistence
 
Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisation
 
0628阙宏宇
0628阙宏宇0628阙宏宇
0628阙宏宇
 
Drupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case StudyDrupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case Study
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
 
Topology backend using kafka
Topology backend using kafkaTopology backend using kafka
Topology backend using kafka
 
Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes Demystified
 

Recently uploaded

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

Mongo performance tuning: tips and tricks

  • 1. Mongo performance Stuff that matters Monitoring Tuning Conclusion vladimir.malyk@gmail.com
  • 3. Mongo Pain. Write lock Multiple readers / Single-writer lock ( http://en.wikipedia.org/wiki/Readers-writer_lock) ver < 2.0 - has a process-wide write lock 2.1.1+ per-database locking ( https://jira.mongodb.org/browse/SERVER-4328 ) per-collection locking ( https://jira.mongodb.org/browse/SERVER-1240 )
  • 4. Mongo Pain. mmap http://docs.mongodb.org/manual/faq/storage/ Page faults: will occur if you’re attempting to access part of a memory-mapped file that isn’t in memory. ( http://docs.mongodb.org/manual/reference/glossary/#term-page-fault ) Performance: page fault can take around 40,000 times longer than a nonfaulting memory operation ver 2.0+, this is addressed by detecting the likelihood of a page fault and releasing the lock before faulting - YIELD operation; SSD is a doctor's stuff in this case;
  • 5. Mongo Atomicity Write operations are atomic on the level of a single document: no single write operation can atomically affect more than one document or more than one collection. (http://docs.mongodb.org/manual/tutorial/isolate-sequence-of-operations/) hint: isolates a write operation that affects multiple documents from other write operations (http://docs.mongodb.org/manual/reference/operator/isolated/) http://docs.mongodb.org/manual/reference/command/findAndModify/
  • 7. Monitoring: HTTP Console http://docs.mongodb.org/ecosystem/tools/http-interf aces/#http-console http://dbhost.net:28017/ Replica Set Admin UI, Oplog status clients DBTOP write lock % time in write lock, by 4 sec periods (form ~12% to ~6%) Log - By default the slow operation threshold is 100 millis
  • 8. Monitoring: SSH Console netstat -n | wc -l ps aux | grep mongodb cat /proc/{pid}/limits | grep "Max open files" ulimit -n 65000 (http://www.andrewrollins.com/2010/10/20/mongodb-open-file-limit/)
  • 9. Monitoring: Custom http://sj.malyk/admin/MongoProfileLog/ milestone marks: do fake update before and after app execution http://docs.mongodb.org/manual/tutorial/manage-the-database-profi ler/ http://docs.mongodb.org/manual/reference/database-profiler/ https://gist.github.com/vladimir-malyk/5047107 https://gist.github.com/kgorman/995a3aa5b35e92e5ab57
  • 11. Tuning: Heavy tricks degradation - don't write to an unimportant collections; partitioning - move an unimportant collections to a separate replicaset.
  • 12. Tuning: Indexes * Create Indexes to Support Your Queries * Use Compound Indexes to Support Several Different Queries * -10% write performance for each additional index (http://www.slideshare.net/mongodb/mongodb-performance-tuning) * Create Indexes that Support Covered Queries * Use Indexes to Sort Query Results * http://blog.mongolab.com/2012/06/cardinal-ins/ * First, fields on which you will query for exact values. * Second, fields on which you will sort. * Finally, fields on which you will query for a range of val. * Ensure Indexes Fit RAM * Creating index on a big collection takes a lot of time with write lock
  • 13. Tuning: Common tricks http://blog.serverdensity.com/mongodb-schema-design-pitfalls/ * Avoid growing documents (“moved” in system.profile) * Use field modifiers: Instead of sending a whole new document to update an existing one, you can set or remove specific fields * Preallocate documents: preallocate the document with placeholder values, then use the $set field modifier to change the actual value later * Field names take up space: http://blog.serverdensity.com/on-shortened-field-names-in-mongod b/ * Consider using _id for your own purposes
  • 14. Tuning: Explain http://docs.mongodb.org/manual/reference/explain/ * http://docs.mongodb.org/manual/reference/explain/#explain.cursor * http://docs.mongodb.org/manual/reference/explain/#explain.net * http://docs.mongodb.org/manual/reference/explain/#explain.nscanned * http://docs.mongodb.org/manual/reference/explain/#explain.n * http://docs.mongodb.org/manual/reference/explain/#explain.scanAndOrder * http://docs.mongodb.org/manual/reference/explain/#explain.indexOnly * http://docs.mongodb.org/manual/reference/explain/#explain.nYields * http://docs.mongodb.org/manual/reference/explain/#explain.allPlans
  • 16. Mongo: Tips and tricks * deal with db disk fragmentation: * manual defragmentation (via replica resync); * http://docs.mongodb.org/manual/reference/command/compact/ * Can't take a write lock while out of disk space: * you need some free space - db defrag will help you;
  • 17. Mongo: Concurrency http://docs.mongodb.org/manual/faq/concurrency/ http://docs.mongodb.org/manual/faq/concurrency/#how-do-i-see-the-status- of-locks-on-my-mongod-instances http://docs.mongodb.org/manual/faq/concurrency/#which-operations-lock-th e-database http://docs.mongodb.org/manual/faq/concurrency/#which-administrative-co mmands-lock-the-database * db.auth() - lock the database but only hold the lock for a very short time http://blog.serverdensity.com/goodbye-global-lock-mongodb-2-0-vs-2-2/ why it's a good idea to upgrade your mongodb