[Posts] the MySQL benchmark comparison: 5.7 VS 8.0

MySQL performance benchmark test comparison: 5.7 VS 8.0

https://segmentfault.com/a/1190000018419485

 

This article was published by the cloud + Community

Author: Database

Disclaimer: This article compiled by Tencent cloud database product team, the contents of the original page from severalnines English the official website, if reproduced, please indicate the source. Translation aim is to deliver more information on the latest global database field, does not mean that Tencent cloud database product team agree with their views or confirm the authenticity of its contents. If other media, websites or any other form of legal entities and individuals use must be authorized and shall assume full legal responsibility through legitimate copyright owner in writing. Not allowed to use the name of Tencent cloud database team were reproduced, or misappropriation of the name of Tencent cloud database release any information.

Original link: HTTPS: //severalnines.com/blog ...


Driven by Oracle MySQL team, MySQL 8.0 has undergone tremendous changes and modifications.

Physical file has changed. For example, .frm,  .trg, .trn and  .par longer exists. Added a lot of new features, such as common table expressions (Common Table Expressions CTE), window function (Window Functions), invisible index (Invisible Indexes), the regular expression (regexp) -MySQL8.0 now fully supports Unicode, how possessed byte security features. The data dictionary also changed. It is now a transactional and merge data dictionary, information about the database objects stored in the dictionary. With previous versions, the dictionary data stored in the metadata file and non-transactional tables.

Security has been improved, caching_sha2_password authentication replaced the previous mysql_native_password authentication, the default authentication method. It provides greater flexibility, but also strengthened the security that it is required to use an unencrypted connection or a secure link exchange support for password realized by RSA keys.

All these features have very good MySQL 8.0 offers, as well as enhancements and improvements carried out, our team very interested to learn under the current version of MySQL 8.0 performance situation. Especially considering we ClusterControl underway for MySQL 8.0.x design (stay tuned). This blog will not discuss the characteristics MySQL8.0, but intend to compare the performance of MySQL 5.7, see how it improved.

Server Setup and Environment server settings and environment

For this benchmark, I intend to use the system environment based on AWS EC2 minimum configuration:

• Example type: t2.xlarge examples

• Storage: gp2 (SSD storage, minimum 100 IOPS, maximum 16000 IOPS)

· Virtual CPU: 4

• Memory: 16GiB

· MySQL5.7 version: MySQLCommunity Server (GPL) 5.7.24

· MySQL8.0 version: MySQLCommunity Server - GPL 8.0.14

In this benchmark, I also configured for the values ​​of some parameters of items, which are:

· Innodb_max_dirty_pages_pct = 90 ## which is the default MySQL 8.0 in.

· Innodb_max_dirty_pages_pct_lwm = 10 ## which is the default MySQL 8.0 in

· innodb_flush_neighbors=0

· innodb_buffer_pool_instances=8

· innodb_buffer_pool_size=8GiB

Here two versions (MySQL 5.7 and MySQL 8.0) is arranged to rest Parameter my.cnf reference template ClusterControl the tune.

Furthermore, I do not use MySQL8.0 new authentication method here that caching_sha2_password authentication. An alternative is to use both versions mysql_native_password, plus arranged innodb_dedicated_serve = OFF (default value) as a MySQL 8.0 innodb_dedicated_serve new features.

To simplify the work, I use MySQL 5.7 Community version ClusterControl configuration node, the node is then removed from the cluster, making it a single host, and shut down the cluster control panel, so MySQL 5.7 Node is in dormant state (not monitor traffic). Technically, MySQL 5.7 and MySQL8.0 nodes are dormant, there is no active connection through the node, so it is essentially a pure benchmark.

Concerned about the "Tencent cloud database," the official micro letter, and stand 10 yuan Tencent cloud-free threshold vouchers, mobile experience end a key management database, the database more from elementary to high-order waiting for you to combat tutorial about!

Commands and scripts Commands and Scripts Used for use

For this task, it sysbench used to test and simulate the load of these two environments. The following test and commands used in the script:

sb-prepare.sh #!/bin/bash host=$1#host192.168.10.110port=3306user='sysbench'password='MysqP@55w0rd'table_size=500000rate=20ps_mode='disable'sysbench/usr/share/sysbench/oltp_read_write.lua --db-driver=mysql --threads=1--max-requests=0 --time=3600 --mysql-host=$host --mysql-user=$user--mysql-password=$password --mysql-port=$port --tables=10 --report-interval=1--skip-trx=on --table-size=$table_size --rate=$rate --db-ps-mode=$ps_modeprepare

sb-run.sh

#!/usr/bin/envbash2 host=$1port=3306user="sysbench"password="MysqP@55w0rd"table_size=100000tables=10rate=20ps_mode='disable'threads=1events=0time=5trx=100path=$PWD counter=1 echo "thread,cpu" >${host}-cpu.csv for i in 16 32 64 128 256 512 1024 2048; do threads=$i mysql -h $host -e"SHOW GLOBAL STATUS" >> $host-global-status.logtmpfile=$path/${host}-tmp${threads}touch $tmpfile/bin/bashcpu-checker.sh $tmpfile $host $threads & /usr/share/sysbench/oltp_read_write.lua--db-driver=mysql --events=$events --threads=$threads --time=$time--mysql-host=$host --mysql-user=$user --mysql-password=$password--mysql-port=$port --report-interval=1 --skip-trx=on --tables=$tables--table-size=$table_size --rate=$rate --delete_inserts=$trx --order_ranges=$trx--range_selects=on --range-size=$trx --simple_ranges=$trx --db-ps-mode=$ps_mode--mysql-ignore-errors=all run | tee -a $host-sysbench.log echo"${i},"`cat ${tmpfile} | sort -nr | head -1` >> ${host}-cpu.csvunlink ${tmpfile} mysql -h $host -e"SHOW GLOBAL STATUS" >> $host-global-status.logdone python $path/innodb-ops-parser.py $host mysql -h $host -e "SHOW GLOBALVARIABLES" >> $host-global-vars.log

