当前位置:网站首页>Message queuing overview
Message queuing overview
2022-04-23 12:16:00 【xmh-sxh-1314】
Message queue is the of basic data structure “ fifo ” A kind of data organization of . Think about it , Shopping in life , Need to line up , People who line up first buy and consume first , It's typical “ fifo ”.
image.png
MQ What problem to solve
MQ Is always there , However, with the popularity of microservice architecture , It has become a common tool to solve the problems between microservices .
The application of decoupling
Take e-commerce applications , There is an order system in the application 、 inventory system 、 Logistics system 、 Payment system . After the user creates the order , If the coupling calls the inventory system 、 Logistics system 、 Payment system , Any subsystem fails , All of these will cause abnormal order operation .
When it comes to message queuing , The problem of inter system calls will be reduced a lot , For example, the logistics system fails , It will take a few minutes to repair . In these few minutes , The memory to be processed by the logistics system is cached in the message queue , The user's order can be completed normally . When the logistics system is restored , Continue to process the order information , The single user cannot feel the failure of the logistics system . Improve system availability .
image.png
Flow peak elimination
Take a chestnut , If the order system can process up to 10000 orders , This processing capacity is more than enough to cope with orders in normal times , In normal time, we can return the result one second after placing an order . But at the peak , If there are 20000 orders, the operating system can't handle it , Only after the order exceeds 10000, users are not allowed to place an order .
Use message queue as buffer , We can lift this restriction , Divide orders placed in one second into a period of time to process , In this case, some users may not receive the successful operation of placing an order until more than ten seconds after placing an order , But it's better than the experience of not ordering .
Message delivery
Multiple service teams are interested in data , You only need to listen to the same kind of message to process .
image.png
for example A Generate data ,B Interested in data . If there is no queue of messages A After each processing, you need to call B service . After a while C Also sensitive to data ,A You need to change the code , call B service , call C service . As long as there is a need for service ,A All services need to change the code . Very inconvenient .
image.png
With message queuing ,A Just send the message once ,B Interested in news , Just listen for messages .C Interested in ,C Also listen to the news .A As a basic service, the service does not need to be changed at all .
Asynchronous messaging
image.png
Some calls between services are asynchronous , for example A call B,B It takes a long time to execute , however A Need to know B When can I finish , There used to be two ways ,A Call after a period of time B Query for api Inquire about . perhaps A Provide a callback api,B Call after execution api notice A service . Neither of these methods is very elegant
image.png
Use message bus , Can be very convenient to solve this problem ,A call B After service , Just monitor B Processing completed message , When B After processing , Will send a message to MQ,MQ Will forward this message to A service .
such A The service does not need to be called circularly B Query for api, No need to provide callback api. Again B Services don't have to do these operations .A The service can also get the message of successful asynchronous processing in time
版权声明
本文为[xmh-sxh-1314]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231207384968.html
边栏推荐
- Idea setting copyright information
- SQL exercise (I)
- S2-062 remote command execution vulnerability recurrence (cve-2021-31805)
- Why is the premise of hash% length = = hash & (length-1) that length is the nth power of 2
- Qt双缓冲绘图
- 第五章 使用In-Memory表达式优化查询(IM 5.1)
- Lesson 23 temporary objects
- 宝塔面板命令行帮助教程(包含重置密码)
- QT draw image
- Outsourcing for five years, abandoned
猜你喜欢

S2-062 remote command execution vulnerability recurrence (cve-2021-31805)

The maximum number of remote desktop servers has been exceeded

WIN10 启动后花屏

Here comes the detailed picture and text installation tutorial of H5 game

IDEA 代码质量规范插件SonarLint

Recommended programming AIDS: picture tool snipaste

worder字体网页字体对照表

Sofa weekly | excellent Committee of the year, contributor of this week, QA of this week

Worder font page font comparison table

Use kettle to copy records to and get records from results
随机推荐
NativeForMySQL 连接MySQL8 提示:1251- Client does not support authentication protocol
Metalama简介4.使用Fabric操作项目或命名空间
2022 love analysis · panoramic report of industrial Internet manufacturers
一个平面设计师的异想世界|ONES 人物
力扣-1137.第N个泰波那契数
Qt进程间通信
宝塔面板命令行帮助教程(包含重置密码)
How much does software testing help reduce program bugs?
【Redis 系列】redis 学习十三,Redis 常问简单面试题
数组---
How to expand the capacity of the server in the 100 million level traffic architecture? Well written!
How imeu is associated with imcu (IM 5.5)
激活函数之阶跃函数
激活函数之relu函数
Next.js 静态数据生成以及服务端渲染的方式
CGC: contractual graph clustering for community detection and tracking
After a circle, I sorted out this set of interview questions..
Win10 splash screen after startup
编程辅助工具推荐:图片工具snipaste
用户接口和IM表达式(IM 5.6)