问题描述
我想了解在什么场景/用例/中,像RabbitMQ这样的消息传递可以帮助消费者Web应用程序.
I would like to learn what are the scenarios/usecases/ where messaging like RabbitMQ can help consumer web applications.
是否有任何可学习的特定资源?
Are there any specific resources to learn from?
当前有哪些Web应用程序正在使用此类消息传递方案?如何使用?
What web applications currently are making use of such messaging schemes and how?
推荐答案
通常,消息总线(例如RabbitMQ,但不限于此)允许可靠的作业处理队列.
In general, a message bus (such as RabbitMQ, but not limited to) allows for a reliable queue of job processing.
对于Web应用程序而言,这对您而言意味着能够随着需求的增长而扩展应用程序并保持UI快速响应的能力.
What this means to you in terms of a web application is the ability to scale your app as demand grows and to keep your UI quick and responsive.
他们可以请求处理一个作业(例如,单击网页上的按钮以开始对服务器上的视频文件进行代码转换),而不是迫使用户等待处理该作业,而是向您发送一条消息.总线,让我们的后端服务在轮到队列时将其拾取,并可能通知用户工作已经/将要开始.然后,您可以将控件返回到UI,以便用户可以继续使用该应用程序.
Instead of forcing the user to wait while a job is processed they can request a job to be processed (for example, clicking a button on a web page to begin transcoding a video file on your server) which sends a message to your bus, let's the backend service pick it up when it's turn in the queue comes up, and maybe notify the user that work has/will begin. You can then return control to the UI, so the user can continue working with the application.
在这种情况下,您的Web界面执行的工作量为零,而只是给用户以您认为合适的方式查看该过程的各个阶段的信息(例如,该作业可以用您可以查询的过程状态来增量更新数据库记录)并显示给您的用户).
In this situation, your web interface does zero heavy lifting, instead just giving the user visibility into stages of the process as you see fit (for example, the job could incrementally update database records with the state of process which you can query and display to your user).
我假设遇到任何形式的大量流量的任何Web应用程序都将具有这种类型的基础结构.尽管存在不利因素(网络故障可能会破坏消息传递,更复杂的基础结构等),但扩展后端的优势变得越来越明显.如果您使用的是云服务,则这种类型的基础结构使得通过订阅作业队列并仅挑选要处理的消息来添加其他消息处理程序来处理您的工作变得很简单.
I would assume that any web application that experiences any kind of considerable traffic would have this type of infrastructure. While there are downsides (network glitches could potentially disrupt message delivery, more complex infrastructure, etc.) the advantages of scaling your backend become increasingly evident. If you're using cloud services this type of infrastructure makes it trivial to add additional message handlers to process your jobs by subscribing to the job queue and just picking off messages to process.
这篇关于在Web应用程序中使用像RabbitMQ这样的消息传递吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!