对消息传递系统中的表进行排队 [英] Queues against Tables in messaging systems

查看:106
本文介绍了对消息传递系统中的表进行排队的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在真实生产环境中体验到了消息传递系统的好处和坏处,我必须承认,组织良好的表或表模式只需在每次任何其他形式消息队列,因为:


  1. 数据永久存储在表中。我见过这么多的java(jms)应用程序丢失或消失未捕获的异常或其他错误的邮件。

  2. 队列往往会填满。





  3. b
    $ b

    您对每种方法的看法是什么?

    解决方案

    完全取决于您的开始要求。



    如果你正在建立一个已经在使用数据库的系统,你没有很高的性能吞吐量要求



    对于简单的低吞吐量,大多是单线程的东西,数据库是一个



    邮件队列照亮的地方是




    • 您想要一个高性能,高并发和可扩展的负载均衡器,所以您可以在每秒处理多个服务器/进程并发处理数万条消息(使用数据库表,你会幸运的处理几百秒,多线程相当困难,因为一个进程将锁定消息队列表)

    • 您需要使用不同的数据库在不同的系统之间进行通信(因此不必提交写访问您的系统数据库到不同团队中的其他人等)



    对于具有单个数据库,团队和相当温和的性能要求的简单系统使用数据库。



    但是,在大型组织中,消息队列闪耀,那里有许多系统需要彼此通信(因此,不希望业务数据库成为故障的中心点或版本地狱的地方)或者当您有高性能要求时。



    在性能方面,消息队列将总是击败数据库表 - 消息队列是专门为作业设计的,不依赖于悲观的表锁(这是数据库实现队列所需的 - 负载平衡)和良好的消息队列将执行将消息热切加载到队列,以避免数据库的网络开销< a>。



    同样,你永远不会使用数据库来对Web服务器上的HTTP请求进行负载均衡 - 因为它太慢了 - 对您的负载均衡器的高性能要求,您也不会使用数据库。


    I've been experiencing the good and the bad sides of messaging systems in real production environments, and I must admit that a well organized table or schema of tables simply beats every time any other form of messaging queue, because:

    1. Data are permanently stored on a table. I've seen so many java (jms) applications that lose or vanish messages on their way for uncaught exceptions or other bugs.
    2. Queues tend to fill up. Db storage is virtually infinite, instead.
    3. Tables are easily accessible, while you have to use esotic instruments to read from a queue.

    What's your opinion on each approach?

    解决方案

    The phrase beats every time totally depends on what your requirements were to begin with. Certainly its not going to beat every time for everyone.

    If you are building a single system which is already using a database, you don't have very high performance throughput requirements and you don't have to communicate with any other teams or systems then you're probably right.

    For simple, low thoughput, mostly single threaded stuff, database are a totally fine alternative to message queues.

    Where a message queue shines is when

    • you want a high performance, highly concurrent and scalable load balancer so you can process tens of thousands of messages per second concurrently across many servers/processes (using a database table you'd be lucky to process a few hundred a second and processing with multiple threads is pretty hard as one process will tend to lock the message queue table)
    • you need to communicate between different systems using different databases (so don't have to hand out write access to your systems database to other folks in different teams etc)

    For simple systems with a single database, team and fairly modest performance requirements - sure use a database. Use the right tool for the job etc.

    However where message queues shine is in large organisations where there are lots of systems that need to communicate with each other (and so you don't want a business database to be a central point of failure or place of version hell) or when you have high performance requirements.

    In terms of performance a message queue will always beat a database table - as message queues are specifically designed for the job and don't rely on pessimistic table locks (which are required for a database implementation of a queue - to do the load balancing) and good message queues will perform eager loading of messages to queues to avoid the network overhead of a database.

    Similarly - you'd never use a database to do load balancing of HTTP requests across your web servers - as it'd be too slow - if you have high performance requirements for your load balancer you'd not use a database either.

    这篇关于对消息传递系统中的表进行排队的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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