|
硬件环境 |
软件环境 |
||||
主机名 |
主机地址 |
CPU |
内存 |
硬盘 |
软件版本 |
操作系统 |
Master |
192.168.105.97 |
Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz 8核 |
16GB |
144GB |
Mysql5.7.28 |
CentOS Linux release 7.3.1611 |
Slave |
192.168.105.98 |
Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz 8核 |
16GB
|
144GB |
Mysql5.7.28 |
CentOS Linux release 7.3.1611 |
Mycat
|
192.168.105.99 |
Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz 8核 |
16GB |
144GB |
Mycat1.6 Mysql5.7.28 |
CentOS Linux release 7.3.1611 |
max_connections = 1000
innodb_open_files=2048
innodb_buffer_pool_size = 8G
innodb_sort_buffer_size = 64M
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
3. 测试方法
1.工具:sysbench测试工具,oltp_read_write.lua测试脚本
2.数据量:10张表,每张表100万条记录
3.测试时长:300秒
4. 线程数16、32、48、64、96、128及更多
4.测试场景及结果
4.1 10张表直接写入mysql
sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=192.168.105.97 --mysql-port=3306 \
--mysql-user=root --mysql-db=db1 --mysql-password=1qaz2wsx \
--tables=10 --table-size=1000000 --threads=16 --time=300 \
--report-interval=10 run >>/home/uniapply/mysysbench_th16.log
各线程测试结果:
线程数 |
QPS(per sec) |
TPS(per sec) |
95% Latency (ms) |
16 |
11309.13 |
565.46 |
63.32 |
32 |
11157.91 |
557.90 |
89.16 |
48 |
10823.45 |
541.17 |
134.90 |
64 |
10592.81 |
529.64 |
167.44 |
96 |
10328.00 |
516.40 |
253.35 |
128 |
10106.73 |
505.34 |
344.08 |
4.2 10张表通过mycat 分4个db{1-4}库写入单台mysql
sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=192.168.105.99 --mysql-port=8066 --db-driver=mysql --mysql-user=root --mysql-db=TESTDB --mysql-password=123456 --db-ps-mode=disable --tables=10 --table-size=1000000 --threads=16 --time=300 --report-interval=10 run >>/home/uniapply/mysysbench_one_th16.log
schema.xml配置如下:
<schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" >
<table name="sbtest1" dataNode="dn1" />
<table name="sbtest2" dataNode="dn1" />
<table name="sbtest3" dataNode="dn1" />
<table name="sbtest4" dataNode="dn2" />
<table name="sbtest5" dataNode="dn2" />
<table name="sbtest6" dataNode="dn2" />
<table name="sbtest7" dataNode="dn3" />
<table name="sbtest8" dataNode="dn3" />
<table name="sbtest9" dataNode="dn4" />
<table name="sbtest10" dataNode="dn4" />
</schema>
<dataNode name="dn1" dataHost="master" database= "db1" />
<dataNode name="dn2" dataHost="master" database= "db2" />
<dataNode name="dn3" dataHost="master" database= "db3" />
<dataNode name="dn4" dataHost="master" database= "db4" />
各线程测试结果:
线程数 |
QPS(per sec) |
TPS(per sec) |
95% Latency (ms) |
16 |
16457.15 |
822.86 |
24.38 |
32 |
21863.91 |
1093.20 |
40.37 |
48 |
24843.09 |
1242.15 |
55.82 |
64 |
28095.88 |
1404.79 |
68.05 |
96 |
29749.64 |
1487.48 |
95.81 |
128 |
30901.99 |
1545.10 |
125.52 |
4.3 10张表通过mycat 分库写入两台mysql
schema.xml配置如下:
<schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" >
<table name="sbtest1" dataNode="dn1" />
<table name="sbtest2" dataNode="dn1" />
<table name="sbtest3" dataNode="dn1" />
<table name="sbtest4" dataNode="dn2" />
<table name="sbtest5" dataNode="dn2" />
<table name="sbtest6" dataNode="dn2" />
<table name="sbtest7" dataNode="dn3" />
<table name="sbtest8" dataNode="dn3" />
<table name="sbtest9" dataNode="dn4" />
<table name="sbtest10" dataNode="dn4" />
</schema>
<dataNode name="dn1" dataHost="master" database= "db1" />
<dataNode name="dn2" dataHost="master" database= "db2" />
<dataNode name="dn3" dataHost="slave" database= "db1" />
<dataNode name="dn4" dataHost="slave" database= "db2" />
各线程测试结果:
线程数 |
QPS(per sec) |
TPS(per sec) |
95% Latency (ms) |
16 |
16653.81 |
832.69 |
23.95 |
32 |
23358.80 |
1167.94 |
35.59 |
48 |
27991.35 |
1399.57 |
47.47 |
64 |
29657.73 |
1482.89 |
59.99 |
96 |
30468.19 |
1523.41 |
90.78 |
128 |
32691.53 |
1634.58 |
110.66 |
160 |
34400.86 |
1720.04 |
127.81 |
200 |
35535.19 |
1776.76 |
153.02 |
256 |
35239.09 |
1761.95 |
193.38 |
4.3 10张表通过mycat 分库写入3台mysql
<schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" >
<table name="sbtest1" dataNode="dn1" />
<table name="sbtest2" dataNode="dn1" />
<table name="sbtest3" dataNode="dn2" />
<table name="sbtest4" dataNode="dn2" />
<table name="sbtest5" dataNode="dn3" />
<table name="sbtest6" dataNode="dn3" />
<table name="sbtest7" dataNode="dn4" />
<table name="sbtest8" dataNode="dn4" />
<table name="sbtest9" dataNode="dn5" />
<table name="sbtest10" dataNode="dn5" />
</schema>
<dataNode name="dn1" dataHost="master" database= "db1" />
<dataNode name="dn2" dataHost="master" database= "db2" />
<dataNode name="dn3" dataHost="slave" database= "db1" />
<dataNode name="dn4" dataHost="slave" database= "db2" />
<dataNode name="dn5" dataHost="mycat" database= "db1" />
各线程测试结果:
线程数 |
QPS(per sec) |
TPS(per sec) |
95% Latency (ms) |
16 |
16689.97 |
834.50 |
23.52 |
32 |
16959.92 |
848.00 |
23.10 |
48 |
28476.12 |
1423.81 |
43.39 |
64 |
29487.32 |
1474.37 |
56.84 |
96 |
33320.61 |
1666.03 |
77.19 |
128 |
33360.94 |
1668.05 |
101.13 |
160 |
32235.10 |
1611.75 |
132.49 |
200 |
34094.82 |
1704.74 |
155.80 |
256 |
33676.08 |
1683.80 |
196.89 |
总结:
从几组测试中可以发现单机mysql发生资源耗尽的情况,但是通过中间件拆分后的mysql依然可以得到比较高的性能表现。
mycat 在高并发多线程纯oltp环境下可以发挥很大的作用,来帮助提高mysql的吞吐量。