后台测试mysql5.7和mysql8.0分别在读写、只读、只写模式下不同并发性能(tps、qps)前提测试版本为mysql5.7.22和mysql8.0.15sysbench测试重启mysql服务并清除os的缓存(避免多次测试时命中缓存)每次测试时,新生成测试数据,然后每次测试保证mysql5.7和mysql8.0的测试。mysql5.7和mysql8.0的配置参数相同环境机器cat/etc/redhat-release|xargsecho'version'&&dmidecode-ssystem-product-name|xargsecho'isvirtualized'&&cat/proc/cpuinfo|grep"processor"|wc-l|xargsecho'cpu核数'版本CentOSLinuxrelease7.5.1804(Core)是否虚拟化KVMcpu核数4myql5.7.225.7.22-loginnodb_buffer_pool_size128Minnodb_log_buffer_size64Minnodb_log_file_size48Mbinlog_formatROWlog_binONtransaction_isolationREPEATABLE-READmysql8.0.158.0.15innodb_buffer_pool_size128Minnodb_log_buffer_size64Minnodb_log_file_size48Mbinlog_formatROWlog_binONtransaction_isolationREPEATABLE-READsysbenchsysbench-Vsysbench1.1.0(usingbundledLuaJIT2.1.0-beta3)测试在不同的持久优化策略(binlog、redolog持久化)下mysql5.7和mysql8.0在读写模式、只读模式、只写模式(oltp_read_write、oltp_read_only、oltp_write_only)下的性能)sysbench测试时间为60s,测试表数为20张,测试采用双1模式(安全)和0+2模式(高性能)进行。双1模式下SHOWGLOBALVARIABLESWHEREVariable_nameIN('sync_binlog','innodb_flush_log_at_trx_commit');+--------------------------------+-------+|Variable_name|Value|+-------------------------------+-------+|innodb_flush_log_at_trx_commit|1||sync_binlog|1|+-----------------------------+-------+mysql5.7和mysql8.0在读写模式下性能双1配置,在读写模式下,mysql5.7.22和mysql8.0.15tps,qps性能差不多,mysql8.0.15在120线程同时,性能下降抖动:mysql5.7和mysql8.0在只读模式下双1配置下,在只读模式下,mysql5.7.22的tps和qps比原来的好1/3左右mysql8.0.15;并发线程数增加后,tps和qps没有增加,反而呈下降趋势mysql5.7和mysql8.0在只写模式下的性能是double1配置。在只写模式下,随着并发数的增加,mysql5.7.22的性能比mysql8.0.15提高了1/4左右。02SHOWGLOBALVARIABLESWHEREVariable_nameIN('sync_binlog','innodb_flush_log_at_trx_commit');+------------------------------------+-------+|Variable_name|Value|+--------------------------------+-------+|innodb_flush_log_at_trx_commit|2||sync_binlog|0|+---------------------------------+-------+mysql5.7和mysql8.0performanceinread-writemode02配置,在读写模式下,在并发数较低的情况下,mysql5.7.22的性能优于mysql5.7.22mysql8.0.15;当并发数比较高时,mysql8.0.15的性能优于mysql5.7.22;当80线程并发以上时,性能开始下降。mysql5.7和mysql8.0在只读模式下的性能是02配置。在只读模式下,mysql5.7.22的性能比mysql8.0.15提高了1/3左右;随着并发数的增加,性能并没有增加,反而有下降的趋势。mysql5.7和mysql8.0在只写模式下的性能是02配置。只写模式下,mysql5.7.22的tps抖动比较大;mysql5.7.22的qps比mysql8.0.15好1/3结论总体而言,mysql5.7.22在读写模式、只读模式、只写模式下的性能均优于mysql8.0.15.随着并行数的增加,性能不会增加,反而会下降。本次测试的结果是在配置很低的情况下进行的,并不是说sysbench需要设置--db-ps-mode=disable来禁用预编译语句,否则并发很多的时候会报如下错误测试线程致命:mysql_stmt_prepare()失败致命:MySQLerror:1461“无法创建超过max_prepared_stmt_countstatements(当前值:16382)”致命:mysql_stmt_prepare()失败致命:MySQL错误:1461“无法创建超过max_prepared_stmt_countstatements(当前值:16382)“FATAL:threadfunction/local/share/sysbench/oltp_common.lua:288:SQLAPIerrorFATAL:mysql_stmt_prepare()failedFATAL:MySQLerror:1461“不能创建超过max_prepared_stmt_countstatements(currentvalue:16382)”FATAL:thread_init'functionfailed:/usr/local/share/sysbench8.lua8:2QLAPIerrorFATAL:mysql_stmt_prepare()failed使用脚本catsysbench_test_mysql5.7_8.0_tps_qps.sh#!/bin/bash#进行sysbench测试mysql5.7和mysql8.0的读写模式、只读模式和写入模式的tps和qps只有模式#nohupbash$0>/tmp/sysbench_test2>&1user=adminpasswd=adminports="801557222"host=127.0.0.1sysbench_test_mode="oltp_read_writeoltp_read_onlyoltp_write_only"sysbench_test_info_path=/tmp/sysbench-localechofunce="+%"F$(date-%T)\e[1;31m${what}\e[0m"}functioncheck_las_comm(){if[$1-ne0];thenred_echo$2exit1fi}functionrestart_mysqld(){servicemysqld${1}restartsleep2}functionpurge_binlog(){port=$1mysql-u$user-p$passwd-P$port-h$host<
