MongoShard Dossier: MongoDB 8.0 WiredTiger (RAM − 1 GB) × 0.50 Cache Formula
In our deterministic MongoShard memory model, we explain why setting wiredTigerCacheSizeGB to 80% of host RAM triggers Linux OOM kills — and how WiredTiger splits uncompressed B-Tree pages against the compressed OS filesystem cache.
MongoShard Analysis: Uncompressed WiredTiger Cache vs Compressed Linux XFS Cache
Unlike single-tier database buffers, WiredTiger operates a dual-layer memory hierarchy on Linux. On-disk blocks inside /var/lib/mongodb are compressed with Zstd or Snappy and buffered inside the Linux kernel page cache. Once mongod promotes a block into the WiredTiger internal cache, we must account for raw uncompressed BSON documents, prefix-compressed B-Tree index pages, ~1 MB per TCP connection stack, and 100 MB blocking $sort/$group stages outside WiredTiger.
MongoShard Reference /etc/mongod.conf & Linux THP / Swappiness Parameters
MongoShard reference snippet (wiredtiger-cache-sizing-formula) — verify host RAM and XFS mount before restarting mongod.
# 1. Linux Kernel Tuning (/etc/sysctl.d/99-mongodb.conf)
vm.swappiness = 1
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5
vm.max_map_count = 128000
# 2. /etc/mongod.conf (32 GB RAM Node -> 0.5 * (32 - 1) = 15.5 GB WT Cache)
storage:
dbPath: /var/lib/mongodb
wiredTiger:
engineConfig:
cacheSizeGB: 15.5
zstdCompressionLevel: 6
collectionConfig:
blockCompressor: zstd
indexConfig:
prefixCompression: true
MongoShard Capacity Matrix for DOSSIER 01 • WIREDTIGER INTERNAL CACHE EQUATION (2026-11-12 Public Rates)
Each hardware tier below follows our MongoShard (RAM − 1 GB) × 0.50 calculation and cites public vendor pricing retrieved on 2026-11-12 from UltaHost (https://ultahost.com/vps-hosting) and Hostinger (https://www.hostinger.com/vps-hosting).
| Workload Scale / Node Class | WiredTiger Cache | Active Working Set Fit | Reference Host Tier (2026-11-12) |
|---|---|---|---|
| 8 GB DDR5 Node (Atlas M30 Class) | 3.5 GB WT Cache | ~3.0 GB Indexes + Hot BSON | Hostinger KVM 2 ($5.99/mo promo) |
| 32 GB DDR5 Node (Atlas M50 Class) | 15.5 GB WT Cache | ~12.0 GB Indexes + Hot BSON | UltaHost VDS 32GB ($58/mo) |
| 128 GB ECC Node (Atlas M80 Class) | 63.5 GB WT Cache | ~48.0 GB Indexes + Hot BSON | UltaHost VDS 128GB ($179/mo) |
MongoShard Production Deployment Checklist (WT-MEMORY-MATH)
- Format /var/lib/mongodb exclusively on XFS (noatime) rather than ext4 to prevent filesystem journal lock contention during WiredTiger checkpoints.
- Set Linux Transparent Huge Pages (THP) to never via systemd before launching mongod so memory defragmentation stalls do not freeze B-Tree lookups.
- Track db.serverStatus().wiredTiger.cache["tracked dirty bytes in the cache"] and keep dirty ratio below the 5% background target.
- Lower storage.wiredTiger.engineConfig.cacheSizeGB explicitly whenever co-locating Node.js, Docker, or pbm-agent processes on the same server.
Inspect UltaHost Specs for MongoShard WT-MEMORY-MATH ↗ Compare Hostinger Rates for MongoShard WT-MEMORY-MATH ↗ Load Preset in MongoShard Calculator →
MongoShard Technical FAQ: DOSSIER 01 • WIREDTIGER INTERNAL CACHE EQUATION
Why does MongoShard cap WiredTiger cacheSizeGB near 50% instead of 75% on a 64GB VDS?
Even on an isolated 64 GB VDS node, mongod relies on the remaining ~32.5 GB of host RAM for Linux Zstd compressed filesystem blocks, journal buffers, per-connection thread stacks (~1 MB each), and aggregation pipeline stages. Raising cacheSizeGB above 60% risks kernel OOM-killer termination during traffic spikes.
How does MongoShard recommend diagnosing an undersized WiredTiger internal cache?
Inspect db.serverStatus().wiredTiger.cache["application threads page read from disk to cache"] and application-thread eviction counters. When client request threads are forced to evict dirty pages synchronously, your active B-Tree working set has outgrown WiredTiger RAM.