SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

MongoDB WiredTiger Internals
MongoDB WiredTiger InternalsMongoDB WiredTiger Internals
MongoDB WiredTiger InternalsNorberto Leite
 
Introduction to MongoDB with PHP
Introduction to MongoDB with PHPIntroduction to MongoDB with PHP
Introduction to MongoDB with PHPfwso
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & IntroductionJerwin Roy
 
How to monitor MongoDB
How to monitor MongoDBHow to monitor MongoDB
How to monitor MongoDBServer Density
 
Postgres connections at scale
Postgres connections at scalePostgres connections at scale
Postgres connections at scaleMydbops
 
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 GoMongoDB
 
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
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkChris Westin
 
Challenges with MongoDB
Challenges with MongoDBChallenges with MongoDB
Challenges with MongoDBStone Gao
 
Connecting NodeJS & MongoDB
Connecting NodeJS & MongoDBConnecting NodeJS & MongoDB
Connecting NodeJS & MongoDBEnoch 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 DeploymentMongoDB
 
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, TaskRabbitRedis Labs
 

Mais procurados (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
 

Semelhante a Mongo performance tuning: tips and tricks

Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam 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-24Jim 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 CloudLyzun Oleksandr
 
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 interfaceJalal Zahid
 
Pandora FMS: MongoDB plugin
Pandora FMS: MongoDB pluginPandora FMS: MongoDB plugin
Pandora FMS: MongoDB pluginPandora 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.4Jim 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
 
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 101Angus Li
 
Strategies for Context Data Persistence
Strategies for Context Data PersistenceStrategies for Context Data Persistence
Strategies for Context Data PersistenceFIWARE
 
Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisationgrooverdan
 
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 Studyhernanibf
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010Bastian Feder
 
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 DemystifiedClaudio Procida
 

Semelhante a 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
 

Último

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Último (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

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