Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the functions of message queues

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the functions of message queues". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

flow clipping

Message queue, in fact, is not something profound, similar to our National Day trip, many scenic spots will appear overcrowded, everywhere is the phenomenon of people following the crowd, at this time, how is the scenic spot to solve the problem? Usually, the queue is limited. A waiting area is set up at the ticket office. If there are too many people in the scenic spot, a waiting area is set up at the ticket office to let tourists queue up. After some tourists come out of the scenic spot, a group of tourists will be put in.

The same is true of the real production environment. In the production environment, the capacity of each system is different. The throughput of the core system or simple system is often relatively large, and the throughput of the non-core system and complex system is often relatively low. For example, in e-commerce systems, we often have to report data on user behavior, which is not so important compared to user browsing, transactions and other behaviors, so the system performance supporting data reporting is often inferior to the core function.

In some traffic peaks, such as the Double Eleven, we generally do not expand this reporting system. At this time, synchronous data reporting is easy to cause avalanche. In response to this situation, we can put the writing of user behavior data into an asynchronous queue and consume it according to the writing speed of data, thus ensuring the robustness of the system.

system decoupling

When we start developing a system, the logic is always clear and simple. As the requirements iterate, the system becomes more and more complex. For a simple example, when we make a trade, the trading system may simply perform a simple inventory deduction and then write an order. As the functionality iterates, we need to notify advertising systems, third-party sellers, merchant systems, etc., like Alibaba, after each simple transaction, we may need to notify dozens of different business parties to process.

This added logic, if we were to do it all in the trading system, would make it more and more bloated and would make it difficult to ensure data consistency. If the notification advertising system fails (such as network fluctuations), then whether the transaction behavior will continue, even if the notification advertising system fails, if the notification merchant system fails? Data inconsistencies can cause complaints and losses to the company, and late development takes a lot of time to repair data.

Message queuing is a simpler and more reliable method. When we successfully complete a transaction, we produce a message that all business parties consume, and the business party itself ensures successful consumption. In this way, the trading system does not have to worry about the subsequent actions of the trading behavior, greatly reducing the complexity of the trading system.

Delay vs. Asynchronous

Such scenarios are very common in e-commerce systems. After a user creates an order, he may not pay. We can remind the user 25 minutes after creating the order to tell him that there is an order that has not been paid, thus improving the conversion rate. If you were to implement this function, what would you do?

We could use a timed task that scans the database every minute to pull out unpaid orders and then notifies the user to pay. This is also a good method, but the difficulty of a reliable timed task is not repeated here. Today, we will introduce another method, that is, message queuing.

Some message queues provide delayed queuing functionality, such as RabbitMQ, which we can implement very simply by taking advantage of its delayed nature. When the user places an order, we issue a delay message, wait until the time of consumption, and then query the status of the order. Later, we will talk about how the message queue delay guarantees reliability.

"What are the functions of message queues" is introduced here. Thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report