How can the scalability of MySQL be improved for BenchmarkSQL TPC-C testing? #7
wangbin579
started this conversation in
General
Replies: 0 comments
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
Current state of MySQL 5.7
MySQL 5.7 is not ideal in terms of scalability. The following figure illustrates the relationship between TPC-C throughput and concurrency in MySQL 5.7.39 under a specific configuration. This includes setting the transaction isolation level to Read Committed and adjusting the innodb_spin_wait_delay parameter to mitigate throughput degradation.
Figure 1. Scalability problems in MySQL 5.7.39 during BenchmarkSQL testing.
From the figure, it is evident that scalability problems significantly limit the increase in MySQL throughput. For example, after 100 concurrency, the throughput begins to decline.
To address the aforementioned performance collapse issue, Percona's thread pool was employed. The following figure illustrates the relationship between TPC-C throughput and concurrency after configuring the Percona thread pool.
Figure 2. Percona thread pool mitigates scalability problems in MySQL 5.7.39.
Although the thread pool introduces some overhead and peak performance has decreased, it has mitigated the issue of performance collapse under high concurrency.
Current state of MySQL 8.0
Let's take a look at the efforts MySQL 8.0 has made regarding scalability.
Redo Log Optimization
The first major improvement is redo log optimization [3].
A test comparing TPC-C throughput with different levels of concurrency before and after optimization was conducted. Specific details are shown in the following figure:
Figure 3. Impact of redo log optimization under different concurrency levels.
The results in the figure show a significant improvement in throughput at low concurrency levels.
Optimizing Lock-Sys Through Latch Sharding
The second major improvement is lock-sys optimization [5].
Based on the program before and after optimizing with lock-sys, using BenchmarkSQL to compare TPC-C throughput with concurrency, the specific results are as shown in the following figure:
Figure 4. Impact of lock-sys optimization under different concurrency levels.
From the figure, it can be seen that optimizing lock-sys significantly improves throughput under high concurrency conditions, while the effect is less pronounced under low concurrency due to fewer conflicts.
Latch Sharding for trx-sys
The third major improvement is latch sharding for trx-sys.
Based on these optimizations before and after, using BenchmarkSQL to compare TPC-C throughput with concurrency, the specific results are as shown in the following figure:
Figure 5. Impact of latch sharding in trx-sys under different concurrency levels.
From the figure, it can be seen that this improvement significantly enhances TPC-C throughput, reaching its peak at 200 concurrency. It is worth noting that the impact diminishes at 300 concurrency, primarily due to ongoing scalability problems in the trx-sys subsystem related to MVCC ReadView.
Refining MySQL 8.0
The remaining improvements are our independent enhancements.
Enhancements to MVCC ReadView
The first major improvement is the enhancement of the MVCC ReadView data structure [1].
Performance comparison tests were conducted to evaluate the effectiveness of the MVCC ReadView optimization. The figure below shows a comparison of TPC-C throughput with varying concurrency levels, before and after modifying the MVCC ReadView data structure.
Figure 6. Performance comparison before and after adopting the new hybrid data structure in NUMA.
From the figure, it is evident that this transformation primarily optimized scalability and improved MySQL's peak throughput in NUMA environments.
Avoiding Double Latch Problems
The second major improvement we made is addressing the double latch problem, where 'double latch' refers to the requirement for the global trx-sys latch by both view_open and view_close [1].
Using the MVCC ReadView optimized version, compare TPC-C throughput before and after the modifications. Details are shown in the following figure:
Figure 7. Performance improvement after eliminating the double latch bottleneck.
From the figure, it is evident that the modifications significantly improved scalability under high-concurrency conditions.
Transaction Throttling Mechanism
The final improvement is the implementation of a transaction throttling mechanism to guard against performance collapse under extreme concurrency [1] [2] [4].
The following figure depicts the TPC-C scalability stress test conducted after implementing transaction throttling. The test was performed in a scenario with NUMA BIOS disabled, limiting entry of up to 512 user threads into the transaction system.
Figure 8. Maximum TPC-C throughput in BenchmarkSQL with transaction throttling mechanisms.
From the figure, it is evident that implementing transaction throttling mechanisms significantly improves MySQL's scalability.
Summary
Overall, it is entirely feasible for MySQL to maintain performance without collapse at tens of thousands of concurrent connections in low-conflict scenarios of BenchmarkSQL TPC-C testing.
References:
Beta Was this translation helpful? Give feedback.
All reactions