Unlocking SSD Performance in KVM: Tackling Write Amplification and Best Practices
This article explains SSD fundamentals such as page and block structures, the causes and mitigation of write amplification through reserved space and TRIM, presents detailed KVM virtualization test setups and results, and compares SSD types, offering practical guidance for maximizing SSD performance in virtualized environments.
SSD Write Amplification and Solutions
SSD uses flash memory with a page (4 KB) as the smallest read/write unit and a block (512 KB) as the smallest erase unit.
Page size: 4 KB, minimum read/write.
Block size: 512 KB (128 pages), minimum erase.
When writing, SSD can only write to an empty page; previously written pages must be erased at the block level, leading to the three‑step process of reading other pages in the block, erasing the block, and rewriting the data—this is called write amplification, which reduces efficiency.
1. Reserve Space
Consumer SSDs typically reserve 7‑10 % of capacity, while enterprise SSDs reserve over 20 % (some even 100 %). Reserved space ensures free pages are always available, reducing write amplification and improving performance under heavy write loads.
2. Use TRIM
TRIM is an OS‑level command that informs the SSD which pages are no longer needed, allowing the SSD’s garbage‑collection process to erase them in advance. Supported OS versions include RHEL/CentOS 6.4+, Linux kernel 2.6.33+, and Windows 7/2008 R2+.
SSD Testing and Usage in KVM
To evaluate SSD performance under KVM virtualization, a series of benchmarks were conducted using Intel 320 SSD on three test servers with different hardware configurations. The test environment was CentOS 6.3 (kernel 2.6.32) and tools used were fio for Linux and iometer for Windows.
Test Environment
Server 1: HP DL380G7, 24 GB RAM, Intel Xeon E5620, 8 × 160 GB SSD in RAID 10.
Server 2: Lenovo 510G7, 8 GB RAM, Intel Xeon E5506, 2 × 300 GB SSD in RAID 1.
Server 3: HP DL380G6, 16 GB RAM, Intel Xeon E5520, 4 × 160 GB SSD in RAID 10.
Before testing, LVM caching was disabled, RAID battery removed, kernel cache cleared via a cron job, and SSDs were pre‑filled to simulate wear.
Test results showed the following key observations:
SSD read performance exceeds write performance.
Larger capacity SSDs deliver higher throughput.
Under KVM, Linux VMs outperform Windows VMs when using the same storage.
Using raw block devices (LVM) yields better performance than file‑based (qcow2) images.
SSD Types: SLC, MLC, and TLC
Flash memory cells store electrons in the gate; based on how many charge levels are distinguishable, they are classified as:
SLC (Single‑Level Cell): two states, highest speed and endurance, highest cost.
MLC (Multi‑Level Cell): four states, moderate speed and endurance, lower cost.
TLC (Triple‑Level Cell): six states, lowest speed and endurance, lowest cost.
SLC offers the longest lifespan (≈100 k erase cycles), while MLC supports ≈10 k cycles and TLC even fewer, but MLC and TLC provide higher density and lower price, which is why most consumer SSDs use MLC.
Conclusions
SSDs can achieve tens of thousands of IOPS for reads and several thousand for writes, far surpassing mechanical disks.
In virtualized environments, using raw block devices for VM disks maximizes SSD performance.
Employing reserved space and TRIM effectively mitigates write amplification.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.