RocksDB & Port 25 Tuning
Tuning RocksDB block-cache-size vs write-buffer-size RAM
Prevent Linux OOM kills during heavy IMAP folder syncs by bounding RocksDB uncompressed block caches and memtable flush buffers.
65% Block Cache / 35% Memtable · Max 40% of Host RAM
Why Unbounded RocksDB Caches Starve Linux Page Cache
RocksDB allocates its block cache in user space while Tantivy relies heavily on OS page cache via memory-mapped files. Reserving more than 40% of total VPS RAM for RocksDB starves Tantivy mmap reads and forces disk thrashing during multi-user searches.
Sizing Write Buffers for Burst Ingestion
During initial imapsync migrations, increase write-buffer-size slightly and enable lz4 SSTable compression so burst writes flush sequentially without stalling IMAP APPEND commands.
Measured Thresholds & Stalwart Configuration Parameters
| Host RAM Tier | block-cache-size | write-buffer-size |
|---|---|---|
| 2 GB VPS (VC2 / Storage) | 256 MB (or use SQLite) | 64 MB (2 buffers max) |
| 4 GB VPS (HF / KVM 2) | 512 MB - 768 MB | 128 MB - 192 MB |
| 8 GB VPS (HF 8 GB) | 1,536 MB - 2,048 MB | 256 MB - 512 MB |