当前位置:网站首页>Integrated architecture of performance and cost: modular architecture
Integrated architecture of performance and cost: modular architecture
2022-07-26 04:22:00 【Pineapple - Qiqi】

The little friend who heard about the modular architecture for the first time may be a little confused for a moment , I've heard of micro service architecture 、 Grid architecture and so on, but what the hell is the cellular architecture ?
In fact, many are commonly used in our mobile phones APP They are all modular architectures , Similar to Gaode navigation 、 Financial banking APP It has been a modular architecture for many years , We all know navigation APP For the request RT And request stability are very strict , If RT The delay is high , When you have passed a certain intersection , The navigation suddenly tells you that you need to turn .... At this time, are 10000 grass mud horses pouring out of your heart , So this navigation APP You must unload it immediately when you get home
What is a modular architecture ?
So called unit , It refers to a self-contained set that can complete all business operations , This collection contains all the services required by all businesses , And the data assigned to this unit .
If a business has 30 100 million data , If you deploy with a modular architecture , We can disassemble the data into 3 Share , each 10 100 million data , establish 3 A unit , These three units , Business services are exactly the same , But the data stored in the database is different , Namely 10 100 million data .
Here, the unit is split according to the data , Data needs to have separable properties , Such as user ID And other globally unique identification information , Otherwise, the unit cannot be split .
The traditional layered architecture is shown in the figure below :
- Each layer of service has multiple nodes , The upper layer calls the lower layer with uniform traffic
- Each layer of services can be expanded or reduced separately

The modular architecture is shown in the figure below :
- It is also divided into multi-layer structure , But the number of different service nodes in each layer is fixed , The call chain is also fixed
- A closed loop is formed inside a unit
Advantages of modular architecture :
No matter the traditional distributed architecture or the unitary architecture, there is no perfect design , Any architecture design needs to make corresponding choices according to the changes of use scenarios
Traditional distributed architecture (SOA As a service ) The advantages are obvious , Different layered services can be deployed independently , However, the problem with this architecture is that the service level is split , The database must be divided into databases and tables , Otherwise, the increasing traffic will cause problems in the database , But the problem of the number of connections brought by the service cannot be solved by dividing the database into databases and tables , Eventually, the database connection will explode , If the database is split horizontally, the transformation and intrusion of code will also be huge
As computer hardware is getting better , The era of lower and lower costs , In fact, vertical expansion is also a new idea , Cellular architecture is a kind of vertical extension , However, this vertical expansion is different from the traditional vertical expansion , It belongs to complete logic + Data slicing

Just like cards , If a machine room is under great pressure and cannot be expanded , Then put one card in another computer room for deployment , And if some unitization occurs DOWN On the plane , The impact is also small , This method is very flexible. Whether it is horizontal expansion or multi live deployment in different places, it can be completed immediately
Process comparison :
In a conventional distributed architecture , When there is a strong demand for bank deposits and withdrawals , Usually, the request will be completed to the database master in a service that specially operates the user account DB The operation of , Then master DB In the synchronization to replica node , Because this scenario requires high data consistency , Therefore, subsequent withdrawals will also be operated to the main DB Not to the replica DB, Although the data security guarantee conforms to , But the performance is too low , Because it is a strong operation on a piece of data in the database , It is bound to be blocked and the experience will be reduced
If it is a modular architecture , It will become the following process
- This is the simplest unit interaction structure , The data of each unit passes MQ Sync , But this is not the only way to use it in real scenes , Usually, we will use a faster method of small batch data synchronization, that is, the synchronization of memory middleware , However, although this method is fast, it is not suitable for scenarios with a large amount of synchronized data

