MySQL 8.0.12 压力测试工具benchyou 使用

版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/vkingnew/article/details/82780318
1.概述
由go语言编写的类似于sysbench的压测工具,目前仅支持mysql。
支持实时查看TPS,此外还通过SSH通道可以使用监控命令vmstat/iostat。

2.安装:
#yum -y install golang
#cd /usr/local
#git clone https://github.com/xelabs/benchyou.git
#cd benchyou
#make
--> go get...
go get github.com/xelabs/go-mysqlstack/driver
--> Building...
go build -v -o bin/benchyou src/bench/benchyou.go
xcommon
vendor/golang.org/x/crypto/curve25519
vendor/golang.org/x/crypto/ed25519/internal/edwards25519
vendor/github.com/spf13/pflag
xworker
sysbench
vendor/golang.org/x/crypto/ed25519
vendor/golang.org/x/crypto/ssh
vendor/github.com/spf13/cobra
xstat
xcmd
command-line-arguments

#cd bin

3.benchyou 的帮助信息:
# /usr/local/benchyou/bin/benchyou --help
Usage:
  benchyou [command]

Available Commands:
  prepare     
  cleanup     
  random      
  seq         
  range       

Flags:
      --batch-per-commit int        #rows per transaction(Default 1) (default 1)
      --delete-threads int          number of delete threads to use(Default 0)
      --max-request uint            limit for total requests, including write and read(Default 0, means no limits)
      --max-time int                limit for total execution time in seconds(Default 3600) (default 3600)
      --mysql-db string             MySQL database name(Default sbtest) (default "sbtest")
      --mysql-enable-xa int         enable MySQL xa transaction for insertion {0|1} (Default 0)
      --mysql-host string           MySQL server host(Default NULL)
      --mysql-password string       MySQL password(Default benchyou) (default "benchyou")
      --mysql-port int              MySQL server port(Default 3306) (default 3306)
      --mysql-range-order string    range query sort the result-set in {ASC|DESC} (Default ASC) (default "ASC")
      --mysql-table-engine string   storage engine to use for the test table {tokudb,innodb,...}(Default tokudb) (default "innodb")
      --mysql-user string           MySQL user(Default benchyou) (default "benchyou")
      --oltp-tables-count int       number of tables to create(Default 8) (default 8)
      --read-threads int            number of read threads to use(Default 32) (default 32)
      --rows-per-insert int         #rows per insert(Default 1) (default 1)
      --ssh-host string             SSH server host(Default NULL, same as mysql-host)
      --ssh-password string         SSH server password(Default benchyou) (default "benchyou")
      --ssh-port int                SSH server port(Default 22) (default 22)
      --ssh-user string             SSH server user(Default benchyou) (default "benchyou")
      --update-threads int          number of update threads to use(Default 0)
      --write-threads int           number of write threads to use(Default 32) (default 32)


4.压力测试准备和结束的操作:
--prepare:
/usr/local/benchyou/bin/benchyou --mysql-db=bench --mysql-host=10.19.189.221 --mysql-user=backup --mysql-password=backup --mysql-port=3308  --oltp-tables-count=32 prepare 
--cleanup:
/usr/local/benchyou/bin/benchyou --mysql-db=bench --mysql-host=10.19.189.221 --mysql-user=backup --mysql-password=backup --mysql-port=3308  --oltp-tables-count=32 cleanup

--压力测试的种类:
random insert(Write/Read Ratio=128:8):
/usr/local/benchyou/bin/benchyou --mysql-db=bench --mysql-host=10.19.189.221 --mysql-user=backup --mysql-password=backup --mysql-port=3308  --oltp-tables-count=32 --ssh-user=benchyou --ssh-password=benchyou   --write-threads=128 --read-threads=8 --max-time=3600 random

注释:以下压测语句的共同部分如下:
/usr/local/benchyou/bin/benchyou --mysql-db=bench --mysql-host=10.19.189.221 --mysql-user=backup --mysql-password=backup --mysql-port=3308  --oltp-tables-count=32 --ssh-user=benchyou --ssh-password=benchyou
下列压测语句只提供不同的部分:
sequential insert(Write/Read Ratio=128:8):
--write-threads=128 --read-threads=8 --max-time=3600 seq
mix(Write/Read/Update/Delete Ratio=4:4:4:4):
--write-threads=4 --read-threads=4 --update-threads=4 --delete-threads=4 --max-time=3600 random

insert multiple rows(10 rows per insert):
--write-threads=4 --rows-per-insert=10 --max-time=3600 random

batch update(10 rows per transaction):
--update-threads=4 --batch-per-commit=10 --max-time=3600 random

query-range(Write/Read Ratio=128:8):
--write-threads=128 --read-threads=8 --max-time=3600 --mysql-range-order=DESC range

5.压测结果解读:
time:         benchmark uptime  压测时间总长
thds:         read threads and write(insert/update/delete) threads 读写线程数
tps:          transaction per second, including write and read 每秒事务数包括读和写
wtps:         write tps 写的TPS
rtps:         read tps   读的TPS
rio:          read io numbers per second 每秒读的IO数。
rio/op:       rio per operation 
wio:          write io numbers per second 每秒写的IO数。
wio/op:       wio per operation
rMB:          amount data read from the device(megabytes) per second 没秒大约写的MB
rKB/op:       rKB per operation
wMB:          amount data written to the device(megabytes) per second
wKB/op:       wKB per operation
cpu/op:       CPU usecs per operation, measured by vmstat
freeMB:       the amount of idle memory(megabytes)
cacheMB:      the amount of memory(megabytes) used as cache
w-rsp:        the response time of one write operation,  in millisecond
r-rsp:        the response time of one read  operation,  in millisecond
total-number: the total number events

示例:
...
time            thds               tps     wtps    rtps    rio    rio/op   wio    wio/op    rMB     rKB/op    wMB     wKB/op   cpu/op  freeMB  cacheMB   w-rsp(ms)  r-rsp(ms)    total-number
[61s]        [r:8,w:128,u:0,d:0]  56036    16824   39212   0      0.00     0      0.00      0.00    0.00      0.00    0.00     0.00    0       0         2.20       0.12         3040434

----------------------------------------------------------------------------------------------avg---------------------------------------------------------------------------------------------
time          tps     wtps    rtps    rio    rio/op   wio    wio/op    rMB     rKB/op    wMB     wKB/op   cpu/op            w-rsp(ms)                      r-rsp(ms)              total-number
[61s]        50106    15455   34651   0      0.00     0      0.00      0.00    0.00      0.00    0.00     0.00    [avg:0.04,min:0.00,max:20.25]  [avg:0.00,min:0.00,max:24.53]      3056518



总结:
相对来说压测的项目比较少,目前的版本类似于sysbench的0.5版本的参数。
压测的数据仅供参考,在生产的压测的还是使用sysbench比较好,不过由于此工具是golang编写的,具有进步意义。



猜你喜欢

转载自blog.csdn.net/vkingnew/article/details/82780318