当前位置:网站首页>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
边栏推荐
- Improvement of RTP receiving and sending PS stream tool (II)
- Additional: token; (don't read until you finish writing...)
- 67 page overall planning and construction plan for a new smart city (download attached)
- 接口自动化覆盖率统计——Jacoco使用
- 附加:token;(没写完,别看…)
- MySQL Foundation
- leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
- MySQL基础
- 流媒体技术优化
- 带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)
猜你喜欢
Difference between NVIDIA n card and amda card
Writing of head and bottom components of non routing components
Request and response
Realization of mask recognition based on OpenCV
Data set - fault diagnosis: various data and data description of bearings of Western Reserve University
洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举
I've been interviewed. The starting salary is 16K
Custom throttling function six steps to deal with complex requirements
Flexible combination of applications is a false proposition that has existed for 40 years
Improvement of RTP receiving and sending PS stream tool (II)
随机推荐
CADD课程学习(4)-- 获取没有晶体结构的蛋白(SWISS-Model)
How much do you know about synchronized?
Writing of head and bottom components of non routing components
Digital collection trading website domestic digital collection trading platform
The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
顶级 DevOps 工具链大盘点
监控容器运行时工具Falco
请求与响应
What experience is there only one test in the company? Listen to what they say
开发知识点
[shutter] shutter open source project reference
1380. Lucky numbers in the matrix
Leetcode relaxation question - day of the week
Use redis to realize self increment serial number
Container runtime analysis
Returns the maximum distance between two nodes of a binary tree
Third party payment function test point [Hangzhou multi tester _ Wang Sir] [Hangzhou multi tester]
How QT exports data to PDF files (qpdfwriter User Guide)
Flexible combination of applications is a false proposition that has existed for 40 years
Wechat applet basic learning (wxss)