Benchmark SSDs for AI Workloads Beyond Advertised Speeds
In this article
SSD specs like sequential read/write speeds rarely tell you how a drive will perform under real AI workloads, which involve random small-block I/O, sustained writes, and mixed read/write patterns. This guide walks you through a practical benchmarking process that measures what actually matters for AI training and inference, so you can choose and configure drives with confidence.
What You'll Need
- A Linux system (Ubuntu 22.04 or later recommended) with root/sudo access
- An SSD you want to test (NVMe or SATA)
- fio (flexible I/O tester) installed:
sudo apt install fio - Python 3 with
pandasandmatplotlib(for analysis/plots) - At least 10–20 GB of free space on the target drive for test files
- A stopwatch or terminal timer (optional)
Step-by-Step
- Identify your drive and its mount point. Run
lsblk -o NAME,SIZE,MODEL,MOUNTPOINTto see available disks. Note the device name (e.g.,/dev/nvme0n1) and the mount point (e.g.,/mnt/data). If the drive is not mounted, mount it withsudo mount /dev/nvme0n1 /mnt/data. - Check current drive health and settings. Run
sudo smartctl -a /dev/nvme0n1(install smartmontools if needed) to verify health and temperature. Also check if the drive is using a proper filesystem (ext4 or XFS) and that it is not nearly full. - Create a test directory. Use
sudo mkdir -p /mnt/data/benchand ensure you have write permission:sudo chmod 777 /mnt/data/bench. - Run a baseline sequential test. This confirms the drive is functioning and gives you a reference point. Use fio with a 4GB file, 1MB block size, and a single job:
sudo fio --name=seqread --rw=read --bs=1M --size=4G --iodepth=32 --ioengine=libaio --direct=1 --output-format=json --output=seqread.json
Repeat for write:--rw=write. Check the JSON output forread_bwandwrite_bw(in KiB/s). - Simulate AI training I/O: random 4K reads/writes. AI workloads often involve many small random accesses (e.g., loading batches of images or embeddings). Run:
sudo fio --name=randread --rw=randread --bs=4k --size=8G --iodepth=64 --ioengine=libaio --direct=1 --output-format=json --output=randread.json
Then the same with--rw=randwrite. Record theread_iopsandwrite_iopsvalues. - Test mixed read/write workloads. AI training often reads and writes simultaneously (e.g., checkpointing while loading data). Use
--rw=rwwith a 50/50 mix:sudo fio --name=mixed --rw=rw --rwmixread=50 --bs=64k --size=8G --iodepth=32 --ioengine=libaio --direct=1 --output-format=json --output=mixed.json
Look at theread_bwandwrite_bwvalues to see how the drive handles concurrent operations. - Measure sustained write performance (cache flush behavior). Many SSDs have a fast SLC cache that fills up, after which write speeds drop. Run a long write test with a file larger than the cache (e.g., 64GB) and monitor the write bandwidth over time:
sudo fio --name=longwrite --rw=write --bs=1M --size=64G --iodepth=32 --ioengine=libaio --direct=1 --output-format=json --output=longwrite.json
After it finishes, use a tool likefio_generate_plotsor parse the JSON to see if the bandwidth drops mid-test. You can also useiostat -x 1during the test to watchwMB/sin real time. - Test with a queue depth that matches your application. AI frameworks often use multiple threads. Repeat the random 4K test with
--iodepth=1and--iodepth=128to see how the drive scales. This reveals how well it handles parallel requests. - Run a realistic AI workload simulation. If you have a dataset, you can replay its I/O pattern using
fiowith a blktrace file. Alternatively, use a tool likevdbenchor create a custom script that reads many small files. For a quick simulation, create 10,000 small files (e.g., 64KB each) and read them in random order withfiousing--directory=/mnt/data/bench/smallfilesand--rw=randread. - Analyze the results. Convert the JSON outputs to a readable format using a Python script that extracts the key metrics (bandwidth, IOPS, latency). Plot the sustained write bandwidth over time to see if there is a cliff. Compare your numbers to the advertised specs – note that advertised speeds are usually sequential and with low queue depth, so your real-world numbers will likely be lower.
- Consider thermal throttling. For NVMe drives, run a test for 30 minutes and monitor temperature with
sudo nvme smart-log /dev/nvme0n1. If the temperature exceeds 80°C, performance may drop. Ensure adequate cooling.
Common Mistakes
- Using too small a file size. A 1GB test may fit entirely in the drive's cache, giving unrealistic results. Use files larger than the cache (typically 2-4x the cache size).
- Not using
--direct=1. This bypasses the OS page cache, ensuring you're testing the raw drive, not RAM. - Ignoring queue depth. A single-threaded test with iodepth=1 will not stress the drive. AI workloads often have many concurrent requests.
- Testing on a nearly full drive. SSDs slow down when they are over 90% full due to garbage collection. Ensure you have plenty of free space.
- Not checking the filesystem. Some filesystems (e.g., ext4 with certain mount options) can introduce overhead. For pure hardware testing, use a raw device or an XFS filesystem.
- Assuming sustained write speed is the same as burst speed. Many drives have a fast SLC cache that fills up quickly. Always test with a file larger than the cache.
Tips
- Use
--output-format=jsonfor all fio runs. This makes parsing and comparing results much easier. - Run each test at least twice. The first run may be affected by write caching or thermal warm-up. Take the average of the runs.
- Monitor the drive's temperature and SMART stats during tests. A drive that throttles will show lower performance after a few minutes.
- If you are comparing drives, use the same filesystem and mount options. Differences in filesystem can skew results.
- For AI workloads, prioritize random read IOPS and mixed read/write bandwidth over sequential speeds. These are more representative of training loops.
- Consider using
blktraceto capture a real workload trace. This gives the most accurate simulation, but requires extra setup.
Troubleshooting
- fio fails with “permission denied”. Ensure you run with
sudoand that the test directory is writable. Also check that the filesystem is mounted with proper permissions. - Drive appears to be slower than advertised. Check if the drive is connected to a PCIe 3.0 slot instead of 4.0, or if it is a SATA drive. Also check if the drive is throttling due to heat.
- Results vary wildly between runs. This could be due to background processes. Close unnecessary applications and run tests multiple times. Also ensure the drive is not being used by other processes.
- fio reports “Invalid value” for
--rwmixread. Make sure you use--rw=rwand not--rw=randrwwhen specifying a mix. Use--rw=randrwfor random mixed workloads. - Cannot parse JSON output. Use a Python script or a tool like
jqto extract values. For example:jq '.jobs[0].read.bw' seqread.json. - Test takes too long. Reduce the file size or use a shorter runtime. For a quick check, use
--runtime=60instead of a fixed size.
Frequently Asked Questions
Why are my benchmark numbers lower than the advertised speeds?
Advertised speeds are usually sequential, with a low queue depth, and often use a small test file that fits in the drive's cache. Real-world AI workloads involve random access, higher queue depths, and sustained writes that exceed the cache, so lower numbers are expected.
What is the SLC cache and why does it matter?
Many SSDs use a portion of the flash as a fast single-level-cell (SLC) cache to boost write speeds. Once this cache fills, write speeds drop to the raw TLC/QLC speed. Testing with files larger than the cache reveals the sustained write performance.
Should I test with a raw device or a filesystem?
For pure hardware performance, test a raw device (e.g., /dev/nvme0n1). For realistic application performance, test with a filesystem. Both are useful; just be consistent when comparing drives.
How do I choose the right queue depth for testing?
It depends on your workload. AI frameworks like PyTorch often use multiple data loader workers, so a queue depth of 32-64 is reasonable. Test with a few depths (1, 16, 64, 128) to see the scaling curve.
What is the best block size for AI workload testing?
AI data is often stored as images, text, or embeddings, which are typically 4KB to 64KB. Test with 4K and 64K block sizes to cover both random and sequential patterns.
Can I use these benchmarks to compare different SSDs?
Yes, as long as you run the same tests on both drives with identical settings, filesystem, and mount options. This gives a fair comparison for AI-specific workloads.