[Tencent Cloud TDSQL-C Serverless Product Evaluation] - TDSQL-C MySQL Database Technology Practice in the Cloud Native Era

1. Activity introduction:

"Tencent Cloud TDSQL-C Product Evaluation Activity" is an activity aimed at database product evaluation and product experience launched by Tencent Cloud and CSDN. Product evaluation in various aspects such as elasticity, automatic start-stop capability, compatibility, security, concurrency, and reliability.

insert image description here


2. Manual experience:

After registering, join the WeChat group, and the assistant provides 2 experimental manuals to experience a simple introduction to TDSQL-C MySQL. Since the new computer has not yet installed the Ptyhon environment, so here I choose "Vue+Koa+TDSQL to realize the question answering system 》 to practice it.

insert image description here
In less than 15 minutes, according to the function description steps in the manual, the experience of TDSQL-C MySQL is completed from 0 to 1. Next, let us experience the functions of TDSQL-C MySQL in depth.


3. Database introduction:

  1. What is a database?

Database (Database, referred to as DB) is a collection of large amounts of organized and shareable data stored in a computer for a long time.

The data in the database is organized, described and stored according to a certain data model. It has small redundancy, high data independence, easy scalability, and can be shared by various users.

  1. Relationship between database and database management tools:

insert image description here

  1. Common database management systems:

insert image description here

In normal development, I have been exposed to MySQL and SQL Server databases. I used .NET in the early days to develop using SQL Server databases. After learning PHP later, most of them use PHP + MySQL for Web-related development work. In the meantime, I also studied and investigated PostgreSQL.

  1. How to operate the database:

The database management system can define and operate data through SQL (Structured Query Language), maintain data integrity and security, and manage various databases.

insert image description here

For example, my usual job is full-stack development, php + vue + uniapp applet, basically 70% of the time on the backend is dealing with MySQL, and I have encountered many MySQL problems. I hope that through this study, I can also review what I have learned.


4. Introduction to TDSQL-C:

From the screenshot of the activity at the top, let’s have a general understanding of what is TDSQL-C? What is the function of TDSQL-C? The following is a summary of mine. You can first understand the basic functions, scenarios, and functions of TDSQL-C.

insert image description here

TDSQL is a MySQL-compatible, self-controllable, and highly consistent distributed database launched by Tencent.

  1. Function:
  • High availability, performance and scalability
  • Supports horizontal automatic splitting, has complete business logic tables, and data is evenly split into multiple physical shards
  • Effectively solve OLTP scenarios with ultra-large concurrency, ultra-high performance, and ultra-large capacity
  1. effect:
  • Friendly support for scenarios such as financial-level high availability, enterprise-level security, and strong data consistency
  • Provide a complete ecology and perfect service guarantee capabilities

Five, TDSQL-C MYSQL practical operation:

  1. Purchase the TDSQL-C MYSQL database on the official website:

Open the official website (TDSQL-C MYSQL link) [https://cloud.tencent.com/product/tdsqlc], click "Shop Now".
insert image description here

If you are a new account, there are some pre-actions, you need to register your real name, otherwise you will be prompted that you cannot purchase.
insert image description here

Recharge a little value to the account to purchase products. If it is used for testing here, charge 10 yuan to experience it.
insert image description here
On the product purchase page, you must choose the "Serverless" product for the instance form. TDSQL-C is divided into two products: one is MySQL and the other is PostgreSQL. Here we choose the "MySQL" database engine.

It can be seen that the region also supports foreign regions, give the product a thumbs up, awesome!

insert image description here
We choose the latest database version "MySQL 8.0", which can be automatically suspended according to your own business settings, select "1 hour", the storage billing mode, you can use the resource pack, click "Buy Resource Pack" to purchase.

insert image description here

Choose "storage resource package", adjust the capacity according to your own needs, it can be seen that it is also cheaper.

insert image description here

Through a few steps to confirm the order, the resource pack is successfully purchased.
insert image description here

Go back to the database purchase page and bind the storage resource pack you just purchased.
insert image description here

In the second step, you can set parameters such as database password, default character set, custom port, and table name case.
insert image description here

After several confirmation steps, the cluster was successfully created. It is interesting that this is not called a database instance, but a cluster.

  1. Database cluster function introduction:

insert image description here

By default, the external network of the database cluster instance is closed, and you need to open it yourself. Here, for the convenience of demonstration, set the "automatic pause duration" to 10 minutes. One question is why there is 24M storage space just after the database is opened?
insert image description here

You can see that the corresponding resource package is 0, and no data is stored.
insert image description here

Through the database management tool DMC, you can see that the system has some system libraries by default, and guess that the 24M data belong to them.

insert image description here

  1. Open the external network access address:

Click "Open" above, after opening the external network access address, note that the host is a domain name (not IP), and the port is a random one (not 3306).

insert image description here

  1. Account Management:

Add a development account with read-only permissions and no operational permissions.

insert image description hereinsert image description here

  1. Database management:

insert image description here

You can individually control the permissions of some accounts.
insert image description here
insert image description here

  1. parameter settings:

You can modify the parameters for some databases to meet your own needs.

insert image description here

  1. Problems encountered in experience:

When using the database password, "Mysql." cannot be used. I tried many times and found that there is a problem with the password. Change it to "Test123."

insert image description here

Imported a little table, after deleting it in Navicat, the space of the table is not released?
insert image description here

The mysql2 in the manual does not seem to be very easy to use when the traffic is concurrent. Next time, try Java's multi-threading.

insert image description here

6. TDSQL-C MySQL cost reduction strategy:

  1. Automatic start and stop:

The advantage of Serverless is that when the setting is not used for 10 minutes (which can be deployed at any time), the database will be suspended. After the suspension, the calculation will no longer be billed. The status of the following database cluster instances is "suspended".

insert image description here

Generally, like our website, there is no traffic at night, which can save costs for a period of time. If it is a year, it is also a relatively considerable energy-saving income.

  1. Serverless scaling in seconds:

Modify the back-end Node code in the above manual, write data to the database concurrently, and simulate the scene where the QPS suddenly rises online.

const mysql = require('mysql2/promise');

// 初始化数据库连接
let connection = null
async function initDb () {
    
    
  connection = await mysql.createConnection({
    
    
    host: 'bj-cynosdbmysql-grp-8znse6hq.sql.tencentcdb.com',
    user: 'root',
    password: 'Test123..',
    database: 'shop',
    port: 26668,
  });

  async function selectData () {
    
    
    for (let i = 0; i < 999999; i++) {
    
    
      let sql = "INSERT INTO `tb_seckill_goods` VALUES (943095, NULL, 'xxxxxxx', 'http://img14.360buyimg.com/n7/jfs/t23629/293/671156875/53383/8ab4ce73/5b3c24abN8090cb25.jpg', 825.26, 82.53, '2019-05-24 06:51:00', '2019-05-24 06:51:00', '1', '2019-05-23 16:00:00', '2019-05-23 17:59:00', 79, 75, 'xxxxx')";
      connection.execute(sql);
    }
  }
  
  selectData()
}
initDb()

insert image description hereinsert image description here

insert image description here

It can be seen that the configuration we bought was the minimum 0.5 and the maximum 1. According to previous experience, the CPU may reach 100%, and the SQL process is blocked. However, the TDSQL-C MySQL Serverless version can automatically The CPU is expanded from a maximum of 1 to almost 5 above.

  1. Summarize:

It can be seen that the TDSQL-C MySQL Serverless version has a highly flexible and flexible usage method, and billing is based on the actual usage, which is very suitable for small and medium-sized enterprises with large fluctuations in business volume. Using this on-demand and volume-based billing model greatly reduces usage costs and waste of resources.

insert image description here


7. TDSQL-C MySQL efficiency improvement strategy:

  1. Authority control:

We can effectively control the operation type of the role through the permissions set above to prevent some people in the team from misoperation. The traditional work may be assigned by the DBA. Here, it can be set directly, which is more convenient. It can be seen that when we use dev_chen to perform the insert operation, an error is reported directly.

insert image description here

  1. SQL import:

It takes about 5 minutes to import data in Navicat, but importing data in DMC management platform saves almost half of the time.

insert image description here

Personal guess, it may be that DMC uploads SQL to the server first, and then imports it locally, which is much faster. The export speed is also relatively fast, but it is recommended to compress it with zip, which can save traffic and the speed is relatively fast.

insert image description here

You can see that during the process of importing table data in Navicat, it is found that this table has data.
insert image description here

However, the query on the DMC is empty. Only after the data is imported from the table can the data be found in the picture below.

insert image description hereinsert image description here

  1. Mysql 5.7 migrated to 8.0:

You can see that the table of Mysql 5.7 is imported in 8.0, and there are some small errors, but it does not affect the use. Basically 100% can be migrated.

insert image description here

  1. Summarize:

insert image description here

8. TDSQL-C MySQL operation and maintenance capabilities:

111


9. Summary:

insert image description here

TDSQL is Tencent Cloud's enterprise-level distributed database. It covers a complete database product system with financial-level distributed, cloud-native, analytical and other multi-engine integrations. It provides industry-leading financial-level high availability, separation of computing and storage, data warehouse, and enterprise-level Security and other capabilities, as well as a complete product service system such as an intelligent operation and maintenance platform and a serverless version.

I am also practicing TDSQL-C MySQL 8.0 through activities, doing-it-yourself manuals, and practicing TDSQL-C MySQL 8.0 in projects. I have a shallow to deep understanding from 0 to 1, and actually operate from some arguments. I understand that TDSQL-C MySQL can indeed give us The business brings a solution to improve efficiency and reduce costs, and hopes to implement TDSQL-C MySQL in the business in the future.

To sum up, it can be seen that TDSQL-C MySQL is a powerful, flexible, and scalable database middleware, suitable for medium and large enterprise-level applications. If you are looking for a reliable, high-performance, and scalable database solution, TDSQL-C MySQL version is a very good choice.

Guess you like

Origin blog.csdn.net/2301_77888392/article/details/132448663