关于数据库:sysbench数据库压测工具详解与实战

11次阅读

共计 15887 个字符,预计需要花费 40 分钟才能阅读完成。


sysbench 是一个基于 LuaJIT 脚本的多线程基准测试工具。2004 年由 Peter Zaitsev(Percona 公司创始人)开发,在其 0.5 版本中能够应用 Lua 脚本实现 OLTP 测试。2016 年重构了 sysbench 代码,并在 2017 年 2 月针对新的硬件环境公布了 1.0 版本,优化了测试性能(是 0.5 版本的 6 倍,能够压测 60 万 TPS)和可扩展性(无 Mutex、无共享计数器、多线程扩展性更强)。

sysbench 不仅可用于数据库基准测试,也可用于服务器的其余工作负载基准测试。本文次要以 1.0 版本为例介绍 sysbench。在新的 Release 版本下,sysbench 新增与优化了如下一些个性。

能够收集无关速率和延迟时间的统计数据,包含提早百分比和直方图。
低开销,能够执行数以千计的并发线程,可能每秒产生和跟踪数亿个事件。
通过 Lua 脚本轻松实现了预约义的钩子,以创立新的测试基准。
能够用作通用的 Lua 脚本解释器,只需在 Lua 脚本中将“#!/usr/bin/lua”替换为“#!/usr/bin/sysbench”即可。

1 装置 sysbench

1.1 yum 装置

执行如下命令,设置 yum repo 仓库 /etc/yum.repos.d/akopytov_sysbench.repo,并间接应用 yum 装置。

RHEL/CentOS

[root@localhost~]# curl -s https://packagecloud.io/insta… sysbench/script.rpm.sh | sudo bash

[root@localhost~]# sudo yum -y install sysbench

1.2 RPM 包装置

手动下载 RPM 包来装置(仅限 RHEL/CentOS),然而在装置 sysbench 前须要先装置依赖包,而后再装置该 RPM 包。

[root@localhost~]# yum install mysql-libs postgresql-libs -y

[root@localhost~]# rpm -Uvh sysbench-1.0.7-13.el6.x86_64.rpm –nodeps

因为 sysbench 编译时依赖 libmysqlclient 动态链接库,所以要抉择对应版本的 sysbench,或者应用软链接:

[root@localhost~]# ln -s /usr/lib64/mysql/libmysqlclient.so.18 /usr/lib64/ libmysqlclient_r.\ so.16

1.3 编译装置

装置依赖的编译环境:

RHEL/CentOS

[root@localhost~]# yum -y install make automake libtool pkgconfig libaio-devel vim-\
common git

For MySQL support, replace with mysql-devel on RHEL/CentOS 5

[root@localhost~]# yum -y install mariadb-devel

For PostgreSQL support

[root@localhost~]# yum -y install postgresql-devel

最新的 sysbench 程序包地址为 https://github.com/akopytov/s…,间接下载并解压缩程序包:

[root@localhost~]# wget

 https://github.com/akopytov/s…

[root@localhost~]# tar zxf sysbench-1.0.13.tar.gz

编译装置:

[root@localhost~]# cd sysbbench-1.0.13

[root@localhost~]# ./autogen.sh

Add –with-pgsql to build with PostgreSQL support

[root@localhost~]# ./configure

[root@localhost~]# make

[root@localhost~]# make install

1.4 验证装置是否胜利

查看版本信息,如果能够失常查看到版本信息而不报错,则阐明 sysbench 装置胜利。

[root@localhost~]# sysbench –version  

2 测试案例

本节通过几个测试案例简略介绍如何应用 sysbench 对 MySQL 数据库进行压力测试。

sysbench 除能压测数据库性能之外,还能对其余一些测试对象进行性能测试,包含 CPU、内存、线程等的压测,限于篇幅,这里不具体介绍,读者能够参考链接:Sysbench – Gentoo Wiki 来进一步理解。

在测试前,请先创立好 MySQL 账户 qbench@127.0.0.1(明码为 qbench),确保该账户能够失常连贯到数据库,并且领有 sbtest 库的所有权限。上面就利用 4 个并发线程,对一个 MySQL 实例上的 32 个 500 万行数据的表(sbtest1, sbtest2, … ,sbtest32)进行 180s 的压力测试,以查看 MySQL 数据库在压力下的体现。

