当前位置:网站首页>[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 :

边栏推荐
猜你喜欢

2022 t elevator repair recurrent training question bank and answers

Cookie encryption 3+rpc solution

数商云:解析B2B2C多用户商城系统架构设计思路,开启智能商城新时代

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

如何在 FlowUs和Notion 等笔记软件中进行任务管理?

Flutter系列-flutter路由管理

JVM快速入门

3GPP 5G R17标准冻结,RedCap作为重要特性值得关注!

2022 R2 mobile pressure vessel filling test question simulation test platform operation

5G 短消息解决方案
随机推荐
Robotframework installation tutorial
下拉刷新及上拉加载更多的ListView
Which securities company is better to open an account when making an appointment to play new bonds? It is safer to open an account
Iplook, as a member of o-ran alliance, will jointly promote the development of 5g industry
2年狂赚178亿元,中国游戏正在“收割”老外
运维、监控、AIOps的几个重要观点
同花顺容易开户么?手机开户安全么?
Iplook becomes RedHat (red hat) business partner
Is it safe for Ping An Securities to open an account? What is its relationship with Ping An Bank?
Notes on new reports
Array emulation stack
使能伙伴,春节重大保障“不停歇”
Golang 實現 Redis(10): 本地原子性事務
PLSQL variable assignment
vs code突然无法进行代码跳转
Array implementation of circular linked list
数字赋能机械制造业,供应链协同管理系统解决方案助力企业供应链再升级
集群、分布式、微服务概念和区别
Pre training language model, Bert, roformer SIM, also known as simbertv2
Some technical ideas: