my.cnf parameter configuration to optimize InnoDB engine performance

my.cnf parameter configuration to optimize InnoDB engine performance

I have read countless my.cnf configurations on the Internet, and most of the configurations mentioned are nothing more than these:

1. innodb_buffer_pool_size
2. innodb_log_file_size
3. innodb_log_buffer_size
4. innodb_flush_log_at_trx_commit

Then I wrote two examples, one single-threaded and one multi-threaded, to test whether the performance was improved by changing the configuration parameters. The result shows that only innodb_flush_log_at_trx_commit can improve performance. For parameters 1, 2, and 3, whether one of them is turned on or all three are adjusted at the same time, the test performance is not affected. I thought about it and it might be because the amount of my test data was not large enough. I will test these three parameters with a larger amount of data when conditions permit.

Here is a detailed description of innodb_flush_log_at_trx_commit:

If innodb_flush_log_at_trx_commit is set to 0, the log buffer will be written to the log file once per second, and the flush (brush to disk) operation of the log file will be performed simultaneously. In this mode, when a transaction is committed, the operation of writing to disk is not actively triggered.
If innodb_flush_log_at_trx_commit is set to 1, MySQL will write the data in the log buffer to the log file and flush it to disk each time a transaction is committed.
If innodb_flush_log_at_trx_commit is set to 2, MySQL will write the log buffer data to the log file each time a transaction is committed. However, the flush operation does not occur simultaneously. In this mode, MySQL will perform a flush operation once per second.

result :

When set to 0, this mode is the fastest, but less secure. A crash of the mysqld process will result in the loss of all transaction data in the last second.
When set to 1, this mode is the safest, but also the slowest. In the event of a mysqld service crash or a server host crash, the binary log may lose at most one statement or one transaction.
When set to 2, this mode is faster and safer than 0. All transaction data in the last second may be lost only if the operating system crashes or the system loses power.

Note : Due to process scheduling issues, this "flush operation once per second" is not guaranteed to be 100% "per second".

Conclusion : The speed is similar when innodb_flush_log_at_trx_commit is set to 0 or 2, and both are much faster than when it is set to 1.

This reminds me of the difference between InnoDB and MyISAM engines. The advantage of InnoDB is that it is faster than MyISAM in concurrent processing. The number of my thread pools is set according to the number of CPU threads. Then I set the number of thread pools to be larger, larger, and larger than the number of CPU threads. As a result, the performance of my test program improved again. I was drunk. It turned out that my understanding of thread pools was too superficial. Optimal thread pool size

You may also be interested in:
  • How to configure the My.ini file when installing MySQL5.6.17 database
  • MySql 5.7.20 installation and configuration of data and my.ini files
  • MySQL 5.6 & 5.7 Optimal Configuration File Template (my.ini)
  • MySQL service performance optimization—my.cnf_my.ini configuration instructions (16G memory)
  • MySQL optimization configuration file my.ini (discuz forum)
  • Detailed analysis of MySQL configuration parameters my.ini/my.cnf
  • Detailed explanation of MySQL my.ini configuration file
  • Solution to the problem that the configuration file my.cnf in MySQL cannot be started due to permission issues
  • mysql method to view the currently used configuration file my.cnf (recommended)
  • Solution to the ineffectiveness of modifying MySQL my.cnf configuration
  • MySQL 5.5.x my.cnf parameter configuration optimization details
  • Detailed explanation of MySQL configuration file my.cnf optimization (mysql5.5)
  • MySQL performance optimization road --- modify the configuration file my.cnf
  • MariaDB (MySQL branch) my.cnf configuration file Chinese annotated version
  • MySQL configuration file my.cnf parameter optimization and Chinese detailed explanation
  • Detailed explanation of MySQL configuration file my.cnf in Chinese, with sharing of MySQL performance optimization methods
  • Comparison of the Chinese version of the MySQL configuration file my.cnf
  • MySQL configuration file my.cnf example most detailed translation
  • Detailed explanation of the my.ini Chinese configuration scheme for MySql optimization: InnoDB, 4GB memory, and multiple queries

<<:  WeChat applet implements text scrolling

>>:  Methods to enhance access control security in Linux kernel

Recommend

Is your website suitable for IE8?

During the Olympic Games, IE 8 Beta 2 will be rele...

CenterOS7 installation and configuration environment jdk1.8 tutorial

1. Uninstall the JDK that comes with centeros fir...

How to implement logic reuse with Vue3 composition API

Composition API implements logic reuse steps: Ext...

Installation tutorial of MySQL 5.1 and 5.7 under Linux

The operating system for the following content is...

How to change the domestic image source for Docker

Configure the accelerator for the Docker daemon S...

JavaScript implements large file upload processing

Many times when we process file uploads, such as ...

How to use Cron Jobs to execute PHP regularly under Cpanel

Open the cpanel management backend, under the &qu...

Detailed explanation of the code for implementing linear gradients with CSS3

Preface The gradient of the old version of the br...

Detailed steps for configuring Tomcat server in IDEA 2020

The steps for configuring Tomcat in IDEA 2020 are...

CSS+HTML to realize the top navigation bar function

Implementation of navigation bar, fixed top navig...

React new version life cycle hook function and usage detailed explanation

Compared with the old life cycle Three hooks are ...

How to set static IP in CentOS7 on VirtualBox6 and what to note

Install CentOS 7 after installing VirtualBox. I w...