2.1 造数

能够间接应用 Lua 脚本前缀作为 testname,应用 prepare 命令造数。

[root@localhost~]# sysbench –db-driver=mysql –time=180 –threads=4 –report-interval=1\ –mysql-host =127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qbench\ –mysql-db= sbtest –tables=32 –table-size=5000000 oltp_read_write –db-ps-mode=disable\ prepare

2.2 数据库读写测试

1.oltp_read_write

该测试案例对应 sysbench 0.5 版本的 oltp.lua 脚本,用于测试数据库的 TPS 性能。

[root@localhost~]# sysbench –db-driver=mysql –time=180 –threads=4 –report-interval=1 –mysql-host =127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qbench –mysql -db =sbtest –tables=32 –table-size=5000000 oltp_read_write –db-ps-mode=disable run

2.oltp_read_only

该测试案例对应 sysbench 0.5 版本的 select.lua 脚本,用于测试数据库的只读性能。

[root@localhost~]# sysbench –db-driver=mysql –time=180 –threads=4 –report-interval=1 –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qbench –mysql-db=sbtest –tables=32 –table-size=5000000 oltp_read_only –db-ps-mode=disable run

3.oltp_delete

该测试案例对应 sysbench 0.5 版本的 delete.lua 脚本,用于测试数据库的删除性能。

[root@localhost~]# sysbench –db-driver=mysql –time=180 –threads=4 –report-interval=1 –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qbench –mysql-db=sbtest –tables=32 –table-size=5000000 oltp_delete –db-ps-mode=disable run

4.oltp_update_index

该测试案例对应 sysbench 0.5 版本的 update_index.lua 脚本,用于测试数据库的更新索引性能。

[root@localhost~]# sysbench –db-driver=mysql –time=180 –threads=4 –report-interval=1 –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qbench –mysql-db=sbtest –tables=32 –table-size=5000000 oltp_update_index –db-ps-mode=disable run

5.oltp_update_non_index

该测试案例对应 sysbench 0.5 版本的 update_non_index.lua 脚本,用于测试数据库的更新非索引字段性能。

[root@localhost~]# sysbench –db-driver=mysql –time=180 –threads=4 –report-interval=1 –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qbench –mysql-db=sbtest –tables=32 –table-size=5000000 oltp_update_non_index –db-ps-mode=disable run

6.oltp_insert

该测试案例对应 sysbench 0.5 版本的 insert.lua 脚本,用于测试数据库的插入性能。

[root@localhost~]# sysbench –db-driver=mysql –time=180 –threads=4 –report-interval=1 –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qbench –mysql-db=sbtest –tables=32 –table-size=5000000 oltp_insert –db-ps-mode=disable run

7.oltp_write_only

该测试案例是 sysbench 1.0.x 版本新增的,与原来的 oltp.lua 相比,少了 select 局部。

[root@localhost~]# sysbench –db-driver=mysql –time=180 –threads=4 –report-interval=1 –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qbench –mysql-db=sbtest –tables=32 –table-size=5000000 oltp_write_only –db-ps-mode=disable run

2.3 清理

应用 cleanup 命令清理 prepare 和 run 产生的数据,实际上是删除对应的表。

[root@localhost~]# sysbench –db-driver=mysql –time=180 –threads=4 –report-interval=1 –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qbench –mysql-db=sbtest –tables=32 –table-size=5000000 oltp_read_write –db-ps-mode=disable cleanup

3 sysbench 参数详解

3.1 sysbench 命令语法

sysbench 命令语法如下:

sysbench [options]… [testname] [command]

options(参数选项):用于指定 sysbench 的并发度、压测时长等参数。
testname(测试名称):用于指定 sysbench 的基准测试名称,可选项包含 oltp_read_ write、oltp_read_only、oltp_write_only、oltp_insert、oltp_delete、oltp_update_index、oltp_update_non_index 等
command(测试命令):用于指定 sysbench 执行什么测试命令,可选项包含 prepare、run、cleanup 等。

3.2 options

上面逐个介绍相干选项。

