Cache Policy of MongoDB

16 views
Skip to first unread message

Moditha Hewasinghage

unread,
Jun 3, 2018, 3:08:14 PM6/3/18
to mongodb-dev
Hello everyone.

I am intereseted in getting to know about the cache policy of MongoDB. Unfortuantely I haven't found much information in my search and decided to  run some experiments to get an idea. I have 4 different sized databases with the same schema and i run a simple retrieve by _id (100000 iterations)on each of them simultaneously and get the collection.stats() to see the cache usage of each of the collections. From what I see the larger collection (1.5M documents) gets the majority of the cahce and the rest of the collections get an equal share regardless of the size of the cache. I also ran other experiments reading each collection one after the other and seems like MongoDB discards the smaller collections first eventhough they are fresh in cache. (image 2 where i read the collections in the descending size and image 3 where i read them in the ascending order). I thought it could be LRU as the cache policy. Can someone tell me the reason behid this behaviour and preferebly the cache policy being used. (i am using MongoDB 3.6.1 with wired tiger and i have reduced the cache to 256MB for the experiments)

Reading together


Larger first

Smaller First

Thank you,
Moditha

Auto Generated Inline Image 1
Auto Generated Inline Image 2
Auto Generated Inline Image 3
Reply all
Reply to author
Forward
0 new messages