MongoDB MMS – How to Determine Database Read/Write Ratio

mongodb

By looking at MongoDB MMS charts, is there a way to calculate a database read/write ratio, or roughly determine whether a database is read-heavy or write-heavy?

Assume I do not have contact with developer and therefore has no idea on database's schema or use case.

Edit: I understand MMS metrics are based on entire databases on the single mongod instance. However, assume currently there is only one database exist.

Example MMS chart:
mms_chart

Best Answer

MMS charts have multiple quantities you can add to determine the number of reads and the number of writes - at a glance they are:

  • Reads:

    • queries
    • getmores
  • Writes:

    • inserts
    • updates
    • deletes/removes

As a general ballpark value, the ratio of these is fine.

It's not quite this simple though because there are other read and write "loads" on the system:

  • system writes which don't show up in counters, such as TTL deletes, etc.
  • commands which may be reads: count, aggregate, in 2.4 and earlier getLastError().
  • commands which may be writes: findAndModify, etc.
  • on a primary a multi-update or remove that matches multiple documents is recorded as a single write operation (on secondary it would be a single write per document affected)
  • a single read operation (aka find) may be a fast, indexed query or a slow collection scan of millions of documents.

Hope this helps, as in general you usually care about not exact absolute ratio of reads to writes, but rather how that ratio may be changing over time.