How is the writing speed of Mysql storage formed?
MySQL storage structure diagram:

Analysis:
1. Read operation: memory read - ->cache cache read-->Disk physical read
The data read will be sent back in the above order.
2. Write operation: memory data is written directly into cache (very fast) --> write to disk
From the above, it can be seen that cache is one of the reasons why MySQL has fast reading and writing speed. played a key role.
1. Cache features:
1. Fast speed
2. Data loss during power failure
3. Limited capacity
2. Protect data security (prevent data loss due to unexpected power outage) Countermeasures:
In storage, add BBU (battery backup unit, which is the battery). After power outage, the data in the cache can be written to the disk to ensure that data will not be lost.
If the BBU is not provided or the BBU is broken, the memory data will not be written to the cache cache, but will be written directly to the disk; compared to writing to the memory, the speed of writing to the disk will be greatly reduced ( ten thousand times difference). At the same time, the slower "writing" takes up most of the "reading" bandwidth. Therefore, the BBU problem is a major influencing factor of poor read and write performance.
3. The cache cache capacity is limited
(4G, 8G, 16G, 32G). In order to keep the cache useful, the system will periodically write the cached data to the disk to avoid cache occupied.
2. Analysis of slow storage writing speed
Database-->Slow writing speed-->System hangs
Q: How to judge the slow writing speed?
A:
1. Suspected BBU problem
Monitor the BBU bug and solve it by restarting the BBU
2. The cache is full (similar to BBU is broken)
1. A large amount of written data fills up the cache cache. Judgment:
shell> iostat -x
mysql> show global status like 'handler_write ';
2. The speed of cache writing to disk is slow (the drainage speed is much slower than the water filling speed)
Hard disk I/O is abnormal and the load is too high: massive physical reads of the database (abnormal SQL ), judgment:
mysql> show status like 'Innodb_buffer_pool_reads';
3. Problem of poor storage performance
1. Poor storage device, update the device
2. Risks of disaster recovery synchronization, "No matter how good the engineer is, he is no match for Lan Xiang's excavator and migrant workers' hoes..."
3. About BBU
English abbreviation: BBU
English full name: Battery Backup Unit
Chinese full name: Battery Backup Unit, which is the battery
1. Function:
After power failure, the cache The data is written to the hard disk to ensure that the data will not be lost;
is a protection measure for brushing dirty data due to accidental power outage;
can provide data protection when the external power supply of the system fails. Backup power supply support to ensure the security of business data in the storage array.
2. Many storage devices will be equipped with BBU
BBU provides power for the RAID controller cache when there is a problem with the power supply. When the power is off, the BBU power can save the data in the cache in the controller for a certain period of time (depending on the BBU model). Users only need to restore normal power supply before the BBU power is exhausted (battery is limited), and the data in the cache can be completely written back to the RAID to avoid data loss caused by power outage.
It is a little different from the server battery. In the server, you can configure a battery when configuring the RAID card. After the system is powered off, the data in the memory can be maintained without losing it, but the time is limited, about 12 hours. About 12 hours, if it is not restored within 12 hours, the data in the memory will be lost;
3. Supercapacitor
The server also has a protection method called supercapacitor, which is also Matched with the RAID card, it can write the data in the cache to the capacitor after the server is powered off, and it will be saved permanently. It is similar to writing to a hard disk, but actually writing to the capacitor. You can understand it as writing to a USB flash drive. . It is better than batteries. Even if the server does not restore power after 12 hours, there will be no data loss.
The above is the detailed content of How is the writing speed of Mysql storage formed?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.
