MySQL Performance: 500,000 queries per second with MySQL 5.7

Review the MySQL/InnoDB improvement history. You can easily find out. In MySQL 5.6 stable release, read-only speedup  has never been so fast, it is easy to understand, and has good scalability in read-only (RO). Also looking forward to it reaching a higher level on read+write (RW). (Especially when reading data is the main job of the database)


However. We are also very happy with the performance of RO in MySQL 5.6. In version 5.7, the main work is concentrated on read+write (RW), because the processing of big data has not yet met our expectations. But RW relies on RO. Ability to increase speed again. The InnoDB team has made strong efforts to optimize the performance per second of version 5.7 through continuous improvement.

The following will explain to you in order
you want paws
you want paws
translated 3 years ago

1 person

 

Great  translation!

In fact, read-only workloads control internal linking in MySQL in two ways:

  • With a single table: MDL, trx_sys and lock_sys (InnoDB)
  • Multiple tables: trx_sys and lock_sys (mainly InnoDB)

The workload of any fast single-table range test is mostly locked due to MDL linking. And multiple tables will be limited due to InnoDB internals (different tables will be protected by different MDL locks, so the link bottleneck in MDL will be lower in this case). But again, it also depends on the size of the workload - a measure of more read-only work than normal will perform better in MySQL 5.6 (eg Sysbench OLTP_RO), while less workload and faster queries (eg Sysbench Point-Selects (to fetch a record with a foreign key)) will make all the links difficult and can only be measured in 16-core-HT, and 32-core is poor.. but anything like Point-Select The workload of the test will be to work with all MySQL internals that will allow you to see the maximum performance possible (start with SQL parser, terminate with row values).. at your given MySQL version and given HW When configured, this may also reach the maximum SQL queries per second (QPS) rate.

yale8848
Translated by yale8848
3 years ago

1 person

 

Great  translation!

The best result we got on Mysql5.6 was 250,000 queries per second, which was also the best result we got by using SQL query on Mysql/InnoDb during that time.

Of course, such a high speed can only be achieved by using the 'read-only transaction' function (a new function on Mysql5.6); in addition, AUTOCOMMIT=1 needs to be used, otherwise the CPU will be easily wasted on starting transactions and committing transactions, You will actually lose the overall performance of the system.

So, the first improvement introduced on Mysql5.7 is the 'auto-discovery of read-only transactions' (actually every InnoDb transaction is considered read-only until there is a DML declaration outside of it) feature --- , which greatly simplifies the read-only transaction function, saving users and developers time, they no longer have to manage whether to use the read-only transaction function. However, using this feature you still can't achieve the best possible query rate per second of Mysql, because the CPU time is still wasted in the process of opening and closing the state of the transaction.

Wang Ruiping
Translated by Wang Ruiping
3 years ago

1 person

 

Great  translation!

At the same time, Percona uses different solutions to solve the problem of "transaction list" management (TRX-list) and slow trx_sys mutex link in InnoDB. Percona's solution works well under high load with transactional Point-Selects, but MySQL 5.7 is mediocre (but I won't post results for 5.7 because its code is not public)... So, at least I can now Do some comparisons:

Observation results:

  • Tested with the same Roint-Select-TRX read only (with transactions) on 8 tables in MySQL 5.6, Percona 5.5 and MySQL 5.7 (result from May 2013)
  • At the same time you can see that we are still far from the peak 250k/s result in the same 16-core-HT configuration.
  • MySQL 5.6 has extended link time in trx_sys exclusive access, and requests per second will decrease since 64 users.
  • Percona 5.5 can maintain the load for a long time, and the requests per second start to decrease at 512 users
  • When MySQL 5.7 has been maintained for a while, requests per second have not decreased (you can't see it in this picture for more concurrent users)...
yale8848
Translated by yale8848
3 years ago

1 person

 

Great  translation!

Clearly, however, transactions should be avoided if the maximum potential query-per-second rate is desired with MySQL.

Let's take a look at this is our maximum query rate per second in May 2013.

Tested with eight tables at the same point, but nothing using MySQL 5.6:

Observed:

  • The above test is to keep MySQL 5.6 always running on 16 cores, then 16 cores-HT, 32 cores, 32 cores-HT.
  • As you can see, the maximum query per second rate is larger than expected -- 275,000 per second on MySQL
  • The largest result has been reached 16-core-HT.
  • However the results on 32 cores are not as good as on 16 cores-HT (due to competing interrupts, a configuration with 2 CPU threads in the same core manages thread contention better - so true concurrency is still preserved at 16 threads , not on 32 cores)
NCThinker
Translated by NCThinker
3 years ago

4人顶

 

 翻译的不错哦!

而在MySQL5.7上做同样的测试却看起来大有不同,因为在5.7中lock_sys互斥链接的时间段已经很低了,同时trx_sys互斥相关代码也得到第一次变化的情形:

观察结果:

  • 首先你可以看到5.7在同样的16核-HT配置下的性能已经比5.6的要好
  • 之后,在32核配置下没有明显的增强!
  • 在32核-HT配置下达到了35万/秒的最大请求!
  • 从上面特殊(具有攻击性)只读负载测试的情况下可以容易看出我们在32核中得到的结果要比16的好,同时我们还没有启动超线程(在32核-HT)...牛吧!;-)
