0% found this document useful (0 votes)
370 views21 pages

MongoDB Profiler Deep Dive MongoDB Austin 2013

MongoDB Performance tuning with the profiler.

Uploaded by

Kenny Gorman
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
370 views21 pages

MongoDB Profiler Deep Dive MongoDB Austin 2013

MongoDB Performance tuning with the profiler.

Uploaded by

Kenny Gorman
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

MongoDB profiler deep dive

MongoAustin 2013 Kenny Gorman Founder, ObjectRocket


@objectrocket @kennygorman

What is the profiler?


Captures metadata about what operations ran on the
system

Saves data into capped collection Designed for basic performance analysis In the spirit of < instrument everything > Very interesting advanced analysis possible Aggregation Historical/Time-series analysis Operational monitoring

Using the profiler



Turn it on, leave it. Development cycle Production debugging Overall performance management Find candidates, pull out query, use explain() Rinse and Repeat

Simple example

example: https://gist.github.com/kgorman/4756589

Annotated

example: https://gist.github.com/kgorman/4957922

Important Profiler Attributes


ts: timestamp of the operation ns: namespace of the db and collection accessed op: the operation type nreturned: the number of documents being returned nscanned: the number of document scanned to return the result moved: if the operation caused a move millis: the total time in milliseconds that the operation took keyupdates:the number of indexes that required update http://docs.mongodb.org/manual/reference/database-profiler/

What to look for


fastMod Good! Fastest possible update. In-place atomic operator ($inc,$set) nretunred vs nscanned If nscanned != nscanned, you may have opportunity to tune. Indexing. key updates Secondary indexes. Minimize them ~10% reduction in performance for each secondary index moved Documents grow > padding factor You can't fix it other than to pad yourself manually db.collection.stats() shows padding 2.3.1+ usePowerOf2Sizes https://jira.mongodb.org/browse/SERVER-1810 nreturned; high number of them cardinality Just pure I/O

What doesn't it show?


IndexOnly Very fast, use explain() instead of profiler I/O

Page accesses Page calls Random I/O Data density/locality https://jira.mongodb.org/browse/SERVER-3546 (track I/O)

Plans Only explain() shows the full plan(s)

Profiler Analysis - FCS

Profiler Analysis - FCS

Profiler Analysis - Moved

Profiler Analysis - helpful queries

example: https://gist.github.com/kgorman/c5774670feb7436f4d69

Going Deeper with Profiler Analytics


In prod environment profiler has lots of data Prioritize tuning opportunities Prioritize performance issues Aggregation, summarization required Enter Aggregation Framework

Aggregation Framework - Example

Aggregation Framework - Example

example: https://gist.github.com/kgorman/995a3aa5b35e92e5ab57

Response time analysis


Response time = service time + queue time Each document in profile collection has a 'millis' attribute. The only true measure of response time in MongoDB

Response time analysis

Why is this useful?


When rolling new code Customer activity patterns Any time based patterns Capacity planning

Going nuts with profiler and timeseries


Turn on profiling Pull delta response time data from db.system.profile in aggregate in a loop Push to your favorite graphing/time-series program https://github.com/kgorman/slum

Going nuts with profiler and timeseries

Contact
@kennygorman @objectrocket [email protected] https://www.objectrocket.com

You might also like