1.惯例选项
–threads=N:指定线程数,默认值为 1,相当于 sysbendh 0.5 及之前版本中的 –num-threads= N 选项。
–events=N:指定总的申请数,默认值为 0,示意不限度申请数,相当于 sysbench 0.5 及之前版本中的 –max-requests 选项。
–time=N:指定压测时长,默认值为 10s,相当于 sysbench 0.5 及之前版本中的 –max-time= N 选项。
–forced-shutdown=STRING:有效值为 off、N、N%(默认值为 off)。off 示意不启用强制关机性能;N 示意在 –time 选项指定的工夫到期后,再过 N 秒强制关机;N% 示意在 –time 选项指定的工夫到期后,再过 –time*N% 工夫强制关机。
–thread-stack-size=SIZE:指定每个线程的堆栈大小,默认值为 64KB。
–rate=N:限定事务速率(tps),默认值为 0,示意不限度,相当于 sysbench 0.5 及之前版本中的 –tx-rate= N 选项。
–report-interval=N:指定两头统计后果报告的间隔时间,默认值为 0,示意敞开两头统计后果报告输入。
–report-checkpoints=[LIST,…]:用逗号分隔的一组列表值,这些值在执行 sysbench 压测时被顺次读取,示意执行多少秒就打印一次统计报告(例如 –report- checkpoints=10,20,30,示意当执行 10s、20s、30s 时别离打印一次统计报告。留神,该数值是指从执行 sysbench 开始到当初的工夫),默认值为空,示意在 –time 选项指定的工夫到期后才打印统计报告。
–debug[=on|off]:是否打印调试信息,默认值为 off。
–help[=on|off]:是否打印帮忙信息,默认值为 off。
–version[=on|off]:是否打印版本信息,默认值为 off。

2.伪随机数创立选项
–rand-type=STRING:随机数散布类型,可选项包含 uniform、gaussian、special、pareto,默认值为 special。
–rand-spec-iter=N:随机数生成的迭代次数,默认值为 12 次。
–rand-spec-pct=N:对特定随机数散布来说被视为“非凡”值的百分比,默认值为 1。
–rand-spec-res=N:对特定随机数散布来说“非凡”值的百分比,默认值为 75。
–rand-seed=N:随机数发生器的种子。当该选项设置为 0 时,示意应用以后工夫作为 RNG 种子。
–rand-pareto-h=N:用于指定 pareto 随机散布的 h 参数,默认值为 0.2。

3.日志选项
–verbosity=N:日志打印的具体水平,5 示意打印 debug 级别以上的日志,0 示意只打印 critical 级别以上的日志。默认值为 3。
–percentile=N:在延迟时间统计中抉择哪个百分位数,可选范畴为(1~100),默认值为 95。如果设置为 0,则示意禁用延迟时间统计性能。
–histogram[=on|off]:是否打印延迟时间直方图报告,默认值为 off。

4.惯例数据库选项
–db-driver=STRING:指定数据库驱动程序(即指定数据库类型),以后版本反对 MySQL 和 PostgreSQL。
–db-ps-mode=STRING:prepare 命令应用模式,有效值为 auto 和 disable,默认值为 auto,在高并发压力下倡议应用 disable。
–db-debug[=on|off]:是否打印数据库的调试信息,默认值为 off。

5.MySQL 选项
–mysql-host=MySQL 服务器主机,默认值为 localhost。
–mysql-port=MySQL 服务器端口号,默认值为 3306。
–mysql-socket= MySQL 服务器 Socket 文件目录。
–mysql-user= 连贯 MySQL 服务器的用户名,默认值为 sbtest。
–mysql-password= 连贯 MySQL 服务器的明码。
–mysql-db= 连贯 MySQL 服务器的数据库名,默认值为 sbtest。
–mysql-ssl[=on|off]:连贯 MySQL 服务器是否应用 SSL,默认值为 off。
–mysql-ssl-cipher= 连贯 MySQL 服务器应用 SSL 时的 Cipher。
–mysql-compression[=on|off]:连贯 MySQL 服务器是否应用压缩,默认值为 off。
–mysql-debug[=on|off]:连贯 MySQL 服务器是否跟踪所有的客户端库调用,默认值为 off。
–mysql-ignore-errors= 是否疏忽 MySQL 返回的谬误,默认值为[1213,1020,1205]。
–mysql-dry-run[=on|off]:是否空跑,只是调用 MySQL 客户端 API,然而不真正执行。

