DBAtlas · Database operations atlas

Measure WiredTiger cache pressure (fill, dirty ratio, application eviction)

MongoDBPerformance

Command

const c = db.serverStatus().wiredTiger.cache;
const max = c["maximum bytes configured"];
({
  maxGB: (max / 1024 ** 3).toFixed(1),
  usedPct: (100 * c["bytes currently in the cache"] / max).toFixed(1),
  dirtyPct: (100 * c["tracked dirty bytes in the cache"] / max).toFixed(1),
  appThreadEvictedPages: c["pages evicted by application threads"],
  pagesReadIntoCache: c["pages read into cache"]
})
// Read/write ticket usage and queue:
db.serverStatus().wiredTiger.concurrentTransactions

What it does

Shows the WiredTiger cache size, its fill and dirty percentages, how many pages application threads were forced to evict, and the read/write ticket status.

When to use it

When disk reads increase, latency spikes suddenly or write throughput drops; when sizing the cache.

Caution

Once fill exceeds 80% (eviction_target) background eviction starts; at 95% (eviction_trigger) application threads also take part in eviction and queries slow down. For dirty data 5% is the target and 20% the trigger; constantly near 20% means disk write capacity is insufficient. A growing pages evicted by application threads counter is latency felt directly by users. Values are cumulative counters; look at the difference between two samples.

Open in DBAtlas →

Related