我曾被要求评估RabbitMQ而不是Kafka,但发现很难找到一个消息队列比Kafka更适合的情况。有人知道在哪些用例中消息队列在吞吐量、持久性、延迟或易用性方面更适合吗?


当前回答

我知道有点晚了,也许你已经间接地说过了,但是,Kafka根本不是一个队列,它是一个日志(就像上面有人说的,基于民意调查)。

简单来说,当你更喜欢RabbitMQ(或任何队列技术)而不是Kafka时,最明显的用例是:

You have multiple consumers consuming from a queue and whenever there is a new message in the queue and an available consumer, you want this message to be processed. If you look closely at how Kafka works, you'll notice it does not know how to do that, because of partition scaling, you'll have a consumer dedicated to a partition and you'll get into starvation issue. Issue that is easily avoided by using simple queue techno. You can think of using a thread that will dispatch the different messages from same partition, but again, Kafka does not have any selective acknowledgment mechanisms.

你能做的最多的就是像那些家伙一样,试着把Kafka转换成一个队列: https://github.com/softwaremill/kmq

雅尼克

其他回答

我知道有点晚了,也许你已经间接地说过了,但是,Kafka根本不是一个队列,它是一个日志(就像上面有人说的,基于民意调查)。

简单来说,当你更喜欢RabbitMQ(或任何队列技术)而不是Kafka时,最明显的用例是:

You have multiple consumers consuming from a queue and whenever there is a new message in the queue and an available consumer, you want this message to be processed. If you look closely at how Kafka works, you'll notice it does not know how to do that, because of partition scaling, you'll have a consumer dedicated to a partition and you'll get into starvation issue. Issue that is easily avoided by using simple queue techno. You can think of using a thread that will dispatch the different messages from same partition, but again, Kafka does not have any selective acknowledgment mechanisms.

你能做的最多的就是像那些家伙一样,试着把Kafka转换成一个队列: https://github.com/softwaremill/kmq

雅尼克

简短的回答是“消息确认”。RabbitMQ可以配置为需要消息确认。如果接收方失败,消息将返回队列,另一个接收方可以再次尝试。虽然你可以用自己的代码在Kafka中完成这个任务,但它可以在RabbitMQ中开箱即用。

根据我的经验,如果你有一个需要查询信息流的应用程序,Kafka和KSql是你最好的选择。如果你想要一个排队系统,你最好使用RabbitMQ。

Scaling both is hard in a distributed fault tolerant way but I'd make a case that it's much harder at massive scale with RabbitMQ. It's not trivial to understand Shovel, Federation, Mirrored Msg Queues, ACK, Mem issues, Fault tollerance etc. Not to say you won't also have specific issues with Zookeeper etc on Kafka but there are less moving parts to manage. That said, you get a Polyglot exchange with RMQ which you don't with Kafka. If you want streaming, use Kafka. If you want simple IoT or similar high volume packet delivery, use Kafka. It's about smart consumers. If you want msg flexibility and higher reliability with higher costs and possibly some complexity, use RMQ.

如果你有复杂的路由需求,想要一个内置的GUI来监控代理,那么RabbitMQ可能是最适合你的应用程序。否则,如果你正在寻找一个消息代理来处理高吞吐量并提供对流历史的访问,Kafka可能是更好的选择。

在以下情况使用RabbitMQ:

你不需要处理大数据,你更喜欢一个方便的内置UI来监控 不需要自动复制队列 消息没有多个订阅者——因为不像Kafka是一个日志,RabbitMQ是一个队列,消息一旦被消费和确认到达就会被删除 如果您有要求使用通配符和正则表达式的消息 如果定义消息优先级很重要

简而言之: RabbitMQ适用于简单的用例,数据流量低,具有优先级队列和灵活的路由选项。 对于海量数据和高吞吐量使用Kafka。