Try to relieve MySQL write pressure and Master/Slave latency

Source: Internet
Author: User
Recently, the Unit needs to use MySQL to store a large amount of log data, resulting in high write pressure and high Master/Slave latency.

Recently, the Unit needs to use MySQL to store a large amount of log data, resulting in high write pressure and high Master/Slave latency.

Recently, the Unit needs to use MySQL to store a large amount of log data, resulting in high write pressure and high Master/Slave latency.

The specific environment is as follows:
MySQL 5.6.14
Server (single CPU, 6 cores, 12 threads, 32 GB memory)
Server hard drive (33 TB in total, Raid5)

The first attempt is to distribute IO
Generally, we use the/dbdata mount point to store data files.
/Data mount point stores log files (redo log file, binlog, relay log, etc)
The advantage is that random IO and sequential IO are separated without competition.

The disadvantage is that the IO usage of the/data mount point is generally low.

Of course, this is not a problem in general-purpose databases.
However, in an Insert-intensive database, the usage of the physical device where the data file is located will remain at 100%, and the usage of the physical device where the log file is located is generally about 5%, or even lower.

In this case, you may consider moving data files from some tables to the physical device where the log files are located to balance the use of IO resources.

MySQL datadir at/dbdata mount point,
The police_im_user_mac database actually points to the/data mount point through soft links.
In this way, some random I/O will be distributed to the/data mount point, reducing the pressure on the/dbdata mount point and reducing the CPU wait time.


The second attempt is to create a database and a table.
Because MySQL 5.6 adopts database-based multi-threaded replication.
The writing pressure on each table is very high, so the structure is modified. Each database has only one table, and multi-thread replication is started (in fact Multiple SQL threads), and transmission compression is set.

Slave_compressed_protocol = on (Master and Slave must be configured)
Slave_parallel_workers = 10

The third attempt is to modify the parameters.
Innodb_flush_log_at_trx_commit = 0
Innodb_support_xa = 0
Sync_binlog = 0
Increase innodb_buffer_pool_size
Set innodb_max_dirty_pages_pct to a greater value.
Set the redolog file size to a greater value.

After these modifications, the write pressure and Master/Slave latency are greatly mitigated. However, when slave_parallel_workers is started, if the replication interruption caused by an SQL thread exception occurs, the error 1062 may occur after the restoration.

This is because the thread synchronization mechanism of Multiple SQL threads may be faulty. Once the replication is interrupted, it is equivalent to an abnormal shutdown of Slave.

Of course, the processing method is the same.

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.