How to get the pages/bytes hit in MongoDB?

Hi all.

As far as I could check, MongoDB doesn’t have a page (or bytes) hit metric. So, how can I calculate it? I am trying to get the page (bytes) hit to get to the hit ratio.

I saw in another post the suggestion to use the following metrics from the wiredTiger.cache section. But what logic should be applied to them to get the page (bytes) hit and, therefore, the hit ratio?

  • bytes currently in the cache
  • tracked dirty bytes in the cache
  • bytes read into cache
  • bytes written from cache

Best Regards,

Rodrigo Lima.

Hello Rodrigo.

In the db.serverStatus().wiredTiger.cache command you will see some metrics. To perform the calculation we use the pages read in the cache (Pages Read Into Cache) and the total number of requests to the cache (Total Pager Requests).

The calculation is done as:

Cache hit rate = (1 - (Pages read from cache / Total requests)) * 100%

pages read into cache: 30
pages requested from the cache: 218

Cache hit rate = (1 - (30 / 218)) * 100%
Cache hit rate = 86.24%

1 Like

Thanks a lot, Samuel. :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.