Welcome 微信登录

首页 / 数据库 / MySQL / MySQL单台物理机上单实例多库与多实例单库性能测试

因游戏业务需求,经常需要创建新的数据库,有时候在已经启着数据库实例的机器上纠结,是在原来的实例中直接加个库呢,还是在另起一个实例,哪个性能更好呢?所以就有了本次的测试。物理机6台,配置如下CPU:Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHzMEM:256GDISK:SSD2台MySQL机器,分别部署单实例多库环境和多实例单库环境,8个数据库,8个实例,每个数据库数据大概6G左右,机器的大内存是为了以后上线用的,测试为了节省创建数据的时间,所以没有采用大内存,只需要数据大于内存即可。4台压力源,每台上压测时起2个进程进行测试。10.11.0.159 单实例多库              buffer_pool_size16G   1instance 8db10.11.0.160 多实例单库              buffer_pool_size2G     8instance 1db10.11.0.159 单实例多库上测试命令:./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --mysql-db=sbtest1 --oltp-table-size=200000--mysql-user=thunder --mysql-password=thunder --mysql-host=10.11.0.159--mysql-port=3306 --oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --mysql-db=sbtest2 --oltp-table-size=200000--mysql-user=thunder --mysql-password=thunder --mysql-host=10.11.0.159--mysql-port=3306 --oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --mysql-db=sbtest3 --oltp-table-size=200000--mysql-user=thunder --mysql-password=thunder --mysql-host=10.11.0.159--mysql-port=3306 --oltp-tables-count=100 --num-threads=32--max-requests=200000 --report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --mysql-db=sbtest4 --oltp-table-size=200000--mysql-user=thunder --mysql-password=thunder --mysql-host=10.11.0.159 --mysql-port=3306--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --mysql-db=sbtest5 --oltp-table-size=200000--mysql-user=thunder --mysql-password=thunder --mysql-host=10.11.0.159--mysql-port=3306 --oltp-tables-count=100 --num-threads=32--max-requests=200000 --report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --mysql-db=sbtest6 --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.159 --mysql-port=3306--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --mysql-db=sbtest7 --oltp-table-size=200000--mysql-user=thunder --mysql-password=thunder --mysql-host=10.11.0.159--mysql-port=3306 --oltp-tables-count=100 --num-threads=32--max-requests=200000 --report-interval=2 run./sysbench --test=./tests/db/oltp.lua --mysql-table-engine=innodb--mysql-db=sbtest8 --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.159 --mysql-port=3306--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run10.11.0.160 多实例单库上测试命令./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.160 --mysql-port=3301--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.160 --mysql-port=3302--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.160 --mysql-port=3303--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.160 --mysql-port=3304--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.160 --mysql-port=3305--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.160 --mysql-port=3306--oltp-tables-count=100 --num-threads=32 --max-requests=200000 --report-interval=2run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.160 --mysql-port=3307--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run./sysbench --test=./tests/db/oltp.lua--mysql-table-engine=innodb --oltp-table-size=200000 --mysql-user=thunder--mysql-password=thunder --mysql-host=10.11.0.160 --mysql-port=3308--oltp-tables-count=100 --num-threads=32 --max-requests=200000--report-interval=2 run测试数据:
多实例非本机TPSQPS单实例非本机
323301359.476470.4432test1356.546417.81
323302358.976461.4132test2355.766403.69
323303358.926460.6032test3356.826422.81
323304358.536453.6032test4356.386414.78
323305358.396451.0432test5357.086427.42
323306358.626455.2232test6355.876405.58
323307358.566454.1132test7355.756403.54
323308358.586454.5032test8355.546399.70
汇总2870.0451660.92汇总2849.7451295.33
多实例本机单实例本机
323301787.4914174.8932test1608.3710950.61
323302789.4514210.1732test2616.1411090.59
323303789.0014201.9332test3606.9610925.27
323304786.2314152.0832test4611.4911006.75
323305788.7514197.4632test5607.0010926.00
323306786.8714163.7132test6614.7611065.62
323307791.7814251.9832test7607.0110926.18
323308789.8514217.2532test8611.9911015.82
汇总6309.42113569.47汇总4883.7287906.84
总结:当压力源为内网其它机器时,可以看出2台机器TPS/QPS相差不大,其原因为MySQL服务器的物理机网卡已经跑满,此时的瓶颈为网卡。当压力源为MySQL服务器本机时,可以看出多实例单库的性能要比单实例多库的性能高出20%左右,但是其本机负载也很高,最高达到了225,CPU  idle值为0,机器资源已经用光,而单实例多库机器的负载最高为65,机器还有剩余资源,CPUidle值为6左右,此时的瓶颈为CPU。以上测试没有针对数据库进行较精细的测试,只是通过sqlbench测试相同配置机器多实例单库与单实例多库性能的对比,已经有相关进行参考。通过上面的数据,肯定很多人会选择多实例单库,而我却没有采用多实例的方式,原因如下:对于业务来说,一般情况下是服务与数据库不在同一台机器,通过测试可以看出,在网络为瓶颈的情况下,两种方式的TPS/QPS是相差不多的,单实例多库这种方式维护起来又很方便。本文永久更新链接地址