How to visually spot and analyze slow MongoDB operations
Kay Agahd idealo internet GmbH
How to visually spot and analyze slow MongoDB operations Kay Agahd - - PowerPoint PPT Presentation
How to visually spot and analyze slow MongoDB operations Kay Agahd idealo internet GmbH About me Current location: Berlin/Germany Education: Engineer's degree, Software Engineering Experience: Software developer from 1998 - 2009
Kay Agahd idealo internet GmbH
2
○ Software developer from 1998 - 2009 in Paris/France ○ Database engineer since 2012 at idealo in Berlin/Germany
3
comparison website and app
United Kingdom, France, Italy and Spain
(November 2018)
4
Why we need a better MongoDB profiler
6
database
7
8
time period (“types” means op type, user, server, query shape, etc.)
MongoDB slow operations profiler
10
DB 1 mongod 1 DB 2 DB n DB n1 mongod n DB n2 DB nm slow ops app profiler 1..n profiler n..m collector DB
11
{ "op": "query", "ns": "offerStore.offer", "query": { "find": "offer", "filter": { "shopId": 292731, "opIds": { "$in": [ 29337,5478 ] }, "offerStatus": { "$gt": 0 } }, "projection": { "traceId": 1, "bokey": 1, "version": 1, "offerTitle": 1 }, "batchSize":1000, ... "shardVersion": [ Timestamp(14944, 25276), ObjectId("591c6...8fcde") ] }, "keysExamined": 2210852, "docsExamined": 232, "cursorExhausted": true, "keyUpdates": 0, "writeConflicts": 0, "numYield": 17272, "locks": { "Global": { "acquireCount": { "r": NumberLong("34546")}}, "Database": { "acquireCount": { "r": NumberLong("17273")}}, "Collection": { "acquireCount": { "r": NumberLong("17273")}} }, "nreturned": 185, "responseLength": 119954, "protocol": "op_command", "millis": 4189, "execStats": { "stage": "PROJECTION", "nReturned": 185, "executionTimeMillisEstimate": 3941, "works": 2210853, "advanced": 185,
... 124 lines omitted ...
}, "ts": ISODate("2018-10-26T07:17:12.747Z"), "client": "10.135.128.219", "allUsers": [ { "user": "__system", "db": "local" } ], "user": "__system@local" }
12
{ "_id":ObjectId("5bd3090b68b5c4203f53ce7e"), "ts":ISODate("2018-10-26T12:31:07.752Z"), "adr":"host523.idealo.de", "lbl":"offerStoreDE", "rs":"offerStoreDE09", "db":"offerStore", "col":"offers" "op":"getmore", "fields":["shopId", "opIds.$in", "offerStatus.$gt"], "sort":["_id"], "nret":500, "reslen":94656, "millis":5322, "user":"__system@local" }
13
14
{ "collector":{ "hosts":["myCollectorHost_member1:27017", "myCollectorHost_member2:27017", "myCollectorHost_member3:27017"], "db":"profiling", "collection":"slowops", "adminUser":"", "adminPw":"" }, ...
15
"profiled":[ { "label":"dbs foo", "hosts":["someHost1:27017", "someHost2:27017", "someHost3:27017"], "ns":["someDB.someCollection", "anotherDB.*"], "enabled": false }, { "label":"dbs bar", "hosts":["someMongoRouter1:27017","someMongoRouter2:27017"], "ns":["*.*"], "adminUser":"kay", "adminPw":"never.tell.it!:-)", "enabled":false, "slowMS":500, "responseTimeoutInMs":2000 } ],...
16
17
18
2018/10/30 10:04 = Count:95 db=offerStore coll=offers
fields=[shopId,mCC.$gt] Duration: avg:322 max:990 sum:31.682 ms
19
20
21
{$match: { ts: {$gt:from, $lt:to}} }, {$group: {_id: {label:"$lbl"}, count:{$sum:1}, sumMs:{$sum:"$millis"}, maxMs:{$max:"$millis"}, sumNret:{$sum:"$nret"}, sumResplen:{$sum:"$reslen"} } }
22
23
https://medium.com/idealo-tech-blog/how-to-visually-spot- and-analyze-slow-mongodb-operations-d91ac819e0de
24