6.pgsql 选项
–pgsql-host= PostgreSQL 服务器主机,默认值为 localhost。
–pgsql-port= PostgreSQL 服务器端口,默认值为 5432。
–pgsql-user= 连贯 MySQL 服务器的用户名,默认值为 sbtest。
–pgsql-password= 连贯 MySQL 服务器的明码。
–pgsql-db= 连贯 MySQL 服务器的数据库名,默认值为 sbtest。

7.其余选项
通过应用如下命令来查看额定的对于测试名称(事务模型)命令选项,只须要任意指定一个测试名称即可。

指定 oltp_read_write 测试名称来查看额定的帮忙选项

[root@localhost]# sysbench oltp_read_write help  

……

oltp_read_write options:

  –distinct_ranges=N Number of SELECT DISTINCT queries per transaction [1]

  –sum_ranges=N Number of SELECT SUM() queries per transaction [1]

  –skip_trx[=on|off] Don’t start explicit transactions and execute all queries in the AUTOCOMMIT mode [off]

……

各选项解释如下。

–distinct_ranges=N:指定在每个事务中 SELECT DISTINCT 查问的执行次数,默认值为 1。
-sum_ranges=N:指定在每个事务中 SELECT SUM()查问的执行次数,默认值为 1。
–skip_trx[=on|off]:指定在 AUTOCOMMIT(主动提交)模式下是否须要跳过启动显式事务(应用 START 语句显式启动一个事务),默认值为 off。
–secondary[=on|off]:指定是否须要应用一个二级索引来代替主键索引,默认值为 off。
–create_secondary[=on|off]:指定除主键之外,是否还须要创立一个二级索引,默认值为 on。
–index_updates=N:指定在每个事务中应用索引执行 UPDATE 语句的次数,默认值为 1。
–range_size=N:指定在每个事务中范畴 SELECT 查问的条件值,默认值为 100。
–auto_inc[=on|off]:指定是否须要应用自增列的自增值作为主键值,如果不应用自增值,则应用 sysbench 主动生成的 ID 值作为主键值,默认值为 on。
–delete_inserts=N:指定在每个事务中 DELETE/INSERT 组合语句的数量,默认值为 1。
–tables=N:指定并行压测的表数量。
–mysql_storage_engine=STRING:指定表的存储引擎,默认值为 InnoDB。
–non_index_updates=N:指定在每个事务中不应用索引执行 UPDATE 语句的次数,默认值为 1。
–table_size=N:指定每个表的数据总量,默认值为 10 000。
–pgsql_variant=STRING:当用 PostgreSQL 驱动程序运行时应用此 PostgreSQL 变体。目前惟一反对的变体是“redshift”。启用后,将主动禁用 create_secondary,并将 –delete_inserts 选项设置为 0。
–simple_ranges=N:指定在每个事务中简略范畴 SELECT 查问(这里指的是 BETWEEN 范畴查问)的次数,默认值为 1。
–order_ranges=N:指定在每个事务中 SELECT ORDER BY 查问的次数,默认值为 1。
–range_selects[=on|off]:指定是否须要关上或敞开所有的范畴 SELECT 查问,默认值为 on。
–point_selects=N:指定在每个事务中单行 SELECT 查问的次数,默认值为 10。

每一种测试名称对应的 Lua 脚本中都定义了须要应用的 DML 测试语句类型,每一种 DML 语句类型都能够通过选项独自指定在每一个事务中须要执行多少次。例如,在 oltp_read_write 测试名称中,一共有 9 种 DML 语句类型,依照默认的每一种语句的执行次数计算,在每一个事务中一共有 18 条语句,每一种 DML 语句类型的默认执行次数如下:

  • 简略等值 SELECT 语句:默认为 10 次。
  • 范畴 SELECT(BETWEEN)语句:默认为 1 次。
  • SELECT SUM()语句:默认为 1 次。
  • SELECT ORDER BY:默认为 1 次。
  • SELECT DISTINCT 语句:默认为 1 次。
  • DELETE 和 INSERT 组合语句:默认为 1 次。
  • 应用索引的 UPDATE 语句:默认为 1 次。
  • 不应用索引的 UPDATE 语句:默认为 1 次。
    在执行 oltp_read_write 测试时,从 MySQL 的 general_log 中抓取的每个事务的语句数量也证实了,在默认的配置下一个事务中的语句数量为 18 条,如下图所示。

