MongoDB - Hold index + working set tight in RAM

I am currently using MongoDB to store a single dataset. This data is 50 GB in size and has about 95 GB of indexes. I am running a machine with 256 GB of RAM. I basically want to have the entire index and working set in RAM, since the machine is designed exclusively for mongo.

Currently, I see that although mongo works with a collection size of 50 GB + an index size of 95 GB, the total RAM used in the device is less than 20 GB.

Is there a way to force mongo to use available RAM so that it can store all its indexes and working set in memory?

+4
source share
1 answer

When your mongod process is running, it has no data in resident memory. Data is then uploaded as it is accessed. Given that your collection fits in memory (here and here), you can run a touch command on it. On Linux, this will call the readahead system call to pull your data and indexes into the file system cache, making it available in memory for mongod. On Windows, mongod will read the first byte of each page, pulling it into memory.

If your collection + indexes do not fit in memory, only the tail of the data will be available, which can be accessed at the time of the touch.

+5
source

Source: https://habr.com/ru/post/1479036/


All Articles