当前位置:网站首页>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
边栏推荐
- CGC: contractual graph clustering for community detection and tracking
- How to expand the capacity of the server in the 100 million level traffic architecture? Well written!
- QT double buffer drawing
- Lesson 24 analysis of classical problems
- 一个平面设计师的异想世界|ONES 人物
- Qt一个进程运行另一个进程
- IDEA设置版权信息
- IDEA 中 .properties文件的中文显示乱码问题的解决办法
- Symmetric encryption, certificate encryption
- IDEA 代码质量规范插件SonarLint
猜你喜欢
远程桌面之终端服务器超出了最大允许连接数解决
Relu function of activation function
C# F23. Stringsimilarity Library: String repeatability, text similarity, anti plagiarism
[redis series] redis learning 13. Redis often asks simple interview questions
论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
Metalama简介4.使用Fabric操作项目或命名空间
Fastjson 2 来了,性能继续提升,还能再战十年
Interpretation 3 of gdpr series: how do European subsidiaries return data to domestic parent companies?
5-minute NLP: text to text transfer transformer (T5) unified text to text task model
Fastjson 2 is coming, the performance continues to improve, and it can fight for another ten years
随机推荐
Qt双缓冲绘图
What is a gateway
IMEU如何与IMCU相关联(IM 5.5)
软件测试对于减少程序BUG有多大帮助?
面了一圈,整理了这套面试题。。
Fabric 1.0源代码分析(33) Peer #peer channel命令及子命令实现
Fabric 1.0 source code analysis (33) implementation of peer channel command and subcommand
Sigmoid function of activation function
thinkphp 添加图片文字水印生成带二维码的推广海报
Chapter 4: enable and disable im column storage for materialized view (IM 4.6)
Relu function of activation function
Markdown语法学习
远程桌面之终端服务器超出了最大允许连接数解决
How much does software testing help reduce program bugs?
软件测试基础DAY2-用例执行
第二十六课 类的静态成员函数
Windows11 安装MySQL服务 提示:Install/Remove of the Service Denied
第四章 为IM 启用填充对象之在NO INMEMORY表上指定INMEMORY列属性:示例(IM-4.4 第四部分)
激活函数之sigmoid函数
科创人·派拉软件CEO谭翔:零信任本质是数字安全,To B也要深研用户心智