Common Database sharding and table sharding methods for Mysql Databases
1. Database sharding 1.1 database sharding according to functions. It is commonly divided into six major databases:
1. User Class Library: used to save user information. For example, db_user, db_system, and db_company.
2. Business Library: used to store information about major businesses. For example, the main business is joke, and the library is used to save the joke business. For example, db_joke and db_temp_joke.
3. Memory Class Library: It mainly uses the Mysql memory engine. The front-end data is quickly searched from the memory library. For example, heap.
4. Image Library: Stores image indexes and associations. For example, db_img_index and db_img_res.
5. Log Class Library: Record click, refresh, logon, and other log information. For example, db_log_click, db_log_fresh, and db_log_login.
6. Statistics class library: business statistics, such as clicks and refreshes. For example, db_stat.
1.2 install the City Station sub-database. if the business is spread all over the country, copy the same database in each city according to the function sub-database, but the database suffix is the city name. For example, db_log_click_bj, db_log_click_tj, and db_log_click_sh;
2. Table sharding 2.1 users or businesses can be divided into n tables according to the Number % n of users or businesses.
Example: joke table.
Tb_joke_01, tb_joke_02, tb_joke_03, tb_joke_04 ........
2.2 date-based table sharding for tables with logs or statistical classes. The table can be sharded by year, month, day, and week.
For example, click count statistics.
Tb_click_stat_201601, tb_click_stat_201602, tb_click_stat_201603
3. Core Architecture of Mysql Databases: one master, multiple slave databases, and read/write splitting.