Explaining SSD write amplification and wear leveling
Write amplification arises because NAND flash can only program bits from 1 to 0 and must erase entire blocks (e.g., 256KB) before rewriting; thus, modifying a small 4KB page requires reading, rewriting, and erasing the full block, causing extra internal writes. The flash translation layer (FTL) maps logical addresses to physical pages, manages free blocks, performs garbage collection, and implements dynamic wear leveling by allocating writes to blocks with the lowest erase counts to distribute wear evenly, while occasionally moving static data for wear balancing. Writing 4KB triggers erasing 256KB blocks because NAND erase granularity is at the block level, so updates are out-of-place until garbage collection consolidates valid pages and erases whole blocks, contributing to write amplification.
What makes flash‑based SSDs different from a rotating disk is not so much the interface as the physics of the medium. NAND cells are arranged in pages and erase‑blocks, a typical consumer device might have 4 KiB or 8 KiB pages grouped into 64–128‑page blocks. Two key constraints are:
- You can only programme a cell once after it has been erased, and programming can only change a bit from “1” to “0”. To turn a “0” back into a “1” you have to erase, and erase operates on the whole block, not on a single 4 KiB page.
- Pages cannot be overwritten in place. If you have already programmed a 4 KiB page and later want to change it, you must write the new data to a fresh, pre‑erased page elsewhere and mark the old page invalid. At some point the block containing that old page must be erased to recover the space.
That is where “write amplification” comes from. From the host’s point of view you issued a single 4 KiB update, but internally the controller may have to read the other 63 valid pages in the 256 KiB block, write all of them and the modified page into a different, empty block, and then erase the old block. The ratio of internal NAND traffic to host traffic is >1; in a badly behaved workload every logical 4 KiB update can drive hundreds of kilobytes of flash writes and an erase, hence the shorthand “a 4 KB write requires erasing a 256 KB block”.
To hide these constraints from the host, SSDs implement a flash translation layer (FTL). The FTL maintains a mapping from logical block numbers to physical flash pages, a pool of erased “free” blocks, and metadata such as per–block erase counts. Small random host writes are turned into log‑structured appends to free pages; the old physical pages are marked stale. When the free pool runs low, a garbage collector picks victim blocks, copies out any still‑valid pages to a new block and erases the victim to replenish the free pool. Dynamic wear levelling is the policy layer on top of this: the FTL chooses target blocks for new data and for garbage‑collection based on their erase counts so that heavily written logical addresses are continually moved around to the least‑worn physical blocks. A more aggressive “static” wear leveller will occasionally move long‑lived (“cold”) data as well, to avoid creating a few very heavily erased blocks next to many almost‑unused ones, but even the basic dynamic scheme keeps the erase count distribution flat by steering updates away from hot spots.