当前位置:网站首页>Architecture: database architecture design
Architecture: database architecture design
2022-07-03 00:07:00 【Bug trendsetter】
introduction
This paper introduces the architecture design of database ;
Usually , A single machine cannot meet the read and write requirements of large systems for databases , It must be solved by clustering ;
The introduction of clusters means that the complexity of the system is increased , Make the system complex and difficult to maintain ;
Database load balancing strategy is usually adopted 、 Read write separation strategy 、 Optimize the strategy of dividing database and table ;
Load balancing
Extensibility is strong : When the system needs higher database processing speed , As long as you simply add a database server, it can be expanded ;
Maintainability : When a node fails , The system will automatically detect the failure and transfer the application of the failed node , Ensure the continuous work of database ;
Security :
Because the data will be synchronized on multiple servers , Data set redundancy can be realized , Security through multiple data ;
Put the database into the intranet , Better protection of database security ;
Ease of use : Completely transparent to applications , What the cluster exposed is a IP(1) Can't follow Web The processing power of the server distributes the load ;
shortcoming : Load Balancer ( Control terminal ) fault , The whole database system will be paralyzed ;
Read / write separation
When the frequency of reading and writing varies a lot (ebay The read-write ratio of is 260:1), To improve efficiency , Reduce disk IO pressure , Adopt read-write separation ;
Realization principle :
Database server builds master-slave cluster , A master from 、 One master and many followers can ;
The database host is responsible for reading and writing operations , The slave machine is only responsible for reading operations ;
The database host synchronizes the data to the slave through replication , Each database server stores all the business data ;
The business server sends writes to the database host , Send the read operation to the database slave ;
Solution of data inconsistency between master and slave :
Data inconsistency : When the data is written to the master server , Can't be found until the next synchronization ;
Read the host again after the slave fails ;
Key business ( account number 、 Transfer, etc ) All read and write operations point to the host , Non critical business adopts read-write separation ;

Sub database and sub table
Sub database
It refers to splitting into different databases according to functional modules , For example, it can be divided into order warehouse 、 Commodity bank 、 User base ;
join It is only applicable to the joint query of different tables in the same database , After splitting, different databases cannot be used join Statement to query , It can only be queried several times ;
Transaction is a concept in the same database , To rollback transactions between different databases , Only query log The way to roll back ;
The high cost , Splitting into different databases means that multiple backup databases need to be established ;
Sub database table - vertical ( The longitudinal ) Split
Originally, a table contained all 10 A field ;
Now separate the fields with high query frequency into another table ( For example, marriage website name, sex, age Three fields ), Other fields ( Such as personal introduction destribution etc. ) Leave it on the original watch ;
advantage : Query performance improvement , If you only query important fields , There is no need to check out other fields , fast ;
shortcoming : If you want to find all the fields , It must be queried twice ;
Sub database table - level ( The transverse ) Split
Save the data of the same table in blocks to different databases , The tables in these databases have exactly the same structure ;
Sequential routing :
For example, it can be divided by the year of the date of the order ,2003 Years of putting db1 in ,2004 Year of db2, And so on ;
The disadvantage is uneven data distribution , Probably 2003 Orders for 100W,2008 Year old 500W;
hash route :
Yes user_id Conduct hash( Or if user_id If it's numerical, use it directly user_id The value is also acceptable. ), And then use a specific number , For example, a database needs to be divided into 4 Database , We will use 4 That's right user_id Of hash Value for modulo , Decide which table to store ;
If you want to 4 A table becomes 5 Tables , Change the membrane value , Then all the data needs to be changed , so much trouble ;
Configure the routing :
It's about building a DB, This DB Save separately user_id To DB The mapping relation of , Every time you visit the database, you need to query the database first , To get specific DB Information , Then we can perform the query operations we need ;
advantage : Strong flexibility , One to one relationship ;
shortcoming : One more query before each query , Will cause certain performance loss ;
source: //changsiyuan.github.io/2018/07/17/2018-7-17-Architecture-6
Share & Looking at
边栏推荐
- Digital twin visualization solution digital twin visualization 3D platform
- Top Devops tool chain inventory
- Installing redis under Linux
- Intranet penetration | teach you how to conduct intranet penetration hand in hand
- Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
- 顶级 DevOps 工具链大盘点
- 来自数砖大佬的 130页 PPT 深入介绍 Apache Spark 3.2 & 3.3 新功能
- How to maintain the brand influence of clothing enterprises
- [analysis of STL source code] imitation function (to be supplemented)
- How to apply for company email when registering in company email format?
猜你喜欢

Data set - fault diagnosis: various data and data description of bearings of Western Reserve University

Matlab 信号处理【问答笔记-1】

35 pages dangerous chemicals safety management platform solution 2022 Edition

Why can't the start method be called repeatedly? But the run method can?

CADD course learning (4) -- obtaining proteins without crystal structure (Swiss model)

PR FAQ, what about PR preview video card?

Interface switching based on pyqt5 toolbar button -1

RTP 接发ps流工具改进(二)

Interpretation of new plug-ins | how to enhance authentication capability with forward auth

Yolox enhanced feature extraction network panet analysis
随机推荐
67 page overall planning and construction plan for a new smart city (download attached)
Happy Lantern Festival, how many of these technical lantern riddles can you guess correctly?
Brief introduction to common sense of Zhongtai
来自数砖大佬的 130页 PPT 深入介绍 Apache Spark 3.2 & 3.3 新功能
[shutter] shutter open source project reference
List of major chip Enterprises
可知论与熟能生巧
MFC gets the current time
[shutter] open the third-party shutter project
開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
CADD course learning (4) -- obtaining proteins without crystal structure (Swiss model)
Explain in detail the process of realizing Chinese text classification by CNN
Data set - fault diagnosis: various data and data description of bearings of Western Reserve University
leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
Fudian bank completes the digital upgrade | oceanbase database helps to layout the distributed architecture of the middle office
Use of cocospods
Convolution和Batch normalization的融合
How to set automatic reply for mailbox and enterprise mailbox?
Create an interactive experience of popular games, and learn about the real-time voice of paileyun unity
Xcode real machine debugging