当前位置:网站首页>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
边栏推荐
- 判断二叉树是否为满二叉树
- Yolox enhanced feature extraction network panet analysis
- JVM foundation review
- How to maintain the brand influence of clothing enterprises
- Top Devops tool chain inventory
- Explain in detail the process of realizing Chinese text classification by CNN
- PR FAQ, what about PR preview video card?
- MFC file operation
- Define MySQL function to realize multi module call
- 直击产业落地!飞桨重磅推出业界首个模型选型工具
猜你喜欢

Writing of head and bottom components of non routing components

67 page overall planning and construction plan for a new smart city (download attached)

Custom throttling function six steps to deal with complex requirements

流媒体技术优化

Why can't the start method be called repeatedly? But the run method can?
![洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表](/img/4a/ab732c41ea8a939fa0983fec475622.png)
洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表

Bean加载控制

Convolution和Batch normalization的融合

Interface switching based on pyqt5 toolbar button -2
![[shutter] open the third-party shutter project](/img/1a/e35d0180612d7e79b55e7818193740.jpg)
[shutter] open the third-party shutter project
随机推荐
Program analysis and Optimization - 9 appendix XLA buffer assignment
接口自动化覆盖率统计——Jacoco使用
Interpretation of new plug-ins | how to enhance authentication capability with forward auth
Agnosticism and practice makes perfect
顶级 DevOps 工具链大盘点
洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举
In February 2022, the ranking list of domestic databases: oceanbase regained its popularity with "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
Load balancing cluster (LBC)
Practical series - free commercial video material library
JDBC practice cases
MySQL基础
The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
PHP get real IP
How to apply for company email when registering in company email format?
Returns the maximum distance between two nodes of a binary tree
leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
MySQL Foundation
All things work together, and I will review oceanbase's practice in government and enterprise industry
Use redis to realize self increment serial number
Mapper agent development