If we plot time as y and data size as x, then we can easily measure response time. If our plot has linear or polynomial line, then we may have response time degradation.
The causes of response time degradation are:
- Working set exceeding RAM.
- Queries taking longer as the data set grows.
- Growing pool of clients.
- Unbounded array growth.
- Excessive number of indexes.
Diagnose: Use mongstat
to show data coming along.For example, execute following command to show time, dirty amount of memory, used amount of memory, number of insert, queue read and write, and active read and write:
mongostat --port 27001 -o "time=T,dirty=dirty,used=used,insert=Inserts,qrw=qrw,arw=arw"
Solve:
- Increase cache size by set
cacheSizeGB
in configuration file to higher value. - Or, adding more RAM.
Diagnose:
- Set profiling level to debug anything and set threshold:
db.setProfilingLevel(2, <THRESHOLD>)
- Show the all slow operations:
db.system.profile.find().pretty()
- Generate plot:
mlogvis <LOG_PATH> --no-browser --out <HTML_FILE>
- Show the plot:
open <HTML_FILE>
Solve:
- Create appropriate indexes to support queries.