测试硬盘 IOPS 最准确、最专业的工具是 Fio。因为它能模拟数据库的“随机读写”行为,而简单的 dd 命令只能测连续读写速度(吞吐量),对数据库优化的参考价值不大。
使用 Fio 进行专业测试(推荐)
这是业界标准,能直接告诉你是否配得上 innodb_io_capacity = 10000 这个参数。
1. 安装 Fio
根据你的系统运行以下命令:
-
CentOS:
yum install fio -y -
Ubuntu/Debian:
apt-get install fio -y
2. 运行测试命令
注意:请在你的数据盘挂载目录下运行(比如进入 /www 或 /www/server/data),因为有些服务器系统盘和数据盘性能不一样。
测试随机写入 (Random Write) - 模拟数据库高并发写入:
Bash
fio -filename=test_io_file -direct=1 -iodepth=64 -thread -rw=randwrite -ioengine=libaio -bs=4k -size=2G -numjobs=1 -runtime=60 -group_reporting -name=mytest
测试随机读取 (Random Read) - 模拟复杂的 SQL 查询:
Bash
fio -filename=test_io_file -direct=1 -iodepth=64 -thread -rw=randread -ioengine=libaio -bs=4k -size=2G -numjobs=1 -runtime=60 -group_reporting -name=mytest
3. 怎么看结果?
命令跑完后,看输出结果中的 IOPS 这一行:
Plaintext
Jobs: 1 (f=1): [w(1)][100.0%][r=0KiB/s,w=420MiB/s][r=0,w=107k IOPS][eta 00m:00s]
或者看详细报告里的:
Plaintext
write: IOPS=107k, BW=419MiB/s (439MB/s)(24.6GiB/60001msec)
-
IOPS=107k:意思是每秒 10.7 万次操作。
以下是Netcup VPS100G12pro的测试结果:
测试结果分析
-
随机写入 (Random Write):
31.6k IOPS。 这是数据库最看重的指标。一般普通 SSD 只有 3k-5k,你达到了 3万+,这意味着你的数据库写入瓶颈几乎不存在。 -
随机读取 (Random Read):
102k IOPS。 读性能更是甚至溢出,高达 10万 IOPS,这对于查询密集的网站来说是完美的。 -
延迟:写入平均延迟仅 2ms,读取仅 0.6ms,极低。
root@v2202412245792303242:~# fio -filename=test_io_file -direct=1 -iodepth=64 -thread -rw=randwrite -ioengine=libaio -bs=4k -size=2G -numjobs=1 -runtime=60 -group_reporting -name=mytest
mytest: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=64
fio-3.25
Starting 1 thread
mytest: Laying out IO file (1 file / 2048MiB)
Jobs: 1 (f=1): [w(1)][12.5%][w=109MiB/s][w=27.8k IOPS][eta Jobs: 1 (f=1): [w(1)][19.0%][w=132MiB/s][w=33.7k IOPS][eta Jobs: 1 (f=1): [w(1)][26.3%][w=143MiB/s][w=36.6k IOPS][eta Jobs: 1 (f=1): [w(1)][33.3%][w=137MiB/s][w=35.2k IOPS][eta Jobs: 1 (f=1): [w(1)][41.2%][w=143MiB/s][w=36.5k IOPS][eta Jobs: 1 (f=1): [w(1)][47.1%][w=142MiB/s][w=36.4k IOPS][eta Jobs: 1 (f=1): [w(1)][52.9%][w=126MiB/s][w=32.2k IOPS][eta Jobs: 1 (f=1): [w(1)][62.5%][w=142MiB/s][w=36.4k IOPS][eta Jobs: 1 (f=1): [w(1)][64.7%][w=72.8MiB/s][w=18.6k IOPS][etaJobs: 1 (f=1): [w(1)][70.6%][w=119MiB/s][w=30.6k IOPS][eta Jobs: 1 (f=1): [w(1)][76.5%][w=142MiB/s][w=36.4k IOPS][eta Jobs: 1 (f=1): [w(1)][87.5%][w=142MiB/s][w=36.4k IOPS][eta Jobs: 1 (f=1): [w(1)][93.8%][w=142MiB/s][w=36.3k IOPS][eta Jobs: 1 (f=1): [w(1)][100.0%][w=117MiB/s][w=29.9k IOPS][eta 00m:00s]
mytest: (groupid=0, jobs=1): err= 0: pid=849293: Sat Dec 13 20:59:24 2025
write: IOPS=31.6k, BW=123MiB/s (129MB/s)(2048MiB/16592msec); 0 zone resets
slat (usec): min=5, max=474132, avg=17.19, stdev=658.54
clat (usec): min=173, max=513016, avg=2007.37, stdev=6237.50
lat (usec): min=182, max=513051, avg=2024.67, stdev=6277.92
clat percentiles (usec):
| 1.00th=[ 416], 5.00th=[ 979], 10.00th=[ 1156], 20.00th=[ 1401],
| 30.00th=[ 1565], 40.00th=[ 1663], 50.00th=[ 1713], 60.00th=[ 1762],
| 70.00th=[ 1811], 80.00th=[ 1958], 90.00th=[ 2442], 95.00th=[ 3392],
| 99.00th=[ 7308], 99.50th=[ 10290], 99.90th=[ 29230], 99.95th=[ 47449],
| 99.99th=[480248]
bw ( KiB/s): min=50760, max=151504, per=100.00%, avg=126415.27, stdev=28115.70, samples=33
iops : min=12690, max=37876, avg=31603.82, stdev=7028.93, samples=33
lat (usec) : 250=0.12%, 500=1.36%, 750=1.10%, 1000=2.79%
lat (msec) : 2=76.21%, 4=14.57%, 10=3.32%, 20=0.40%, 50=0.08%
lat (msec) : 100=0.01%, 250=0.02%, 500=0.01%, 750=0.01%
cpu : usr=4.51%, sys=41.88%, ctx=198295, majf=0, minf=1
IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=0.1%, >=64=100.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.1%, >=64=0.0%
issued rwts: total=0,524288,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=64
Run status group 0 (all jobs):
WRITE: bw=123MiB/s (129MB/s), 123MiB/s-123MiB/s (129MB/s-129MB/s), io=2048MiB (2147MB), run=16592-16592msec
Disk stats (read/write):
vda: ios=0/519754, merge=0/3997, ticks=0/897931, in_queue=898067, util=96.85%
root@v2202412245792303242:~# fio -filename=test_io_file -direct=1 -iodepth=64 -thread -rw=randread -ioengine=libaio -bs=4k -size=2G -numjobs=1 -runtime=60 -group_reporting -name=mytest
mytest: (g=0): rw=randread, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=64
fio-3.25
Starting 1 thread
Jobs: 1 (f=1): [r(1)][100.0%][r=391MiB/s][r=100k IOPS][eta 00m:00s]
mytest: (groupid=0, jobs=1): err= 0: pid=849567: Sat Dec 13 20:59:57 2025
read: IOPS=102k, BW=397MiB/s (416MB/s)(2048MiB/5161msec)
slat (usec): min=3, max=512, avg= 3.92, stdev= 2.61
clat (usec): min=111, max=4026, avg=625.63, stdev=171.37
lat (usec): min=115, max=4029, avg=629.63, stdev=171.46
clat percentiles (usec):
| 1.00th=[ 277], 5.00th=[ 367], 10.00th=[ 424], 20.00th=[ 494],
| 30.00th=[ 537], 40.00th=[ 578], 50.00th=[ 611], 60.00th=[ 652],
| 70.00th=[ 701], 80.00th=[ 758], 90.00th=[ 840], 95.00th=[ 914],
| 99.00th=[ 1074], 99.50th=[ 1156], 99.90th=[ 1467], 99.95th=[ 1680],
| 99.99th=[ 3294]
bw ( KiB/s): min=400096, max=436224, per=99.90%, avg=405937.60, stdev=12199.78, samples=10
iops : min=100024, max=109056, avg=101484.40, stdev=3049.95, samples=10
lat (usec) : 250=0.41%, 500=21.09%, 750=57.57%, 1000=18.99%
lat (msec) : 2=1.92%, 4=0.03%, 10=0.01%
cpu : usr=8.82%, sys=49.59%, ctx=18638, majf=0, minf=65
IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=0.1%, >=64=100.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.1%, >=64=0.0%
issued rwts: total=524288,0,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=64
Run status group 0 (all jobs):
READ: bw=397MiB/s (416MB/s), 397MiB/s-397MiB/s (416MB/s-416MB/s), io=2048MiB (2147MB), run=5161-5161msec
Disk stats (read/write):
vda: ios=522501/2665, merge=0/16, ticks=288986/1911, in_queue=290900, util=98.25%