Therefore, the script just ready sbtestschema and populate the tables and records. It then uses

/usr/share/sysbench/oltp_read_write.lua script read / write load testing. The dump script global state variables and MySQL, collecting CPU utilization, and parse the script innodb-ops-parser.py InnoDB operative treatment. According to the script generates a log dump collected during the benchmark  .csv file, I use an Excel spreadsheet from here to  generate a chart .csv file. Please check the code on github submitted.

Now, let us continue to deal with the results of the chart!

InnoDB line operation

img

img

img

img

基本上在这里,我只提取了InnoDB行操作,它执行查找(读取),删除,插入和更新。当线程数量增加时,MySQL 8.0明显优于MySQL 5.7!在这两个版本中都没有针对配置项进行任何个性化变更,只有我统一配置的参数项。所以这两个版本中的配置几乎都使用默认值。

有趣的是,MySQL团队关于新版本中读写性能的声明,这些图表指出了性能的显著提高,特别是在高负载服务器上。想一下MySQL 5.7和MySQL 8.0在InnoDB行操作上的区别,确实存在有很大的不同,特别是当线程数增加的时候。MySQL 8.0表明,无论工作负载如何,它都能高效地运行。

事务处理

img

img

如上图所示,MySQL 8.0的结果趋势显示出其处理事务所需的时间的巨大变化。纵轴数值越低,代表性能越好,意味着处理事务的速度更快。处理的事务统计表(第二张表)还显示出这两个版本处理事务的数量没有差异。这意味着,两个版本处理的事务数量几乎相同,但它们的完成速度不同。虽然MySQL 5.7在较低的负载下可以大量事务,但是实际的负载,特别是在生产中,可能会更高——尤其是在最繁忙的时期。

img

上面的图仍然显示的是两个版本能够处理的事务数量,只是将读和写分离开来。然而,图中实际上是存在异常值,而我没有将这些值包括在内,因为它们是这一小部分异常结果会扭曲图形。

MySQL 8.0体现出一个很大的改进,特别是对于读取。表现在写操作的效率上,特别是对于高工作负载的服务器。在8.0版本中,影响MySQL读取性能的重要新增支持是:可以按降序(或正向索引扫描)创建索引的能力。以前的版本只有升序或反向索引扫描,如果需要降序,MySQL必须执行filesort(如果需要filesort,需要检查max_length_for_sort_data的值)。当最有效的扫描顺序混合某些列的升序和其他列的降序时,降序索引还使优化器可以使用多列索引。有关详细信息,请参见此处。

CPU资源

img

在此基准测试中,我决定测试一些硬件资源,尤其是CPU利用率。

让我先解释一下如何在基准测试中获取CPU使用率。在对数据库进行基准测试时,sysbench测试结果中不包括在此过程中使用的硬件资源的统计信息。因此,我所做的是通过创建文件的方式来创建标识,通过SSH连接到目标主机,然后用Linux命令“top”收集数据并在测试结束前进行解析,然后再次收集。然后分析出mysqld进程占用最大的CPU使用量,最后删除该标识文件。你可以查看我在github上的代码。

让我们再次讨论图表结果,似乎表明MySQL 8.0消耗了大量的CPU,超过MySQL 5.7。然而,MySQL 8.0可能必须消耗额外的CPU在新的变量配置上。例如,这些变量可能会影响您的MySQL 8.0:

· innodb_log_spin_cpu_abs_lwm = 80

· innodb_log_spin_cpu_pct_hwm = 50

· innodb_log_wait_for_flush_spin_hwm = 400

· innodb_parallel_read_threads = 4

在此基准测试中,具有默认值的变量将保留其默认值。由于MySQL 8.0重新设计了InnoDB写入REDO日志的方式(这是一个改进),前三个变量可配置处理重做日志的使用的CPU资源。例如,变量innodb_log_spin_cpu_pct_hwm具有CPU亲和性,这意味着如果mysqld仅绑定到4个内核,它将忽略其他CPU内核。对于并行读取线程,在MySQL 8.0中添加了一个新变量,您可以调整要使用的线程数。

然而,我没有深入研究这个问题。可以通过利用MySQL8.0提供的特性来提高性能。

结论

MySQL 8.0中有许多改进。基准测试结果显示,与MySQL 5.7相比,MySQL 8.0不仅在处理读负载时,而且在读写混合的高负载下的性能都取得了令人瞩目的进步。搜索关注“腾讯云数据库”官方微信,立得10元腾讯云无门槛代金券,体验移动端一键管理数据库,更有从初阶到高阶数据库实战教程等你来约!

Let's look at new features in MySQL 8.0, it looks not only take advantage of the latest software technology (such as Memcached improvements, remote management for better DevOps work performance, etc.), as well as hardware. For example, replacement with UTF8MB4 latin1 as the default character encoding. This means it needs more disk space, because UTF8 requires two bytes on a non-US-ASCII characters. Although this benchmark does not utilize use caching_sha2_password new authentication method, but it does not affect the performance of whether to use encryption. Once authenticated, it will be stored in the cache, which means that authentication is performed only once. So, if you are using only one user at a client, then no problem, and more secure than previous versions.

Because MySQL advantage of the latest hardware and software, so it will change the default variable. You can read more details.

Overall, the performance of MySQL 8.0 has far exceeded the MySQL 5.7.

+ Tencent cloud article has been published in various community channels

For more fresh dry technology, we can focus on Tencent community cloud - cloud plus community know almost agency official number and number

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12213684.html