WiredTiger 캐시 압박 측정 (채움률, dirty 비율, 애플리케이션 eviction)
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 캐시 크기, 채움 및 dirty 비율, 애플리케이션 스레드가 강제로 evict한 페이지 수, 읽기/쓰기 ticket 상태를 보여 준다.
사용 시점
디스크 읽기가 증가하거나, 지연이 갑자기 튀거나, 쓰기 처리량이 떨어질 때. 캐시 크기를 산정할 때.
주의
채움이 80%(eviction_target)를 넘으면 백그라운드 eviction이 시작되고, 95%(eviction_trigger)에서는 애플리케이션 스레드도 eviction에 참여해 쿼리가 느려진다. dirty 데이터는 5%가 목표, 20%가 트리거이며 계속 20% 근처라면 디스크 쓰기 용량이 부족한 것이다. 증가하는 pages evicted by application threads 카운터는 사용자가 직접 체감하는 지연이다. 값은 누적 카운터이므로 두 샘플의 차이를 본다.