yale8848
yale8848
翻译于 3年前

2人顶

 

 翻译的不错哦!

从另一方面来讲,仍然有改进的空间这点还是很清晰的。有关trx_sys的争用仍然在持续。我们没有充分的使用CPU的能力来做有用的工作(仍然有许多CPU周期用在锁的轮转)...不过现在的结果比以前好多了,并且比5.6好很多,因此没有理由继续挖掘来提高这方面的性能,我们主要集中在我们曾经花费了巨大的空间的读写负载的性能提高上。

到了5月底,也就是我们的性能会议期间,Sunny给try_sys互斥争用增加了几个新的更改,从那以后最大的每秒可进行的查询(QPS)可达到375K!这是不是对5.7进行了足够的性能提高,对吗?;-)

同时,我们继续与建议用其他方式管理TRX列表的Percona团队交换了意见,他们的方案看起来非常有趣,不过在5.5上,这样的代码却不能展示出更高的每秒可进行的查询数(QPS),而且在5.6上的这样代码(曾经测试过Percona Server 5.6)最大的每秒可进行的查询数(QPS)也不会比在MySQL 5.6上大。然而,讨论涉及到一个有趣的观点:如果同时有一些读写负载在运行的话,它对只读性能有什么影响呢?...而且,即使在同样的测试条件下MySQL 5.7代码仍然运行的要好一些,效果是非常明显的(你可以在这儿查看我的分析,然而,再次说明一下,这段时间内我不能展示5.7上的结果,因为它的代码还没有对大众公布-也许会在以后的一篇文章中给出)..

what time people
几点人
翻译于 3年前

3人顶

 

 翻译的不错哦!

由于这儿同时对任何纯粹的读写负载也有影响,因此有足够的动机以Sunnys很长时间所期待的那样重新写整个TRX列表相关的代码,然而,这种经历简直让人痴迷!

;-)) 日复一日,我们很高兴的看到我们的每秒可进行的查询图逐渐变高,直到在同一个32核的超线程服务器上达到了每秒可进行的查询440K!

5.7开发里程碑发布2上进行的Select 8个表所得到的结果数

不需要说明..;-))

然而,有一个小小的令人奇怪的地方-我们试图与Sunny通过不同的工具分析所有瓶颈和代码更改所带来的影响。而且在某些测试里,令我吃惊的是Sunny观察到比我更高的每秒可进行的查询数..这个“奇异之处”与下面因素相关:

  • 在高负载下,现在的5.7代码都运行在接近硬件极限(主要是CPU)的位置,因此每条指令都非常重要!
  • 如果使用的Unix套接字或者IP端口,那么区分就会非常明显!
  • Sysbench自身使用了30%的CPU时间,不过同样的测试负载使用的是(具有更短的代码路径的)老版本的Sysbench的话,它将只使用20%CPU,剩余的10%用在MySQL服务器上。
  • 因此,同样测试负载的情况下,使用Unix套接字而不是IP 端口,并且使用Sysbench-0.4.8替代Sysbench-0.4.13的话,我们将得到每秒可进行的查询数超过500K!-很容易,不是吗?;-))
what time people
几点人
翻译于 3年前

2人顶

 

 翻译的不错哦!

让我们来比较“之前”和“之后”的差异

观察结果:

  • 通过Sysbench降低了CPU的使用率。
  • 在MySQL服务器上具有更高的CPU可用性。
  • 我们实现了50万每秒查询。

还有什么呢?

我可能只提到:kudos Sunny和整个MySQL的开发团队;

让我们看一下现在选择8张表工作负载的情况下的最大每秒查询。

  • MySQL-5.7.2 (DMR2)
  • MySQL-5.6.14
  • MySQL-5.5.33
  • Percona Server 5.6.13-rc60.5
  • Percona Server 5.5.33-rel31.1
  • MariaDB-10.0.4
  • MariaDB-5.5.32

每个引擎都在以下配置下进行测试:

  • CPU taskset: 8核-HT,16核,16核-HT,32核,32核-HT
  • 并发会话数:8,16,32 ... 1024
  • InnoDB自旋等待延时:6,96
NCThinker
NCThinker
翻译于 3年前

4人顶

 

 翻译的不错哦!

最好的结果是来自任意两个特定的组合间的比较。通过对数据库引擎的比较,我得到了下面的一个图表,这个图表我在以前的文章中已经提到过了。