3.3 testname

testname 用于指定 sysbench 的基准测试名称。基准测试包含:

oltp _*.lua,数据库基准测试 Lua 脚本汇合。这是 DBA 日常常常须要用到的测试脚本。
fileio,文件系统级基准测试。
cpu,简略的 CPU 基准测试。
memory,内存拜访基准测试。
threads,基于线程的调度器基准测试。
mutex,POSIX 互斥基准测试。
提醒:在理论执行时,对于 Lua 新格局脚本,能够只写脚本名称(不写.lua 后缀),如 oltp_read_only,不再须要像 sysbench 0.5 及之前版本那样应用 –test 选项来指定。

1.sysbench Lua 脚本介绍
Sysbench 1.0.x 版本中的 Lua 脚本代码比 0.5.x 版本工整得多,并且对构造进行了从新设计,大部分 SQL 语句都被整合到了 oltp_common.lua 脚本中集中定义,其余 Lua 脚本只须要加载这个脚本进行调用即可。另外,还对原来的 delete.lua、select.lua、update*.lua、insert.lua 脚本中的 SQL 语句进行了改良,将其嵌套到 begin 和 commit 语句中。

通过 RPM 包装置的 sysbench 1.0.x 版本中的 Lua 脚本有两个目录,如下所示。

[root@localhost~]# ls -lh /usr/share/sysbench/ /usr/share/sysbench/tests/include/\ oltp_legacy

/usr/share/sysbench/:  #对于 sysbench 1.0.x 版本, 倡议应用这个目录下的最新的 Lua 脚本。不过该脚本应用 prepare 命令执行语句,须要创立大量的 prepare 命令对象,调整参数的值

total 64K

-rwxr-xr-x 1 root root 1.5K May 15 22:14 bulk_insert.lua

-rw-r–r– 1 root root  14K May 15 22:14 oltp_common.lua

-rwxr-xr-x 1 root root 1.1K May 15 22:14 oltp_delete.lua

-rwxr-xr-x 1 root root 2.0K May 15 22:14 oltp_insert.lua

-rwxr-xr-x 1 root root 1.3K May 15 22:14 oltp_point_select.lua

-rwxr-xr-x 1 root root 1.7K May 15 22:14 oltp_read_only.lua

-rwxr-xr-x 1 root root 1.8K May 15 22:14 oltp_read_write.lua

-rwxr-xr-x 1 root root 1.1K May 15 22:14 oltp_update_index.lua

-rwxr-xr-x 1 root root 1.2K May 15 22:14 oltp_update_non_index.lua

-rwxr-xr-x 1 root root 1.5K May 15 22:14 oltp_write_only.lua

-rwxr-xr-x 1 root root 1.9K May 15 22:14 select_random_points.lua

-rwxr-xr-x 1 root root 2.1K May 15 22:14 select_random_ranges.lua

drwxr-xr-x 4 root root 4.0K Jun 15 15:53 tests

/usr/share/sysbench/tests/include/oltp_legacy: # 对于 sysbench 1.0.x 版本,在这个目录下保留了一些兼容之前版本写法的 Lua 脚本

total 52K

-rw-r–r– 1 root root 1.2K May 15 22:14 bulk_insert.lua

-rw-r–r– 1 root root 4.6K May 15 22:14 common.lua

-rw-r–r– 1 root root  366 May 15 22:14 delete.lua

-rw-r–r– 1 root root 1.2K May 15 22:14 insert.lua

-rw-r–r– 1 root root 3.0K May 15 22:14 oltp.lua

-rw-r–r– 1 root root  368 May 15 22:14 oltp_simple.lua

-rw-r–r– 1 root root  527 May 15 22:14 parallel_prepare.lua

-rw-r–r– 1 root root  369 May 15 22:14 select.lua

-rw-r–r– 1 root root 1.5K May 15 22:14 select_random_points.lua

