MySQL 8.0.12 壓力測試工具benchyou 使用
阿新 • • 發佈:2018-12-10
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編寫的,具有進步意義。