DBAtlas · 数据库运维图谱

测量 WiredTiger 缓存压力(填充率、脏数据比例、应用线程驱逐)

MongoDB性能

命令

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

作用

显示 WiredTiger 缓存大小、填充和脏数据百分比、应用线程被迫驱逐的页数,以及读/写 ticket 状态。

适用场景

磁盘读取增加、延迟突然飙升或写入吞吐量下降时;确定缓存大小时。

注意

填充率超过 80%(eviction_target)时后台驱逐开始;达到 95%(eviction_trigger)时应用线程也会参与驱逐,查询变慢。脏数据的目标是 5%,触发点是 20%;长期接近 20% 说明磁盘写入能力不足。pages evicted by application threads 计数器不断增长,就是用户直接感受到的延迟。这些值是累计计数器;请比较两次采样的差值。

在 DBAtlas 中打开 →

相关内容