-rw-r–r– 1 root root 1.6K May 15 22:14 select_random_ranges.lua

-rw-r–r– 1 root root  369 May 15 22:14 update_index.lua

-rw-r–r– 1 root root  578 May 15 22:14 update_non_index.lua

对于 Lua 语法请参考:http://www.runoob.com/lua/lua…。

2.自定义 Lua 脚本

为了实现自定义测试,读者也能够自定义 Lua 脚本,应用 sysbench 进行测试。

上面是一个简略的示例。

function prepare()

    db_query(“CREATE TABLE t (a INT)”)

    db_query(“INSERT INTO t VALUES (1)”)

end

function event()

    db_query(“UPDATE t SET a = a + ” .. sb_rand(1, 1000))

end

function cleanup()

    db_query(“DROP TABLE t”)

end

应用 sysbench 测试如下:

calls prepare()

[root@localhost~]# sysbench –test=test.lua prepare

calls event() in a loop

[root@localhost~]# sysbench –test=test.lua –num-threads=16 –report-interval=1 run

[1s] threads: 16, tps: 0.00, reads: 0.00, writes: 13788.65, response time: 1.43ms (95%)

[2s] threads: 16, tps: 0.00, reads: 0.00, writes: 14067.56, response time: 1.40ms (95%)

$ sysbench –test=test.lua cleanup # calls cleanup()

3.4 command

command 将由 sysbench 传递给内置的 testname 或 testname 指定的 Lua 脚本。该命令指定 testname 须要执行的操作。

以下是典型的测试命令及其形容。

prepare:执行筹备工作。例如,在磁盘上创立必要的测试文件以进行 fileio 测试,或者在测试数据库上新建 100 万行数据以执行数据库基准测试。
run:应用 testname 参数指定的压测脚本执行对应的测试。
cleanup:在测试完结后删除长期数据或文件。
help:显示应用 testname 参数指定的压测脚本的相干帮忙信息,包含该压测脚本参数的残缺列表。例如 sysbench oltp_write_only help,能够查看 oltp_write_only 压测脚本反对的所有可选参数。

4 数据库测试输入信息详解

上面具体介绍应用 sysbench 测试 MySQL 数据库的输入后果。
[root@localhost~]# sysbench –db-driver=mysql –time=10 –threads=4 –report-interval=1\ –mysql-host=127.0.0.1 –mysql-port=3306 –mysql-user=qbench –mysql-password=qb

[14/480]

ysql-db=sbtest –tables=32 –table-size=50000 oltp_read_write –db-ps-mode=disable run

sysbench 1.0.7 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:

Number of threads: 4

Report intermediate results every 1 second(s)

Initializing random number generator from current time

Initializing worker threads…

Threads started!

[1s] thds: 4 tps: 374.23 qps: 7533.43 (r/w/o: 5280.08/977.98/1275.36) lat (ms,95%): 17.95 err/s: 0.00 reconn/s: 0.00

[2s] thds: 4 tps: 329.07 qps: 6604.49 (r/w/o: 4622.04/880.20/1102.25) lat (ms,95%): 21.11 err/s: 0.00 reconn/s: 0.00

[3s] thds: 4 tps: 362.00 qps: 7225.05 (r/w/o: 5054.04/943.01/1228.01) lat (ms,95%): 18.61 err/s: 0.00 reconn/s: 0.00

[4s] thds: 4 tps: 392.00 qps: 7847.05 (r/w/o: 5494.04/1069.01/1284.01) lat (ms,95%): 17.63 err/s: 0.00 reconn/s: 0.00

[5s] thds: 4 tps: 331.01 qps: 6602.18 (r/w/o: 4625.12/894.02/1083.03) lat (ms,95%): 20.37 err/s: 0.00 reconn/s: 0.00

[6s] thds: 4 tps: 334.99 qps: 6712.77 (r/w/o: 4698.84/929.97/1083.96) lat (ms,95%): 19.65 err/s: 0.00 reconn/s: 0.00

[7s] thds: 4 tps: 356.97 qps: 7149.40 (r/w/o: 5002.58/985.92/1160.90) lat (ms,95%): 19.29 err/s: 0.00 reconn/s: 0.00

