在 Web 应用程序中使用像 RabbitMQ 这样的消息传递? [英] Use of messaging like RabbitMQ in web application?

查看:25
本文介绍了在 Web 应用程序中使用像 RabbitMQ 这样的消息传递?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解像 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.

就网络应用程序而言,这对您来说意味着能够随着需求的增长扩展您的应用程序,并使您的 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 这样的消息传递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