request Make sure users ID The corresponding routing unit remains unchanged for a period of time , Even if the attribute of the user's relevant latitude changes, the routing unit can remain unchanged for a period of time ( Navigation type APP Unitization will have more detailed logic ), Then there is an essential difference between this process and the above process ,A Users don't care B Whether the user's account is operated successfully , as long as A If the account operation is successful, then A The account is deducted immediately , This unit uses the synchronization mechanism to tell other units , At this point if B To withdraw money ,B If the unit is not synchronized to the latest data B Can't see new money , This is why there is a waiting time for bank transfers
Core elements :
- Route nearby
- Incremental synchronization of data copies
this 2 If the core elements are completed, then the cellular architecture with many activities in different places can basically run , Closed loop inside the unit + The request route is allocated nearby , this 2 This mechanism ensures that the performance is higher than that of the traditional distributed deployment , But the problems are complexity and original architecture ( Code ) The rectification cost is relatively high
Nearest route scheme :
To meet the RT requirement , Then the services in the unit should complete the closed loop as much as possible to reduce the interaction with other units , Therefore, the routing strategy must consider this
- User mode routing
- User's common location routing
- Device routing

The usual entry packet routing strategy is still adopted , The mapping relationship of the routing table is user -- Group relationship , Group -- Unit relationship
After the storage structure is determined , We also need to determine the storage scheme , Because the whole user - Group analysis depends on a large number of call log analysis , When the number of users is also very objective, we have to consider the storage cost , We may immediately think of :bitmap、db、 The bloon filter
In the routing scenario, cross cell routing is considered , The impact on the user's request is only RT elevated , So as long as the probability is very small, the business is basically acceptable , Therefore, it is more appropriate to choose a Bronte filter , It can support users ID、 equipment ID And other ways of routing , The storage cost and computing performance are good , The probability of routing errors is also acceptable
There is, of course, another situation , After user grouping calculation , No group was found where the user should be , At this time, we need a thorough routing strategy , That's the mold strategy

边栏推荐
- 动态规划 爬楼梯
- 理性认知教育机器人寓教于乐的辅助作用
- Postman 导入curl 、导出成curl、导出成对应语言代码
- How does win11 22h2 skip networking and Microsoft account login?
- Yuansaka Lin wallpaper
- Can literature | relationship research draw causal conclusions
- What format should be adopted when the references are foreign documents?
- `Oi problem solving ` ` leetcode '2040. The k-th minor product of two ordered arrays
- 解决:RuntimeError: Expected object of scalar type Int but got scalar type Double
- Recommendation | DBT skills training manual: baby, you are the reason why you live
猜你喜欢

SEGGER Embedded Studio找不到xxx.c或者xxx.h文件

How does win11 change the power mode? Win11 method of changing power mode

firewall 命令简单操作

Acwing_12. 背包问题求具体方案_dp
远坂凛壁纸

(translation) the button position convention can strengthen the user's usage habits

建设面向青少年的创客教育实验室

Dijango learning

荐书|《DBT技巧训练手册》:宝贝,你就是你活着的原因

MySQL的优化分析及效率执行
随机推荐
p-范数(2-范数 即 欧几里得范数)
Life related - less expectation, happier
How does win11 change the power mode? Win11 method of changing power mode
Helloworld案例分析
使用百度飞桨EasyDL完成垃圾分类
Which websites can I visit to check the latest medical literature?
Write a paper for help, how to write the discussion part?
Matrix and Gauss elimination [matrix multiplication, Gauss elimination, solving linear equations, solving determinants] the most detailed in the whole network, with examples and sister chapters of 130
Go plus security: an indispensable security ecological infrastructure for build Web3
[binary tree] the longest interleaved path in a binary tree
The difference between positive samples, negative samples, simple samples and difficult samples in deep learning (simple and easy to understand)
Acwing刷题
When you try to delete all bad code in the program | daily anecdotes
【学习笔记】AGC041
How mantium uses deepspeed to implement low latency gpt-j reasoning on Amazon sagemaker
Mantium 如何在 Amazon SageMaker 上使用 DeepSpeed 实现低延迟 GPT-J 推理
HelloWorld case analysis
P-norm (2-norm is Euclidean norm)
LeetCode. 6115 count the number of ideal arrays
What are the duplicate check rules for English papers?