MySQL-based Key-List storage solution _ MySQL

Source: Internet
Author: User
A MySQL-based Key-List storage solution bitsCN.com

Objectives:

Key-List model, trillions of nodes, distributed and scalable, ensuring certain performance and high availability

Basic idea:

1. the list corresponding to the same key should be as centralized as possible

2. restrict the table size through table upgrading and table splitting

3. see the HBase solution management table.

Table upgrade and split solutions:

Use typical data For example, assume that each record has 40 bytes.

Make sure that each table has a maximum of 10 million lines (each data file must not exceed 400 M, or a maximum of 1 million lines, a maximum of 40 M). set a tablespace for each mysql table.

Two conditions are used to limit the number of UIDs and the maximum number of UIDs multiplied by less than 1kw.

Four levels of tables:

Level 1: 100,000 million users with 100 million records. if the number of users exceeds 100,000, the table is split into two or more level 1 Tables. if the number of user records exceeds 100, the table is moved to the minimum level 2 table. (All split or upgrade tasks are performed in idle hours in the early morning. The upgrade takes priority)

Level 2: 10 thousand million users, 1000 records, same as above

Level 3: one thousand million user records, same as above

Level 4: less than one hundred users, more than 100000 records

Structure chart and functions of each part

Master's responsibilities (with backup and one master ):

1. maintain the distribution of databases and tables where the key (uid) is located, and create a hash index in the memory.

2. coordinate data capacity load balancing and distribute write tables in different zones as much as possible

3. detect nodes. if any node is added or deleted, perform the corresponding operations.

Zone responsibilities:

Monitors the table and implements table split. the split is completed in the current zone. during this period, you need to communicate with mater. after the split, other zones will be backed up.

Split Operations (too complicated, not too clear ):

Split Point definition: sort the uid by mid from many to few. when the sum is greater than half of the total number, it is the split point.

When splitting a table, select a slave table to notify the master to apply a read lock to the table and record the synchronization Log Point p. Read/write operations cannot be assigned during the splitting process, after splitting, synchronize the data after the log point p to the two new tables. After synchronization, the master node is notified to map all the writes to the new table. other backups are automatically updated to the two tables in master-slave mode, or use a buffer table or a buffer queue.

Split data copies: The master determines whether to put them in idle zones.

Upgrade operation:

The master node is responsible for the coordination. the specific upgrade is carried out within each zone and does not involve modification to the number of tables. it is much easier to split but involves distribution modification of keys.

Read/write operations:

First, obtain the corresponding table location from the master.

Read Data: reads data from the nearest node. the master table of the data center is preferentially read from the node. if the data center fails to read the data, the other nodes are obtained.

Write Data: write data only to the master table, which may not be the nearest data center. if a single point of failure occurs, the master is notified to change the master. if the process is too long, it is solved through the buffer queue.

Add new machine:

Calculate the number of tables on each node. The M node with the maximum data size is divided into several tables and added to the new machine. after the calculation, the master is notified.

A machine fails:

Find the smallest machines in the table and copy the table data of the failed nodes according to certain rules.

Or wait for the DBA to process it. you do not need to process it immediately.

Notify master

Difficulties (but there are references for solving them, such as HBase ):

Automated table split and upgrade process is complex

Complex table management

How to ensure normal read/write services and data consistency

BitsCN.com

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.