下面是一些评论:

  • 对Mysql5.7的巨大差距结果不需要做过多的评论,因为这是很明显的。
  • 那么,有趣的是基于MySQL5.5的代码库引擎没有任何的接近MySQL5.6的结果。
  • 这已经证实了在使用MySQL5.6的代码库引擎之后,Percona Server达到了MySQL5.6的水平,然而MariaDB-10仍然还在探索的路上。
  • 因此,毫无疑问,MySQL5.6是代码的基石!
  • MySQL5.7是在MySQL5.6基础上的再一次优化扩展。

具有什么样的扩展性呢?

答案是简单的:MySQL5.7是唯一在此基础上进行扩展的。

如果使用ip端口和一个重量级的Sysbench-0.4.13,会得到如下的结果:

QPS只是稍微的略低一点,但是总体的趋势是完全一样的。

可扩展性也是非常的相似:

 

更多的结果将会出来,敬请期待;

注意:对一个单表绑定过多的工作负载是不好的:

  • 减少InnoDB间的争论使得其他的争论更加的明显。
  • 当负载是绑定在一张单表上时候,MDL的争论将变得更加主导。
  • 这是预期希望的,我们在下一个DMRS上将保持不变。

 

NCThinker
NCThinker
翻译于 3年前

3人顶

 

 翻译的不错哦!

还有很多挑战摆在我们面前;-)

作为参考,我上述测试的硬件配置信息如下:
  • Server : 32cores-HT (bi-thread) Intel 2300Mhz, 128GB RAM
  • OS : Oracle Linux 6.2
  • FS : 启用"noatime,nodiratime,nobarrier"挂载的EXT4

my.conf:
 max_connections=4000
 key_buffer_size=200M
 low_priority_updates=1
 table_open_cache = 8000
 back_log=1500
 query_cache_type=0
 table_open_cache_instances=16

# files
 innodb_file_per_table
 innodb_log_file_size=1024M
 innodb_log_files_in_group = 3
 innodb_open_files=4000

# buffers
 innodb_buffer_pool_size=32000M
 innodb_buffer_pool_instances=32
 innodb_additional_mem_pool_size=20M
 innodb_log_buffer_size=64M
 join_buffer_size=32K
 sort_buffer_size=32K

# innodb
 innodb_checksums=0
 innodb_doublewrite=0
 innodb_support_xa=0
 innodb_thread_concurrency=0
 innodb_flush_log_at_trx_commit=2
 innodb_max_dirty_pages_pct=50
 innodb_use_native_aio=1
 innodb_stats_persistent = 1
 innodb_spin_wait_delay= 6 / 96

# perf special
 innodb_adaptive_flushing = 1
 innodb_flush_neighbors = 0
 innodb_read_io_threads = 4
 innodb_write_io_threads = 4
 innodb_io_capacity = 4000
 innodb_purge_threads=1
 innodb_adaptive_hash_index=0

# monitoring
 innodb_monitor_enable = '%'
 performance_schema=OFF

如果你需要的话,Linux Sysbench的二进制版本在这里

  • Sysbench-0.4.13-lux86
  • Sysbench-0.4.8-lux86

使用UNIX socket来运行Point-Selects测试的Sysbench命令如下(在parallel中启动8个进程):

LD_PRELOAD=/usr/lib64/libjemalloc.so /BMK/sysbench-0.4.8 --num-threads=$1 --test=oltp --oltp-table-size=10000000 \
        --oltp-dist-type=uniform --oltp-table-name=sbtest_10M_$n \
        --max-requests=0 --max-time=$2 --mysql-socket=/SSD_raid0/mysql.sock \
        --mysql-user=dim --mysql-password=dim --mysql-db=sysbench \
        --mysql-table-engine=INNODB  --db-driver=mysql \
        --oltp-point-selects=1 --oltp-simple-ranges=0 --oltp-sum-ranges=0 \
        --oltp-order-ranges=0 --oltp-distinct-ranges=0 --oltp-skip-trx=on \
        --oltp-read-only=on run  > /tmp/test_$n.log &

使用IP端口来运行Point-Selects测试的Sysbench命令如下(在parallel中启动8个进程):

LD_PRELOAD=/usr/lib64/libjemalloc.so /BMK/sysbench-0.4.13 --num-threads=$1 --test=oltp --oltp-table-size=10000000 \
        --oltp-dist-type=uniform --oltp-table-name=sbtest_10M_$n \
        --max-requests=0 --max-time=$2 --mysql-host=127.0.0.1 --mysql-port=5700 \
        --mysql-user=dim --mysql-password=dim --mysql-db=sysbench \
        --mysql-table-engine=INNODB  --db-driver=mysql \
        --oltp-point-selects=1 --oltp-simple-ranges=0 --oltp-sum-ranges=0 \
        --oltp-order-ranges=0 --oltp-distinct-ranges=0 --oltp-skip-trx=on \
        --oltp-read-only=on run  > /tmp/test_$n.log &

Good luck to you,
-Dimitri

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326485136&siteId=291194637