[8s] thds: 4 tps: 333.01 qps: 6657.20 (r/w/o: 4663.14/926.03/1068.03) lat (ms,95%): 20.37 err/s: 0.00 reconn/s: 0.00

[9s] thds: 4 tps: 347.03 qps: 6950.59 (r/w/o: 4860.41/972.08/1118.09) lat (ms,95%): 20.37 err/s: 0.00 reconn/s: 0.00

[10s] thds: 4 tps: 342.97 qps: 6821.44 (r/w/o: 4773.61/932.92/1114.91) lat (ms,95%): 19.29 err/s: 0.00 reconn/s: 0.00

SQL statistics:

    queries performed:

        read: 49084

        write: 9513

        other: 11523

        total: 70120

    transactions: 3506 (350.33 per sec.)

    queries: 70120 (7006.63 per sec.)

    ignored errors: 0 (0.00 per sec.)

    reconnects: 0 (0.00 per sec.)

General statistics:

    total time: 10.0062s

    total number of events: 3506

Latency (ms):

         min: 4.56

         avg: 11.41

         max: 39.24

         95th percentile: 19.65

         sum: 39997.58

Threads fairness:

    events (avg/stddev): 876.5000/5.22

    execution time (avg/stddev): 9.9994/0.00

4.1 输入后果概述

Sysbench 测试输入后果次要分为三局部:
版本及要害测试参数输入。
两头统计后果输入。
整体统计后果输入。

4.2 版本及要害测试参数输入

在 sysbench 测试失常开始当前,首先输入的是 sysbench 的版本、压测线程个数、每隔几秒输入一次两头后果、随机数初始化等相干信息。

4.3 两头统计后果输入

在指定了 –report-interval 参数当前,每隔 report-interval 工夫输入一次两头统计后果,如下所示。

[6s] thds: 4 tps: 334.99 qps: 6712.77 (r/w/o: 4698.84/929.97/1083.96) lat (ms,95%): 19.65 err/s: 0.00 reconn/s: 0.00

[6s]:示意以后曾经压测 6s。
thds: 4:示意 4 个线程并发压测。
tps: 334.99:示意在 report-interval 工夫距离内的每秒事务数。
qps: 6712.77:示意在 report-interval 工夫距离内的每秒查问数。
(r/w/o: 4698.84/929.97/1083.96):示意在 report-interval 工夫距离内的每秒读 / 写 / 其余申请数,用于补充阐明 qps。
lat (ms,95%):19.65:示意在 report-interval 工夫距离内的申请 95% 的延迟时间在 19.65ms 以下。
err/s: 0.00:示意在 report-interval 工夫距离内的每秒失败申请数。
reconn/s: 0.00:示意在 report-interval 工夫距离内的每秒重连接数。

4.4 整体统计后果输入

在 sysbench 全副测试实现当前,将输入整体压测的统计后果。次要分为四局部:
(1)SQL 统计后果
该项输入后果包含 sysbench 发动的读 / 写 / 其余 / 总计 SQL 查问数量、总计事务数及每秒事务数、总计申请数及每秒申请数、总计谬误数及每秒谬误数、总计重连接数及每秒重连接数。

SQL statistics:

    queries performed:

        read: 49084

        write: 9513

        other: 11523

        total: 70120

    transactions: 3506 (350.33 per sec.)

    queries: 70120 (7006.63 per sec.)

    ignored errors: 0 (0.00 per sec.)

    reconnects: 0 (0.00 per sec.)

(2)通用统计值

该项输入后果包含总计执行的工夫、所有的事件数量(这里对应的是发动的 MySQL 事务数)。

General statistics:

    total time: 10.0062s

    total number of events: 3506

(3)延迟时间统计后果

该项输入后果包含延迟时间最低值、平均值、最高值、第 95% 位值、总计值。

Latency (ms):

         min: 4.56

         avg: 11.41

         max: 39.24

         95th percentile: 19.65

         sum: 39997.58

(4)压测线程统计后果

该项输入后果包含每个压测线程的均匀事件数及标准差、每个事务的均匀执行工夫及标准差。

Threads fairness:

    events (avg/stddev): 876.5000/5.22

    execution time (avg/stddev): 9.9994/0.00

正文完
 0