sysbench 初探
Last updated: Oct 219, 21029
概况
sysbench 可以执行多种类型的基准测试
- 可以测试数据库的性能
- 测试运行数据库的服务器的性能
使用
版本
- sysbench:1.0.17(通过
sysbench -v
获取) - OS:CentOS 7.2.1511(通过
lsb_release -a
获取)
CPU 基准测试
执行:
sysbench --test=cpu --cpu-max-prime=20000 run
结果:
CPU speed:
events per second: 356.63
General statistics:
total time: 10.0026s
total number of events: 3568
Latency (ms):
min: 2.78
avg: 2.80
max: 2.94
95th percentile: 2.81
sum: 10000.08
Threads fairness:
events (avg/stddev): 3568.0000/0.00
execution time (avg/stddev): 10.0001/0.00
OLTP 基准测试
执行如下语句,生成一张 1000000 行的表:
sysbench oltp_read_write --table-size=1000000 --db-driver=mysql --mysql-db=test --mysql-user=root --mysql-password=${your password} prepare
执行下面语句进行测试:
sysbench oltp_read_write --table-size=1000000 --db-driver=mysql --mysql-db=test --mysql-user=root --mysql-password=${your_password} --time=60 --max-requests=0 --threads=8 run
结果:
SQL statistics:
queries performed:
read: 430052
write: 122872
other: 61436
total: 614360
transactions: 30718 (511.84 per sec.)
queries: 614360 (10236.88 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 60.0127s
total number of events: 30718
Latency (ms):
min: 5.37
avg: 15.63
max: 95.12
95th percentile: 22.69
sum: 479993.25
Threads fairness:
events (avg/stddev): 3839.7500⁄23.09
execution time (avg/stddev): 59.9992⁄0.00
从结果中可以看到:
总的事务数是:30718
每秒事务数是:511.84
响应时间:最长 95.12 ms,最短 5.37 ms,平均 15.63 ms