目录 ==>
github https://github.com/akopytov/sysbench
sysbench是一个基于LuaJIT的可编写脚本的多线程基准测试工具。它最常用语数据库基准测试,但也可以用语创建其他任意复杂的负载测试。
sysbench自带支持了如下的基准测试选项
oltp_*.lua
:一组类似OLTP的数据库基准测试fileio
:文件系统基准测试cpu
:一个简单的CPU基准测试memory
:内存访问基准threads
:基于线程的调度程序基准mutex
:POSIX互斥量基准万事开头难,本文仅做抛砖引玉只用,不做深入,只一个简单demo引入。
测试基于我的测试环境,测试结果不具有参考意义,重点在于梳理流程。
其github中的安装方式
Installing from Binary Packages(我通过此方式安装,Debian10)
Building and Installing From Source
请善于运用它的help
See 'sysbench <testname> help' for a list of options for each test.
# such as
sysbench cpu help
# sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
# cpu options:
# --cpu-max-prime=N upper limit for primes generator [10000]
使用方式
sysbench [要测试的类型,可以是cpu、memory...也可以是数据库的测试脚本] [一堆参数,--threads=88] [prepare|run|cleanup]
# prepare,诸如fileio之类的测试,需要的准备工作时创建文件。数据库测试需要先创建表写入数据
# cleanup,清理测试数据,如文件、数据库表
(base) darcyzhang@debian:~/work_data$ sysbench cpu help
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
cpu options:
--cpu-max-prime=N upper limit for primes generator [10000],primes生成器的上次 [10000]
sysbench cpu --cpu-max-prime=10000 run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 10000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 994.03 # 单个事件平均执行时间
General statistics:
total time: 10.0008s # 总执行时间
total number of events: 9943 # 总共执行了9943个事件
Latency (ms): # 延迟时间
min: 0.94
avg: 1.01
max: 3.59
95th percentile: 1.01
sum: 9995.40
Threads fairness:
events (avg/stddev): 9943.0000/0.00
execution time (avg/stddev): 9.9954/0.00
(base) darcyzhang@debian:~/work_data$ sysbench memory help
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
memory options:
--memory-block-size=SIZE size of memory block for test [1K],内存块大小
--memory-total-size=SIZE total size of data to transfer [100G],测试总数据大小
--memory-scope=STRING memory access scope {global,local} [global],操作内存范围
--memory-hugetlb[=on|off] allocate memory from HugeTLB pool [off]
--memory-oper=STRING type of memory operations {read, write, none} [write],内存操作类型
--memory-access-mode=STRING memory access mode {seq,rnd} [seq],操作内存模式
(base) darcyzhang@debian:~/work_data$ sysbench memory --memory-total-size=100G run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Running memory speed test with the following options:
block size: 1KiB
total size: 102400MiB
operation: write
scope: global
Initializing worker threads...
Threads started!
Total operations: 44938156 (4492899.47 per second) # 总操作
43884.92 MiB transferred (4387.60 MiB/sec) # 传输总数据
General statistics:
total time: 10.0002s # 总时间
total number of events: 44938156 # 执行事件总数
Latency (ms):
min: 0.00
avg: 0.00
max: 0.15
95th percentile: 0.00
sum: 4333.66
Threads fairness:
events (avg/stddev): 44938156.0000/0.00
execution time (avg/stddev): 4.3337/0.00
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
fileio options:
--file-num=N number of files to create [128],创建文件数
--file-block-size=N block size to use in all IO operations [16384],IO文件大小
--file-total-size=SIZE total size of files to create [2G],文件总大小
--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw},文件读写模式
--file-io-mode=STRING file operations mode {sync,async,mmap} [sync],文件操作模式
--file-async-backlog=N number of asynchronous operatons to queue per thread [128],每个线程队列中的异步操作数
--file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
--file-fsync-all[=on|off] do fsync() after each write operation [off]
--file-fsync-end[=on|off] do fsync() at the end of test [on]
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
--file-rw-ratio=N reads/writes ratio for combined test [1.5]
# --file-test-mode是必须参数,需要先prepare创建文件
(base) darcyzhang@debian:~/work_data$ sysbench fileio --file-test-mode=rndwr prepare # 这里是随机写
# 测试完记得清理创建的文件
# (base) darcyzhang@debian:~/work_data$ sysbench fileio --file-test-mode=rndwr run
(base) darcyzhang@debian:~/work_data$ sysbench fileio --file-test-mode=rndwr run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Extra file open flags: (none)
128 files, 16MiB each
2GiB 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 write test
Initializing worker threads...
Threads started!
File operations:
reads/s: 0.00
writes/s: 5995.76
fsyncs/s: 7686.47
Throughput:
read, MiB/s: 0.00
written, MiB/s: 93.68
General statistics:
total time: 10.0017s
total number of events: 136791
Latency (ms):
min: 0.00
avg: 0.07
max: 27.58
95th percentile: 0.22
sum: 9862.76
Threads fairness:
events (avg/stddev): 136791.0000/0.00
execution time (avg/stddev): 9.8628/0.00
sysbench安装成功后,会写入一些数据库的测试脚本到机器上
(base) darcyzhang@debian:~$ find /usr/share -name "*.lua" | grep sysbench
/usr/share/sysbench/oltp_update_index.lua
/usr/share/sysbench/tests/include/inspect.lua
/usr/share/sysbench/tests/include/oltp_legacy/delete.lua
/usr/share/sysbench/tests/include/oltp_legacy/parallel_prepare.lua
/usr/share/sysbench/tests/include/oltp_legacy/common.lua
/usr/share/sysbench/tests/include/oltp_legacy/insert.lua
/usr/share/sysbench/tests/include/oltp_legacy/oltp_simple.lua
/usr/share/sysbench/tests/include/oltp_legacy/select_random_ranges.lua
/usr/share/sysbench/tests/include/oltp_legacy/bulk_insert.lua
/usr/share/sysbench/tests/include/oltp_legacy/update_index.lua
/usr/share/sysbench/tests/include/oltp_legacy/update_non_index.lua
/usr/share/sysbench/tests/include/oltp_legacy/select.lua
/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua
/usr/share/sysbench/tests/include/oltp_legacy/select_random_points.lua
/usr/share/sysbench/oltp_point_select.lua
/usr/share/sysbench/oltp_read_write.lua
/usr/share/sysbench/select_random_ranges.lua
/usr/share/sysbench/bulk_insert.lua
/usr/share/sysbench/oltp_insert.lua
/usr/share/sysbench/oltp_common.lua
/usr/share/sysbench/oltp_delete.lua
/usr/share/sysbench/oltp_read_only.lua
/usr/share/sysbench/oltp_update_non_index.lua
/usr/share/sysbench/oltp_write_only.lua
/usr/share/sysbench/select_random_points.lua
这些脚本可以模拟数据库的某些操作场景,insert
插入数据实验,oltp
为oltp场景实验。
我的简单理解OLTP(on-line transaction processing,联机事务处理)就是数据库在日常使用场景中的操作,如一个订单事务产生的增删改查操作。关联的还有一个OLAP(On-Line Analytical Processing,联机分析处理)操作,个人简单理解就是大批量导出数据库数据进行数据分析的场景。
使用上面的脚本实现测试
我在 Locust压力测试 这篇中创建了一个数据库,现在就用这个数据库来做测试demo,使用/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua
的脚本。
可以看一下这只脚本,是一只lua脚本,咱不是太懂,但应该能看到它的大致操作(我在其中注释了我的理解)。通过传入指定参数,控制一个event中执行各种操作的数量。
(base) darcyzhang@debian:~$ cat /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua
pathtest = string.match(test, "(.*/)")
if pathtest then
dofile(pathtest .. "common.lua") -- do了common.lua
else
require("common")
end
function thread_init()
set_vars()
if (((db_driver == "mysql") or (db_driver == "attachsql")) and mysql_table_engine == "myisam") then
local i
local tables = {}
for i=1, oltp_tables_count do
tables[i] = string.format("sbtest%i WRITE", i)
end
begin_query = "LOCK TABLES " .. table.concat(tables, " ,")
commit_query = "UNLOCK TABLES"
else
begin_query = "BEGIN"
commit_query = "COMMIT"
end
end
function get_range_str()
local start = sb_rand(1, oltp_table_size)
return string.format(" WHERE id BETWEEN %u AND %u",
start, start + oltp_range_size - 1)
end
function event() -- 一个event
local rs
local i
local table_name
local c_val
local pad_val
local query
table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
if not oltp_skip_trx then -- oltp_skip_trx参数可以在命令行指定
db_query(begin_query)
end
if not oltp_write_only then
for i=1, oltp_point_selects do
rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" ..
sb_rand(1, oltp_table_size))
end
if oltp_range_selects then
for i=1, oltp_simple_ranges do
rs = db_query("SELECT c FROM ".. table_name .. get_range_str())
end
for i=1, oltp_sum_ranges do
rs = db_query("SELECT SUM(K) FROM ".. table_name .. get_range_str())
end
for i=1, oltp_order_ranges do
rs = db_query("SELECT c FROM ".. table_name .. get_range_str() ..
" ORDER BY c")
end
for i=1, oltp_distinct_ranges do
rs = db_query("SELECT DISTINCT c FROM ".. table_name .. get_range_str() ..
" ORDER BY c")
end
end
end
if not oltp_read_only then
for i=1, oltp_index_updates do
rs = db_query("UPDATE " .. table_name .. " SET k=k+1 WHERE id=" .. sb_rand(1, oltp_table_size))
end
for i=1, oltp_non_index_updates do
c_val = sb_rand_str("###########-###########-###########-###########-###########-###########-###########-###########-###########-###########")
query = "UPDATE " .. table_name .. " SET c='" .. c_val .. "' WHERE id=" .. sb_rand(1, oltp_table_size)
rs = db_query(query)
if rs then
print(query)
end
end
for i=1, oltp_delete_inserts do
i = sb_rand(1, oltp_table_size)
rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i)
c_val = sb_rand_str([[
###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]])
pad_val = sb_rand_str([[
###########-###########-###########-###########-###########]])
rs = db_query("INSERT INTO " .. table_name .. " (id, k, c, pad) VALUES " .. string.format("(%d, %d, '%s', '%s')",i, sb_rand(1, oltp_table_size) , c_val, pad_val))
end
end -- oltp_read_only
if not oltp_skip_trx then
db_query(commit_query)
end
end
另外,common_oltp里有这样一个数据库表,应该就是用啊来做测试的
query = string.format([[
CREATE TABLE sbtest%d(
id %s,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
%s (id)
) %s %s]],
table_num, id_def, id_index_def, engine_def, extra_table_options)
开始测,老规矩,先help一下
# 使用sysbench --help命令,可以看到mysql的参数项
mysql options:
--mysql-host=[LIST,...] MySQL server host [localhost]
--mysql-port=[LIST,...] MySQL server port [3306]
--mysql-socket=[LIST,...] MySQL socket
--mysql-user=STRING MySQL user [sbtest]
--mysql-password=STRING MySQL password []
--mysql-db=STRING MySQL database name [sbtest]
--mysql-ssl[=on|off] use SSL connections, if available in the client library [off]
--mysql-ssl-cipher=STRING use specific cipher for SSL connections []
--mysql-compression[=on|off] use compression, if available in the client library [off]
--mysql-debug[=on|off] trace all client library calls [off]
--mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205]
--mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off]
# /usr/share/sysbench/ 目录下的脚本实现了help
# /usr/share/sysbench/tests/include 目录下的脚本没有实现help命令
# 他们的参数应该都是一致的
# prepare
(base) darcyzhang@debian:~$ sysbench /usr/share/sysbench/oltp_read_write.lua \
--mysql-host=192.168.5.217 \
--mysql-port=3396 \
--mysql-user=root \
--mysql-password=123456 \
--mysql-db=test_db \
--threads=16 \
--events=1000000 \
--report-interval=1 \
--time=10 \
prepare
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Initializing worker threads...
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
Creating a secondary index on 'sbtest1'...
# run
(base) darcyzhang@debian:~$ sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=192.168.5.217 --mysql-port=3396 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --threads=16 --events=1000000 --report-interval=1 --time=10 run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 16
Report intermediate results every 1 second(s)
Initializing random number generator from current time
Initializing worker threads...
Threads started!
[ 1s ] thds: 16 tps: 724.39 qps: 14666.75 (r/w/o: 10301.51/2900.56/1464.69) lat (ms,95%): 27.66 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 16 tps: 741.85 qps: 14833.05 (r/w/o: 10376.93/2971.42/1484.71) lat (ms,95%): 27.66 err/s: 1.00 reconn/s: 0.00
[ 3s ] thds: 16 tps: 747.30 qps: 15003.93 (r/w/o: 10509.15/2997.18/1497.59) lat (ms,95%): 27.66 err/s: 3.00 reconn/s: 0.00
[ 4s ] thds: 16 tps: 760.82 qps: 15225.36 (r/w/o: 10659.45/3044.27/1521.64) lat (ms,95%): 25.74 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 16 tps: 748.09 qps: 14986.75 (r/w/o: 10491.23/2999.35/1496.17) lat (ms,95%): 26.68 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 16 tps: 776.93 qps: 15535.59 (r/w/o: 10880.02/3101.72/1553.86) lat (ms,95%): 25.74 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 16 tps: 757.23 qps: 15112.55 (r/w/o: 10570.18/3027.91/1514.46) lat (ms,95%): 26.20 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 16 tps: 762.80 qps: 15295.90 (r/w/o: 10712.13/3058.18/1525.59) lat (ms,95%): 26.20 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 16 tps: 777.21 qps: 15524.10 (r/w/o: 10871.87/3095.82/1556.41) lat (ms,95%): 25.74 err/s: 2.00 reconn/s: 0.00
[ 10s ] thds: 16 tps: 767.92 qps: 15340.39 (r/w/o: 10732.87/3072.68/1534.84) lat (ms,95%): 25.28 err/s: 1.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 106260
write: 30342
other: 15173
total: 151775
transactions: 7583 (756.44 per sec.)
queries: 151775 (15140.20 per sec.)
ignored errors: 7 (0.70 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 10.0199s
total number of events: 7583
Latency (ms):
min: 13.56
avg: 21.12
max: 47.13
95th percentile: 26.68
sum: 160137.72
Threads fairness:
events (avg/stddev): 473.9375/4.87
execution time (avg/stddev): 10.0086/0.01
# cleanup
(base) darcyzhang@debian:~$ sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=192.168.5.217 --mysql-port=3396 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --threads=16 --events=1000000 --report-interval=1 --time=10 cleanup
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
Dropping table 'sbtest1'...
在企业生产中可能会需要再mysql之上加一层代理,来优化mysql在某些方面的短板。此时测试通过这个代理相较于直连数据库的性能差异,将成为衡量这个代理价值的一个重要参考项。
这里以kingshard举例来做一个性能对比。kingshard 是由 Go 提供支持的高性能 MySQL 代理。就像其他 mysql 代理一样,您可以使用它来拆分读/写 sql。现在它支持基本的 SQL 语句(选择、插入、更新、替换、删除)。最重要的功能是分片功能。Kingshard 旨在简化 MySQL 的分片方案。其官方文档中表示,kingshard 的性能比直接连接 MySQL 提高了 80% 左右。
按其 安装 步骤进行安装。性能测试一般都会在真机上进行,我这里为了测试方便,拉取了一个go的docker镜像,在docker容器中部署kingshard。这种方式的话注意做9696端口的映射。
安装完成后需要配置配置文件etc/ks.yaml
来指定数据库、端口等。注意这里的etc目录是其项目下的etc目录,而不是根目录下的etc。
我打算用root这个用户,对配置文件做一些更改。没再做一个node2,所以把node2的相关的配置都删了,否则连不上会报错
# ks.yaml(截取部分)
# server listen addr
addr : 0.0.0.0:9696
# server user and password
user_list:
-
user : root
password : root
-
user : kingshard
password : kingshard
# node is an agenda for real remote mysql server.
nodes :
-
name : node1
# default max conns for mysql server
max_conns_limit : 32
# all mysql in a node must have the same user and password
user : root
password : 123456 # ★★★改★★★
# master represents a real mysql master server
master : 192.128.5.217:3396 # ★★★改★★★
# slave represents a real mysql salve server,and the number after '@' is
# read load weight of this slave.
#slave : 192.168.59.101:3307@2,192.168.59.101:3307@3
down_after_noalive : 32
# schema defines sharding rules, the db is the sharding table database.
schema_list :
-
user: root
nodes: [node1] # ★★★改★★★
default: node1
shard:
-
-
user: kingshard
nodes: [node1] # ★★★改★★★
default: node1
shard:
-
Run and Test
root@2c5bfe080cef:/go/src/github.com/flike/kingshard# ./bin/kingshard -config=etc/ks.yaml
__ _ __ __
/ /__(_)___ ____ ______/ /_ ____ __________/ /
/ //_/ / __ \/ __ \/ ___/ __ \ / __\/ ___/ __ /
/ ,< / / / / / /_/ (__ ) / / / /_/ / / / /_/ /
/_/|_/_/_/ /_/\__, /____/_/ /_/\__,_/_/ \__,_/
/____/
Git commit:f17b393
Build time:2021-12-05 04:52:57
2021/12/05 05:10:36 - INFO - server.go:[300] - [server] "NewServer" "Server running" "netProto=tcp|address=0.0.0.0:9696" conn_id=0
2021/12/05 05:10:36 - INFO - server.go:[43] - [web] "NewApiServer" "Api Server running" "netProto=http|address=0.0.0.0:9797" conn_id=0
2021/12/05 05:10:36 - INFO - prometheus.go:[41] - [prometheus] "Run" "Prometheus running" "address=0.0.0.0:7080" conn_id=0
# 可以通过代理连接到数据库
(base) darcyzhang@debian:~$ mysql -uroot -proot -h192.168.5.217 -P9696
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 10001
Server version: 5.6.20-kingshard mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| tdb |
| test_db |
+--------------------+
6 rows in set (0.005 sec)
通过代理复现对数据库的sysbench测试,同样的参数执行prepare、run、cleanup
(base) darcyzhang@debian:~$ sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua \
--mysql-host=192.168.5.217 \
--mysql-port=9696 \
--mysql-user=root \
--mysql-password=root \
--mysql-db=test_db \
--threads=16 \
--events=1000000 \
--report-interval=1 \
--time=10 \
run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 16
Report intermediate results every 1 second(s)
Initializing random number generator from current time
Initializing worker threads...
Threads started!
[ 1s ] thds: 16 tps: 229.75 qps: 4760.14 (r/w/o: 3357.76/926.97/475.42) lat (ms,95%): 77.19 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 16 tps: 238.15 qps: 4772.04 (r/w/o: 3339.13/956.61/476.30) lat (ms,95%): 78.60 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 16 tps: 239.99 qps: 4792.86 (r/w/o: 3358.90/953.97/479.99) lat (ms,95%): 80.03 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 16 tps: 244.00 qps: 4866.01 (r/w/o: 3407.01/971.00/488.00) lat (ms,95%): 77.19 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 16 tps: 236.03 qps: 4748.68 (r/w/o: 3320.48/956.14/472.07) lat (ms,95%): 78.60 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 16 tps: 240.99 qps: 4805.90 (r/w/o: 3368.93/954.98/481.99) lat (ms,95%): 77.19 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 16 tps: 241.00 qps: 4814.91 (r/w/o: 3361.93/971.98/480.99) lat (ms,95%): 77.19 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 16 tps: 248.97 qps: 4996.44 (r/w/o: 3505.61/991.89/498.94) lat (ms,95%): 74.46 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 16 tps: 251.05 qps: 4990.90 (r/w/o: 3490.63/999.18/501.09) lat (ms,95%): 74.46 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 16 tps: 256.98 qps: 5174.63 (r/w/o: 3629.74/1028.93/515.96) lat (ms,95%): 71.83 err/s: 1.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 34230
write: 9778
other: 4889
total: 48897
transactions: 2444 (243.12 per sec.)
queries: 48897 (4864.01 per sec.)
ignored errors: 1 (0.10 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 10.0480s
total number of events: 2444
Latency (ms):
min: 46.78
avg: 65.64
max: 127.52
95th percentile: 77.19
sum: 160422.05
Threads fairness:
events (avg/stddev): 152.7500/1.20
execution time (avg/stddev): 10.0264/0.01
对比一下
裸数据库
transactions: 7583 (756.44 per sec.)
queries: 151775 (15140.20 per sec.)
kingshard
transactions: 2444 (243.12 per sec.)
queries: 48897 (4864.01 per sec.)
看起来该场景下性能损失了2/3(结果不能说明问题,未考虑最佳部署环境、没有参数调优等等)
https://github.com/akopytov/sysbench
https://github.com/flike/kingshard