Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
MongoDB Diagnostics and Performance Tuning
Search
dcrosta
January 23, 2012
Technology
3
1.7k
MongoDB Diagnostics and Performance Tuning
From MongoDB LA, January 19, 2012.
dcrosta
January 23, 2012
Tweet
Share
More Decks by dcrosta
See All by dcrosta
Let the computer write the tests
dcrosta
0
44
Good Test, Bad Test
dcrosta
1
670
Exploring Python Code Objects (PyOhio)
dcrosta
4
300
Python Packaging for Humans
dcrosta
13
480
Exploring Python Code Objects
dcrosta
5
240
Keystone: Python Web Development, Simplified
dcrosta
4
300
MongoDB In the Cloud with Amazon EC2
dcrosta
6
430
Evolution without Migration
dcrosta
2
420
Other Decks in Technology
See All in Technology
コンテンツを支える 若手ゲームクリエイターの アートディレクションの事例紹介 / cagamefi-game
cyberagentdevelopers
PRO
1
130
プロダクトエンジニアが活躍する環境を作りたくて 事業責任者になった話 ~プロダクトエンジニアの行き着く先~
gimupop
1
480
いまならこう作りたい AWSコンテナ[本格]入門ハンズオン 〜2024年版 ハンズオンの構想〜
horsewin
9
2.1k
Product Engineer Night #6プロダクトエンジニアを育む仕組み・施策
hacomono
PRO
1
470
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
9
120k
AIを駆使したゲーム開発戦略: 新設AI組織の取り組み / sge-ai-strategy
cyberagentdevelopers
PRO
1
130
Aurora_BlueGreenDeploymentsやってみた
tsukasa_ishimaru
1
130
신뢰할 수 있는 AI 검색 엔진을 만들기 위한 Liner의 여정
huffon
0
360
「最高のチューニング」をしないために / hack@delta 24.10
fujiwara3
21
3.5k
来年もre:Invent2024 に行きたいあなたへ - “集中”と“つながり”で楽しむ -
ny7760
0
470
日経電子版におけるリアルタイムレコメンドシステム開発の事例紹介/nikkei-realtime-recommender-system
yng87
1
510
IaC運用を楽にするためにCDK Pipelinesを導入したけど、思い通りにいかなかった話
smt7174
1
110
Featured
See All Featured
How to Ace a Technical Interview
jacobian
275
23k
Writing Fast Ruby
sferik
626
61k
Done Done
chrislema
181
16k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
37
1.8k
How GitHub (no longer) Works
holman
311
140k
Code Review Best Practice
trishagee
64
17k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
What's new in Ruby 2.0
geeforr
342
31k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
Measuring & Analyzing Core Web Vitals
bluesmoon
1
41
Transcript
Diagnostics and Performance Tuning Dan Crosta, 10gen
[email protected]
@lazlofruvous
Agenda •Tools •Performance Indicators
Speed MongoDB is a high-performance database, but how do I
know that I’m getting the best performance
TOOLS
1. mongostat
2.serverStatus > db.serverStatus(); { ! ! "host" : “MacBook.local", "version"
: "2.0.1", "process" : "mongod", "uptime" : 619052, // Lots more stats... }
3.Profiler > db.setProfilingLevel(2); { "was" : 0, "slowms" : 100,
"ok" : 1 }
3.Profiler > db.system.profile.find() { "ts" : ISODate("2011-09-30T02:07:11.370Z"), "op" : "query",
"ns" : "docs.spreadsheets", "query" : { "username": "dcrosta" }, "nscanned" : 20001, "nreturned" : 1, "responseLength" : 241, "millis" : 1407, "client" : "127.0.0.1", "user" : "" }
4.Monitoring Service • MMS: 10gen.com/try-mms • Nagios • Munin
INDICATORS
1.Slow Operations Sun May 22 19:01:47 [conn10] query docs.spreadsheets ntoreturn:100
reslen:510436 nscanned:19976 { username: “dcrosta”} nreturned:100 147ms
2.Replication Lag PRIMARY> rs.status() { "set" : "replSet", "date" :
ISODate("2011-09-30T02:28:21Z"), "myState" : 1, "members" : [ { "_id" : 0, "name" : "MacBook.local:30001", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "optime" : { "t" : 1317349400000, "i" : 1 }, "optimeDate" : ISODate("2011-09-30T02:23:20Z"), "self" : true }, { "_id" : 1, "name" : "MacBook.local:30002", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 302, "optime" : { "t" : 1317349400000, "i" : 1 }, "optimeDate" : ISODate("2011-09-28T10:17:47Z"), "lastHeartbeat" : ISODate("2011-09-30T02:28:19Z"),
3.Resident Memory > db.serverStatus().mem { "bits" : 64, // Need
64, not 32 "resident" : 7151, // Physical memory "virtual" : 14248, // Files + heap "mapped" : 6942 // Data files
3.Resident Memory > db.stats() { "db" : "docs", "collections" :
3, "objects" : 805543, "avgObjSize" : 5107.312096312674, "dataSize" : 4114159508, // ~4GB "storageSize" : 4282908160, // ~4GB "numExtents" : 33, "indexes" : 3, "indexSize" : 126984192, // ~126MB "fileSize" : 8519680000, // ~8.5GB "ok" : 1 }
3.Resident Memory ! ! indexSize + dataSize <= RAM
4.Page Faults > db.serverStatus().extra_info { ! "note" : "fields vary
by platform", ! “heap_usage_bytes” : 210656, ! “page_faults” : 2381 }
5.Write Lock Percentage > db.serverStatus().globalLock { "totalTime" : 2809217799, "lockTime"
: 13416655, "ratio" : 0.004775939766854653, }
Concurrency • One writer or many readers • Global RW
Lock • Yields on long-running ops and if we’re likely to go to disk.
High Lock Percentage? You’re Probably Paging!
6.Reader and Writer Queues > db.serverStatus().globalLock { "totalTime" : 2809217799,
"lockTime" : 13416655, "ratio" : 0.004775939766854653, "currentQueue" : { "total" : 1, "readers" : 1, "writers" : 0 }, "activeClients" : { "total" : 2, "readers" : 1, "writers" : 1 }
6.Reader and Writer Queues > db.currentOp() { "inprog" : [
{ "opid" : 6996, "active" : true, "lockType" : "read", "waitingForLock" : true, "secs_running" : 1, "op" : "query", "ns" : "docs.spreadsheets", "query" : { “username” : “Hackett, Bernie” }, "client" : "10.71.194.111:51015", "desc" : "conn", "threadId" : "0x152693000", "numYields" : 0 },
7.Background Flushing > db.serverStatus().backgroundFlushing { "flushes" : 5634, "total_ms" :
83556, "average_ms" : 14.830670926517572, "last_ms" : 4, "last_finished" : ISODate("2011-09-30T03:30:59.052Z") }
Disk Considerations • Raid • SSD • SAN?
8.Connections > db.serverStatus().connections { "current" : 7, "available" : 19993
}
9.Network Speed > db.serverStatus().network { "bytesIn" : 877291, "bytesOut" :
846300, "numRequests" : 9186 }
10.Fragmentation db.spreadsheets.stats() { "ns" : "docs.spreadhseets", "size" : 8200046932, //
~8GB "storageSize" : 11807223808, // ~11GB "paddingFactor" : 1.4302, "totalIndexSize" : 345964544, // ~345MB "indexSizes" : { "_id_" : 66772992, “username_1_filename_1” : 146079744, “username_1_updated_at_1” : 133111808 }, "ok" : 1 }
10.Fragmentation 2 is the Magic Number
storageSize / size > 2 • Might not be reclaiming
free space fast enough • Padding factor might not be correctly calibrated db.spreadsheets.runCommand(“compact”)
paddingFactor > 2 • You might have the wrong data
model • You might be growing documents too much • Should review Schema Design
download at mongoDB.org
We’re Hiring Engineers, Sales, Evangelist, Marketing, Support, Developers @mongodb_jobs http://linkd.in/joinmongo
We’re Always Around For Conferences, Appearances and Meetups 10gen.com/events @mongodb
h2p://bit.ly/mongo8