Wednesday, 11 November, 2015
This article is continuing the MySQL 5.7 Performance story, started from 1.6M
QPS details post, and followed by 1M
QPS OLTP_RO article. However, the current story will not be mostly
about MySQL 5.7, but also about announced on the same time MariaDB 10.1
So far, MySQL Team was proud to show 1.6M QPS on Point-Select (SQL) queries, and MariaDB 10.1 GA announce was also claiming an ability to reach 1M QPS, also on Point-Selects, but on POWER8 HW. And I may be only happy for MariaDB team for their progress on POWER systems, except just one small detail related to how their 1M QPS result was obtained..
But first of all, what are these Point-Selects and what is so special with this workload ?..
- point-select is representing a single SQL query reading a row by its primary key (PK)
- a workload based on such queries is very similar to any generic key-value store solution, but via SQL
- usually a point-select is extremely fast and doing a round-trip from end-to-end in database engine
- so any internals overhead in engine code, any contentions, any scalability limits are seen very quickly..
- historically such kind of workload did not scale very well on MySQL/InnoDB tandem..
- on MySQL Server side there was a huge amount of internal locks around every SQL query execution
- while on the InnoDB side there was a huge general overhead related to transactions management + related locks..
- the first step ahead was made here in MySQL 5.6
- but the real changes came only with MySQL 5.7 ;-)
So, our 1.6M QPS on Point-Selects with MySQL 5.7 we were able to reach under the most heavy conditions :
- each Sysbench "client" thread is executing a single point-select query per iteration
- no transactions clauses used, no grouping..
- single query round-trip is driving the response time latency
- a fair simulation of a key-value store by SQL access
and the Sysbench execution command line is looking then as the following:
LD_PRELOAD=/usr/lib64/libjemalloc.so /BMK/sysbench --num-threads=$1 \ --test=oltp --oltp-table-size=1000000 \ --oltp-dist-type=uniform --oltp-table-name=sbtest_1M_$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 &
Now, about 1M QPS result published on MariaDB 10.1 :
- if you'll look in details published in their article, instead of --oltp-point-selects=1 the --oltp-point-selects=1000 was used
- and these 1K point-selects then grouped and executed within a single transaction!.. (--oltp-skip-trx=off is used (default))
Adapting these test conditions to my Sysbench command line this will then give the following :
LD_PRELOAD=/usr/lib64/libjemalloc.so /BMK/sysbench --num-threads=$1 \ --test=oltp --oltp-table-size=1000000 \ --oltp-dist-type=uniform --oltp-table-name=sbtest_1M_$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=1000 --oltp-simple-ranges=0 --oltp-sum-ranges=0 \ --oltp-order-ranges=0 --oltp-distinct-ranges=0 --oltp-skip-trx=off \ --oltp-read-only=on run > /tmp/test_$n.log &
How does this change the initial workload test case ?
- in one word : completely ;-)
- by grouping 1000 queries within a single transaction we're lowering a lot the whole related transaction locks..
- and as the result, an overall QPS numbers are growing! ;-)
- but did you see many real cases when a single MySQL session is grouping 1000 SELECT queries within a single transaction ?..
- I may still imagine a need to run several SELECTs within a single transaction to guarantee a read consistency...
- but such kind of queries are usually not short ones, so not really good to show a high QPS ;-)
- but well, even they are really short as point-selects.. -- what kind of application will run them by 1000 in a single shot ?..
- such kind of a "workaround" we proposed yet to our users when started to ship MySQL 5.6, but always mentioned that this is as a workaround, not a final solution (as this could help when you're really have many fast SELECTs and you can really group then within a single transaction without breaking your apps logic).. -- but as soon as potential amount of SELECTs to group is small, the transaction overhead is quickly eating your gain..
- so, the real solution here is - MySQL 5.7 ;-)
Let me show now all this by example, using the test scenario as proposed by MariaDB and just vary the amount of point-selects executed within a single transaction. Let's start with 50 point-selects (which is already too much as to me, but well) :
50 point-selects in transaction :
- MySQL 5.7 is still reaching its 1.6M QPS as well
- MariaDB 10.1 is reaching over 1.4M QPS (so, not only on Power while running within a "workaround" test conditions)..
Then the following are the results with 25, 10, and 5 point-selects executed within the same transaction :
25 point-selects in transaction :
10 point-selects in transaction :
5 point-selects in transaction :
- as you can see, less queries executed within the same single transaction - lower QPS is reached..
- so, MySQL 5.7 is going from 1.6M QPS to 1.2M QPS
- while MariaDB 10.1 is going from 1.4M QPS to just 600K QPS..
On the last test, with 5 point-selects within a transaction the lower QPS is also impacted by round-trips of BEGIN and COMMIT statements around transaction.. What the result will be if I'll not use transactions?
5 point-selects without transaction :
- as you can see, MySQL 5.7 is going back to its 1.6M QPS
- while MariaDB 10.1 is going yet more down to just slightly higher than 400K QPS only..
To get a better understanding of the transaction statements impact let's get a look on the following graph comparing MySQL 5.7 in the last test with 5 point-selects within transaction (left side) -vs- 5 point-selects without transaction (right side) :
- as you can see in overall amount of Queries/sec the left side is even higher! (BEGIN and COMMIT are also counted as queries by MySQL stats)
- and as we're wasting CPU cycles to process BEGIN and COMMIT - we're doing less SELECTs as the result..
- while on the right side (without transactions) the whole CPU time is spent for SELECTs, and we're reaching 1.6M QPS then ;-)
- it's up to you to consider whenever MariaDB 10.1 is really reaching 1M QPS, or 400K QPS only ;-))
- however, what is important for me here after all : you can really reach 1.6M QPS with MySQL 5.7 whatever the test conditions are used here ;-))
Then, to avoid any kind of speculations about new Intel chips as the reason of excellent MySQL 5.7 scalability results, let me just remind you about the results obtained on the old severs (32cores-HT and 40cores-HT), running the old Intel CPUs (similar 4CPU sockets each, but just 8cores-HT and 10cores-HT per CPU socket, both are running at 2300Mhz frequency). The following are the results obtained on the same Sysbench RO Point-Select workload :
- single point-select per iteration, no transactions
- 8 tables of 1M rows are used in the first test
- 1 table of 10M rows is used in the second test
- as you can see there is a huge gap between MySQL 5.7 and any other engine on 32, 40 and 72cores-HT HW..
- the gap on 72cores-HT HW is way bigger only because MySQL 5.7 is continuing to scale and reaching a yet more higher result, while all other engines are already reached their limits and cannot go anymore further..
- NOTE : only MySQL 5.7 is showing near the same QPS results on both 8-tables and 1-table workloads
INSTEAD OF SUMMARY :
From where is coming such a great scalability gain in MySQL 5.7 ?
- first of all it's a continuous improvement process started yet since MySQL 5.6 with kernel_mutex split + RO transactions on InnoDB side, and many various internal contentions improvements on the MySQL Server side
- then, on MySQL 5.7 InnoDB side : a whole transactions management redesign, improved lock management, redesigned index locking, etc...
- MySQL 5.7 Server side : resolved contentions around MDL, THR_lock, LOCK_grant, LOCK_plugin, and all other "next-level" locks fixes.. -- in fact for today there is no more any known/visible internal contentions in MySQL 5.7 except coming from InnoDB ;-)
- so far, all the credit is to our great MySQL Engineering Team! (all the listed stuff above is related to fundamental changes invented and implemented by our Engineering, taking us months and years of heavy work)..
and, of course, huge thanks to MySQL Community for all feedback we
have about ;-)
When MariaDB will be able to scale as far as MySQL 5.7 ?
- when it'll move to InnoDB SE from MySQL 5.7
and when on its Server side the lock contention in the "lock free"
table definition cache code will be fixed ;-)
When Percona Server will scale as far as MySQL 5.7 ?
- since Percona Server will move to the MySQL 5.7 code base
- and XtraDB moves to InnoDB code base from MySQL 5.7
not before ;-)
- or both are re:implementing all these changes in their 5.6 / 10.1 code ;-)
- And hope I don't say you here any news, because the same story was already with MySQL 5.6 too, but who cares? ;-))
Well, what to say.. -- #MySQL 5.7 rocks! ;-)
blog comments powered by DisqusNote: if you don't see any "comment" dialog above, try to access this page with another web browser, or google for known issues on your browser and DISQUS..