当前位置:网站首页>[suggestions collection] common usage scenarios of message queue
[suggestions collection] common usage scenarios of message queue
2022-06-22 19:25:00 【lxw1844912514】
1. system decoupling
Look at this scene .A The system sends data to BCD Three systems , Sent via interface call . If E The system also needs this data ? Then if C The system is not needed now ?A The head of the system almost collapsed ......


2. Asynchronous processing

General Internet enterprises , Direct action to the user , The general requirement is that every request must be in 200 ms Finish within , It is almost insensitive to the user .
If Use MQ, that A The system sends 3 Message to the MQ In line , If it takes time 5ms,A The system goes from accepting a request to returning a response to the user , The total time is 3 + 5 = 8ms, For users , It feels like a button ,8ms And then he went straight back , Shuang ! Well done website , So fast !

3. Traffic peak clipping
Every day 0:00 To 12:00,A The system is calm , The number of concurrent requests per second is 50 individual . It turns out to be 12:00 ~ 13:00 , The number of concurrent requests per second suddenly increases to 5k+ strip . But the system is directly based MySQL Of , A flood of requests poured in MySQL, For every second MySQL To perform some 5k strip SQL.
General MySQL, Carry it to every second 2k Three requests is enough , If you request to 5k Words , Maybe just put MySQL To have killed , Causing the system to crash , Users can no longer use the system .
But the rush is over , By the afternoon , It's a low peak , Maybe it's just 1w At the same time on the site , The number of requests per second is probably the same 50 A request , There is almost no pressure on the whole system .

If you use MQ, Per second 5k Requests to write to MQ,A Maximum processing per second 2k A request , because MySQL At most per second 2k individual .A System from MQ Slowly pull the request in , Pull every second 2k A request , Do not exceed the maximum number of requests per second you can handle ok, So down , Even at rush hour ,A The system will never fail . and MQ Every second 5k A request to come in , Just 2k A request to go out , The result is a midday rush (1 Hours ), There could be hundreds of thousands or even millions of requests MQ in .

This short peak backlog is ok Of , Because after the rush hour , Every seconds 50 A request to enter MQ, however A The system is still going to be per second 2k The speed of the request in processing . So , Just after the rush hour ,A The system will quickly clear the backlog of messages .
4. Log processing
Large e-commerce website ( TaoBao 、 JD.COM 、 Gome 、 Suning ...)、App( Tiktok 、 Meituan 、 Didi et al ) Need to analyze user behavior , We should find the user's preferences and activity according to the user's access behavior , You need to collect a lot of user access information on the page .

Advantages and disadvantages of message queuing
The advantages have been mentioned above , Namely There are corresponding advantages in special scenes .
The disadvantages are as follows :
Reduced system availability
The complexity of the system increases
Consistency issues
Kafka、ActiveMQ、RabbitMQ、RocketMQ Advantages and disadvantages
Message queue ActiveMQ 、RocketMQ 、RabbitMQ and Kafka How to choose ?

Sum up , After all the comparisons , Here are some suggestions :
In terms of technology selection :

边栏推荐
- In the first half of the year, there were 7 new unicorns in this field, and the capital scrambled to enter the market
- org. apache. ibatis. binding. BindingException: Invalid bound statement (not found)
- 加工制造业智慧采购系统解决方案:助力企业实现全流程采购一体化协同
- 新人报道的笔记
- Modèle de langage de pré - formation, Bert, roformer Sim aussi connu sous le nom de simbertv2
- Sre is bound to move towards the era of chaotic engineering -- Huawei cloud chaotic engineering practice
- Niuke.com: consolidation interval
- 输入两个字符串,输出最长相同子串
- Iplook and SBC establish long-term cooperation
- 《被讨厌的勇气》读后感
猜你喜欢

线程池:ThreadPoolExcutor源码阅读

Flutter系列-flutter路由管理

泡泡玛特:空洞的灵魂需要故事

3GPP 5G R17标准冻结,RedCap作为重要特性值得关注!
![jniLibs. Srcdirs = ['LIBS'] what's the use?](/img/d5/3070f8e793507efc601bb22d5024fa.png)
jniLibs. Srcdirs = ['LIBS'] what's the use?

Exness sorted out three problems to be solved in Musk's acquisition of Twitter

维智科技亮相西部数博会,时空AI技术获高度认可

Iplook 5gc successfully connected with CICA international CHF (billing function)

PostgreSQL 字符串分隔函数(regexp_split_to_table)介绍以及示例应用

牛客网:合并区间
随机推荐
贪心之区间问题(2)
Chrome suddenly can't copy and paste
UE4_UE5制作3DUI-跟随相机朝向(附工程)
centerOS 安装mangodb
5g short message solution
输入两个字符串,输出最长相同子串
JVM quick start
Sre is bound to move towards the era of chaotic engineering -- Huawei cloud chaotic engineering practice
预训练语言模型,bert,RoFormer-Sim又称SimBERTv2
【建议收藏】消息队列常见的使用场景
std::enable_ shared_ from_ This error: error: expected template name before '<' token
贪心之区间问题(4)
codeup最长回文子串
Golang implements redis (10): local atomic transactions
Pre training language model, Bert, roformer SIM, also known as simbertv2
Exness sorted out three problems to be solved in Musk's acquisition of Twitter
org. apache. ibatis. binding. BindingException: Invalid bound statement (not found)
如何更改Apple Watch上的表盘
Flutter系列-搭建Flutter开发环境
How MySQL deletes a column in a database table