Skip to content

Instantly share code, notes, and snippets.

@jorpic
Created January 22, 2016 21:26
Show Gist options
  • Save jorpic/103a9a939be6144462b9 to your computer and use it in GitHub Desktop.
Save jorpic/103a9a939be6144462b9 to your computer and use it in GitHub Desktop.
M202: MongoDB Advanced Deployment and Operations

https://university.mongodb.com/courses/M202/about

1

  • 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
  • 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
  • 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
  • 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment