Finally got the MySQL performance optimization and high-availability architecture practical notes compiled and summarized by the Tencent Cloud architect, too strong!

As one of the most popular open source database software, MySQL database software has been widely known. Large websites such as Facebook, Tencent, and Taobao, which are currently very popular, all use MySQL databases.

Most business scenarios in the Internet industry have very obvious characteristics: a large number of users, a large amount of triggered data, high concurrency, and moderate business complexity. The initial positioning of MySQL database products is the data service of Web applications, so almost all Internet companies use MySQL database products, and many companies almost all use the data services provided by MySQL.

Choosing open source products is the mainstream choice of the country and enterprises. The open source MySQL database is the most widely used at home and abroad and has the most technical personnel in the industry. It has become the most critical relational database product in the "de-IOE" distributed technology architecture. The database system is the core of the IT business system, and its high availability and disaster tolerance capabilities play a vital role in the continuity and data integrity of the entire business system, and it is the cornerstone of the normal operation of an enterprise.

Few Internet companies do not use MySQL, and domestic Internet giants are using MySQL on a large scale. If MySQL is likened to a dragon in the database world, performance optimization and high-availability architecture design practices are the finishing touches.

This article will explain in detail the MySQL 5.7 high availability and performance optimization technology, carefully sort out ideas, and combine with real production cases, explain the actual deployment through the principle, and help readers apply the knowledge points learned to actual work.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

This article is suitable for MySQL database learners, MySQL database developers and MySQL database administrators who have a certain foundation to read.

table of Contents

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

Introduction to MySQL architecture;

As the current mainstream database for Internet work, MySQL has an unshakable position. The ranking of DB-Engines is cited a lot in the industry, and the authority is also high. The top three are still Oracle, MySQL, and Microsoft SQL Server. MySQL is a database that came out in the 1990s. The entire architecture has absorbed some of the good features of other databases, and has also eliminated the bad points. The entire architecture is relatively stable and relatively simple. The architecture of MySQL can be applied in a variety of different scenarios. Facebook, Twitter, Google, Tencent, Ali, etc. are all using MySQL to store massive amounts of data.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

lnnoDB storage engine architecture;

Starting from MySQL 5.5, InnoDB is the default table storage engine, which is characterized by supporting transactions, supporting data row locks, supporting multiple versions of concurrent MVCC, and supporting foreign keys.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

MySQL transactions and locks;

Locking in a computer is a mechanism for coordinating multiple processes or threads to access a certain resource concurrently. In the database, in addition to contention for traditional computing resources (CPU, RAM, I/O, etc.), data is also a resource that can be shared and accessed by many users. The database will automatically lock the corresponding objects when performing concurrent access to ensure the consistency of concurrent access to the data. The InnoDB storage engine supports row-level locks and table-level locks, but row-level locks are used by default.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

SQL statement performance optimization ;

Speaking of SQL statement performance optimization, I believe everyone knows some simple techniques: do not use SELECT *, do not use NULL fields, use indexes reasonably, select appropriate data types for fields, etc. Do you really understand these optimization techniques? Do you understand the working principle behind it? This chapter explains the principles behind these optimization suggestions from a theoretical and practical perspective.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

MySQL server is fully optimized ;

Most of the large and medium-sized Internet websites that use the Linux operating system are using MySQL as the back-end database service, so how to optimize the MySQL server is what we want to study. Now MySQL version 5.7 has better optimizations for multi-core CPUs, solid state drives, and lock mechanisms. In addition, MySQL 5.7 version has improved the optimizer a lot. For example, the in statement subquery of MySQL 5.7 can use index range scan mode, Union all no longer generates temporary tables, and the sorting efficiency is also improved. We have fully optimized the MySQL server from several aspects including the enhancement of the storage engine of MySQL 5.7, optimization of hardware, operating system, configuration parameters, and optimization of design specifications.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

MySQL performance monitoring;

MySQL is accepted by more and more enterprises. With the development of enterprises, MySQL storage data is expanding day by day, performance analysis, monitoring and early warning become very important. In some scenarios, a set of MySQL monitoring/graphic tools is usually deployed, and then further tuning is performed based on the information provided by the MySQL monitoring panel.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

Detailed MySQL master-slave replication;

The master-slave replication function of MySQL is to build a high-availability and high-performance application foundation based on the MySQL database. It can not only be used to share the read load of the master database, but also provide more support for high-availability HA and other tasks. Master-slave replication means that data can be replicated from one MySQL database server master node to another one or more MySQL database server slave nodes. Master-slave replication can be used in enterprise scenarios such as real-time data backup, read-write separation, and high-availability HA.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

PXC high-availability solution ;

Percona's Percona XtraDB Cluster (PXC) is a MySQL high-availability cluster architecture based on the Galera protocol, which integrates Percona Server and PerconaXtraBackup, and also uses the Codership Galera library. Percona Xtradb Cluster connects different MySQL instances through the Galera package on the original MySQL code, realizing a multi-master cluster architecture. It can realize data synchronization replication and reading and writing between multiple MySQL nodes, which not only guarantees the high availability of database services, but also ensures the strong consistency of all data in the entire cluster, and meets the consistency and availability in the CAP theory. ).

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

MySQL automatic failover cluster based on MHA implementation;

MHA (Master High Avaliability) is a script management tool written by a Japanese engineer in Perl language. It is an open source MySQL high-availability solution software that can realize automatic master server failover based on MySQL master-slave replication. At present, it is a relatively mature solution in terms of MySQL high availability. In the MySQL failover process, MHA can automatically complete the database failover operation within 30 seconds, and can ensure data consistency to the greatest extent during the failover process, so as to achieve a real high Available.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

MySQL Group Replication;

MySQL Group Replication (MGR) is a brand new highly available solution officially launched by MySQL in December 2016. MGR is considered to be another "real" cluster after Oracle Database RAC. It is also a new high-availability cluster architecture that MySQL officially based on the concept of group replication and fully refers to the combination of MariaDB Galera Cluster and Percona XtraDB Cluster. It is an officially launched state machine replication based on the Paxos protocol, which completely solves the situation that data consistency problems cannot be guaranteed in traditional asynchronous replication and semi-synchronous replication, and allows MySQL database to open the door to the Internet financial industry.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

Keepalived+ dual-master replication high-availability architecture ;

The dual-master replication with Keepalived MySQL high-availability architecture design is also based on MySQL's master-slave replication principle, while Keepalived uses VIP, and uses Keepalived's own service monitoring function and custom scripts to realize the automatic switchover of the master master server failure. This MySQL dual-master replication + Keepalived architecture can actually be applied to various businesses and is a simple and convenient high-availability solution.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

Introduction to database sub-database sub-table and middleware;

The number of users of large websites and the scale of databases have risen sharply. The common performance bottlenecks of relational databases are mainly reflected in two points: one is a large number of concurrent read and write operations, resulting in excessive load pressure on a single database; the other is that the amount of data stored in a single table is too large , Resulting in inefficient query. At this time, the common practice is to implement the sharding transformation of the database to deal with the impact of massive data and high concurrency on the database. At the same time, database middleware that supports sharding and transparent to business development is also popular.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

Detailed explanation of Mycat middleware;

Since a real database requires a storage engine, and Mycat does not have a storage engine, it is not a distributed database system in the full sense. It can be more appropriately referred to as a database middleware, which is to carry out data between the database and the application. Intermediate services for processing and interaction. The traditional way to access the database is to directly connect to the database, create a database instance, and add, delete, check and modify the data in the database according to requirements. However, when we use Mycat, we actually connect directly to Mycat, and operate the real database through Mycat. On Mycat, we can do some table and database operations to meet our scalability requirements for the database.

A summary of MySQL performance optimization and high-availability architecture practice documents compiled by Tencent Cloud architects

 

This [MySQL Performance Optimization and High-Availability Architecture Practice] document has a total of 263 pages. If you need a full version, you can forward this article and follow the editor, scan the code below to get it! !

Guess you like

Origin blog.csdn.net/bjmashibing001/article/details/111937786