In mongodb data files are preallocates to a particular size,like first data file .0, the next .1, etc. The first file mongod allocates is 64 megabytes, the next 128 megabytes, and so on, up to 2 gigabytes, at which point all subsequent files are 2 gigabytes. Is there any way the default size can be change to 2GB? if so what will be the impact on the performance.


There is no way to specify your own sizes, the only way to alter the sizes of data files is to specify (or not) the smallfiles option. That will bring the file sizes down to 25% of the default (max of 512MB rather than 2GB etc.)

You can pre-allocate the files yourself in advance (with dd, fallocate or similar). I have a sample bash script using fallocate for just such a purpose here on GitHub. You still have to do the progression of sizes up to 2GB first, then allocate the remainder at 2GB though. If nothing else, full pre-allocation would let you determine if allocation is having any kind of impact on your testing.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.