https://university.mongodb.com/courses/M202/about
- Memory model
- mmap (deprecated after introducing WiredTiger engine)
- Working set (portion of data that is accessed most often)
- indexes
- subset of data
- Resident memory (amount of RAM currently used by the database process)
- shared view (mmap of data file) vs. private view (remap of shared view)
- remapping doubles usage of virtual memory usage (not physical)
- private view is used for journalling
- sudden drop of resident memory (when part of memory is marked as filesystem cache)
- data is still cached in memory
- shared view (mmap of data file) vs. private view (remap of shared view)
- Wired Tiger
- document level locking
- compression (zlib, snappy)
- half of available memory is used for WT cache
- Process restarts
- after killing mongod, some data is still in memory (FS cache)
- to drop FS caches
echo 3 > /proc/sys/vm/drop_caches
sysctl -w vm.drop_caches=1
- Storage
- spinning disks
- capped collections
- journal
- spinning disks
- File systems & options
- ext4 & xfs support
fallocate()
(which is fast) - ext3 does not support
fallocate()
and requires filling file with zeroes to allocate 2G file- this is slow
- ext4 & xfs support
- Readahead
- number of extra sectors to be read form disk on data access
# blockdev --report
- big readahead is good when
- data locality is high
- data seeks are expensive (not so true for SSD)
- lower readahead is preferred when effective memory usage is required (prevent thrashing FS cache)
- lower boundary for readahead is equal to index bucket size (8k = 16 sectos)