Understanding Write Amplification in NVMe SSDs Under WAL-Heavy Workloads
Modern NVMe drives advertise sequential write speeds above 3 GB/s, yet a write-ahead log calling fdatasync() on tiny 512-byte records can stall at a fraction of that bandwidth while driving SMART wear indicators up rapidly.
Inside the Flash Translation Layer
NAND flash reads and writes in pages (typically 4 KiB to 16 KiB) but can only erase in multi-megabyte erase blocks. Repeatedly flushing small unaligned writes forces the drive controller to perform read-modify-write cycles and aggressive background garbage collection.
Practical Mitigations
- Ensure filesystem partitions and database page sizes align cleanly to 4 KiB physical sector boundaries (check with
nvme id-ns). - Enable WAL group commit so concurrent transactions amortize a single
fdatasyncacross multiple commits. - Leave 15–20% unallocated over-provisioning space on write-intensive volumes to keep garbage collection latency predictable.
# Inspect logical vs physical block sizes and wear percentage
nvme smart-log /dev/nvme0n1 | grep -E "percentage_used|data_units_written"