sysbench–实践–01–文件IO测试
1、介绍
- 磁盘IO性能测试
- 主要性能指标:请求数(request)和总体的吞吐量(total)。
2、参数说明
sysbench --test=fileio help
2.1、–file-num=N
- 创建文件的数量
- 默认值:128。
2.2、–file-block-size=N
- 每次IO操作的block大小
- 默认值:16K。
2.3、–file-total-size=SIZE
- 所有文件大小总和
- 默认值:2G。
2.4、–file-test-mode=STRING
测试模式:
1. seqwr(顺序写)
2. seqrewr(顺序读写)
3. seqrd(顺序读)
4. rndrd(随机读)
5. rndwr(随机写)
6. rndrw(随机读写)。
2.5、–file-io-mode
- 文件操作模式:
- sync(同步)
- async(异步)
- mmap(快速map映射)
- 默认值:sync。
2.6、–file-async-backlog
number of asynchronous operatons to queue per thread [128]。
2.7、–file-extra-flags=STRING
使用额外的标志符来打开文件{sync,dsync,direct}。
2.8、–file-fsync-freq=N
- 在完成N次请求之后,执行fsync()
- 0表示不使用fsync
- 默认值:100。
2.9、–file-fsync-all=[on|off]
- 每次写操作后执行fsync()
- 默认值:off。
2.10、–file-fsync-end=[on|off]
- 测试结束后执行fsync()
- 默认值:on。
2.11、–file-fsync-mode=STRING
- 使用fsync或fdatasync方法进行同步
- 默认值:fsync。
2.12、–file-merged-requests=N
- 尽可能的合并N个IO请求数
- 0表示不合并
- 默认值:0。
2.13、–file-rw-ratio=N
- 测试时候的读写比例
- 默认值:1.5(即3:2)。
3、操作
3.1、IO测试,线程数为4,创建大小为1G的测试文件,使用了随机读写模式
命令
# 准备阶段:IO测试,线程数为4,创建大小为1G的测试文件,使用了随机读写模式(rndrw),执行完后会在当前目录下生成一堆小文件。
sysbench fileio --threads=4 --file-total-size=1G --file-test-mode=rndrw prepare
# 运行阶段:IO测试,线程数为4,创建大小为1G的测试文件,使用了随机读/写(rndrw)
sysbench fileio --threads=4 --file-total-size=1G --file-test-mode=rndrw run
结果
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 4
Initializing random number generator from current time
Extra file open flags: (none)
128 files, 8MiB each
1GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...
Threads started!
File operations:
reads/s: 10485.52
writes/s: 6990.35
fsyncs/s: 22414.18
Throughput:
read, MiB/s: 163.84 # 表示读的带宽
written, MiB/s: 109.22 # 表示写的带宽
General statistics:
total time: 10.0050s
total number of events: 398711
Latency (ms):
min: 0.00
avg: 0.10
max: 18.66
95th percentile: 0.62
sum: 39603.46
Threads fairness:
events (avg/stddev): 99677.7500/2639.39
execution time (avg/stddev): 9.9009/0.00