Detailed explanation of GaussDB for MySQL performance optimization

Detailed explanation of GaussDB for MySQL performance optimization

background

Let's first look at the general process of transaction submission in MySQL 8.0

The above process is an implementation of the WAL principle in MySQL 8.0. This process means that the submission of any transaction must complete the write buffer and flush to disk processes.

However, there is a problem in this process: the CPU of each server is limited, and the number of threads that the server can process is also limited. So when the number of concurrent transactions in our business is much larger than the number that our server can process in parallel, the subsequent transactions can only be processed after the previous transactions are submitted. Before that, they could do nothing. Therefore, in a high-concurrency scenario, how to further improve thread utilization is a key to writing high-concurrency transactions.

Inspiration comes from life

An optimization is not imagined out of thin air; sometimes, it often comes from real life. Next, let's take a look at an example around us that is very similar to the transaction submission process: express delivery.

In today’s express delivery, generally one courier is responsible for an area. When express delivery first started to become popular, the quantity was small, so one courier could basically complete the delivery within the specified time.

However, as the number of express deliveries increases, a courier has to spend a long time delivering in one community before reaching the next community, which often results in the courier being unable to deliver on time. Driven by this problem, a new industry began to emerge - express delivery stations.

Optimization principles of express delivery

Next, let’s take a look at what problems the express delivery station actually solves.

In the express delivery process, the most time-consuming part is not loading or unloading, but phone calls and waiting. The time it takes to deliver to a community depends on the time when the last person comes to pick up the package. After the last person collects the money, the courier can't do anything else except making a phone call (there is no way to notify the people in the next community because the time when the last person comes to pick up the package is uncertain). Then this waiting time is a waste for the courier.

Express delivery stations can solve this problem to a large extent. After the courier arrives, he only needs to unload the express and go to the next community. The rest of the work can be done by the station staff, which greatly improves the courier's delivery efficiency.

analyze

Going back to the database, if we regard the Transaction thread as a courier and the file on the storage as the person who picks up the courier, we will find that the two are very similar. So can we optimize the transaction processing process like we optimize express delivery? The answer is yes.

According to the optimization principle of express delivery stations, we know that express delivery stations save couriers the time of waiting for customers to pick up the goods. So, is there any waiting process in the transaction processing process? The answer is yes, storage IO is a longer wait. Developers with rich experience in database use all know that the disk IO performance of waiting for redo logs to be written to storage largely determines the write performance of the database. For modern databases, especially for databases like GaussDB (for MySQL) that separate computing from storage, the storage IO time accounts for a large proportion of the total transaction processing time. Although log buffer merge writes can improve the overall throughput in concurrent situations, if these threads can do other things (such as processing other waiting transactions) during the waiting time for IO. Then there will be further performance improvements.

Optimization of GaussDB (for MySQL)

Now that we have found the waiting point, we can create a "express delivery station" for the database, just like the optimization method of express delivery, and let the "express delivery station" do the waiting, while the transaction thread can handle other waiting transactions, so that the CPU will not be "idle".

As shown in Figure 5, GaussDB (for MySQL) can commit a transaction after the flush to disk action of the redo log is completed. However, it does not respond to the client at this time, but directly processes the next transaction. At the same time, a small number of "post commit worker threads" are used to wait for the completion of log writing in batches (the waiting process does not actually occupy the CPU) and respond to the client. This allows the "waiting" and "processing of the next transaction" to be parallelized, keeping the CPU "busy".

Actual test

According to actual tests, under the standard sysbench write model, when Post Commit is not used, the maximum performance is about 350,000 QPS. After using Post Commit, the QPS can reach more than 420,000, which improves the write performance by 20%.

The above is a detailed explanation of GaussDB for MySQL performance optimization. For more information about GaussDB for MySQL performance optimization, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Example of how to configure the MySQL database timeout setting
  • How to run MySQL in Docker environment and enable Binlog to configure master-slave synchronization
  • MySQL database backup setting delayed backup method (MySQL master-slave configuration)
  • MySQL uses indexes to optimize performance
  • MySQL optimizes database performance through show status and explain analysis
  • Introduction to MySQL database performance optimization
  • mysql configuration connection parameter settings and performance optimization

<<:  Can you do all the web page making test questions?

>>:  HTML thead tag definition and usage detailed introduction

Recommend

JavaScript Array Methods - Systematic Summary and Detailed Explanation

Table of contents Common array methods Adding and...

Detailed explanation of destructuring assignment syntax in Javascript

Preface The "destructuring assignment syntax...

Detailed explanation of MySQL DEFINER usage

Table of contents Preface: 1.Brief introduction t...

How to find and delete duplicate rows in MySQL

Table of contents 1. How to find duplicate rows 2...

How to modify the user and group of a file in Linux

In Linux, when a file is created, the owner of th...

Detailed explanation of Javascript string methods

Table of contents String length: length charAt() ...

Docker removes abnormal container operations

This rookie encountered such a problem when he ju...

Tutorial on how to install and use Ceph distributed software under Linux

Table of contents Preface 1. Basic Environment 1....

Example usage of JavaScript tamper-proof object

Table of contents javascript tamper-proof object ...

Detailed explanation of MySql installation and login

Check if MySQL is already installed in Linux sudo...

Analysis of MySQL query sorting and query aggregation function usage

This article uses examples to illustrate the use ...

Vue virtual Dom to real Dom conversion

There is another tree structure Javascript object...

A brief discussion on the CSS overflow mechanism

Why do you need to learn CSS overflow mechanism i...

Detailed discussion of the character order of mysql order by in (recommended)

//MySQL statement SELECT * FROM `MyTable` WHERE `...

Fabric.js implements DIY postcard function

This article shares the specific code of fabricjs...