我曾被要求评估RabbitMQ而不是Kafka,但发现很难找到一个消息队列比Kafka更适合的情况。有人知道在哪些用例中消息队列在吞吐量、持久性、延迟或易用性方面更适合吗?
当前回答
从技术上讲,与Rabbit MQ提供的特性集相比,Kafka提供了一个巨大的超特性集。
如果问题是
Rabbit MQ技术上比Kafka更好吗?
那么答案是
No.
但是,如果问题是
从业务角度看Rabbit MQ比Kafka好吗?
那么,答案是
在某些商业场景中,可能是“Yes”
从业务角度来看,Rabbit MQ可以比Kafka更好,原因如下:
Maintenance of legacy applications that depend on Rabbit MQ Staff training cost and steep learning curve required for implementing Kafka Infrastructure cost for Kafka is higher than that for Rabbit MQ. Troubleshooting problems in Kafka implementation is difficult when compared to that in Rabbit MQ implementation. A Rabbit MQ Developer can easily maintain and support applications that use Rabbit MQ. The same is not true with Kafka. Experience with just Kafka development is not sufficient to maintain and support applications that use Kafka. The support personnel require other skills like zoo-keeper, networking, disk storage too.
其他回答
投票最多的答案涵盖了大部分内容,但我想强调用例的观点。卡夫卡能做兔子mq能做的事情吗?答案是肯定的,但兔子mq能做卡夫卡能做的所有事情吗?答案是否定的。
rabbit mq不能做的让kafka与众不同的事情是分布式消息处理。现在读一下得票最多的答案,它会更有意义。
To elaborate, take a use case where you need to create a messaging system that has super high throughput for example "likes" in facebook and You have chosen rabbit mq for that. You created an exchange and queue and a consumer where all publishers (in this case FB users) can publish 'likes' messages. Since your throughput is high, you will create multiple threads in consumer to process messages in parallel but you still bounded by the hardware capacity of the machine where consumer is running. Assuming that one consumer is not sufficient to process all messages - what would you do?
你能再增加一个消费者到队列中吗?不,你不能这样做。 你能创建一个新的队列并绑定该队列来交换发布“喜欢”消息吗?答案是不能,因为你会有两次消息处理。
这是卡夫卡解决的核心问题。它允许您创建分布式分区(rabbit mq中的Queue)和相互通信的分布式消费者。这确保主题中的消息由分布在各个节点(Machines)中的使用者处理。
Kafka代理确保消息在该主题的所有分区上实现负载平衡。消费者组确保所有消费者彼此交谈,并且消息不会被处理两次。
但在现实生活中,除非吞吐量非常高,否则您不会遇到这个问题,因为即使只有一个消费者,rabbit mq也可以非常快地处理数据。
从技术上讲,与Rabbit MQ提供的特性集相比,Kafka提供了一个巨大的超特性集。
如果问题是
Rabbit MQ技术上比Kafka更好吗?
那么答案是
No.
但是,如果问题是
从业务角度看Rabbit MQ比Kafka好吗?
那么,答案是
在某些商业场景中,可能是“Yes”
从业务角度来看,Rabbit MQ可以比Kafka更好,原因如下:
Maintenance of legacy applications that depend on Rabbit MQ Staff training cost and steep learning curve required for implementing Kafka Infrastructure cost for Kafka is higher than that for Rabbit MQ. Troubleshooting problems in Kafka implementation is difficult when compared to that in Rabbit MQ implementation. A Rabbit MQ Developer can easily maintain and support applications that use Rabbit MQ. The same is not true with Kafka. Experience with just Kafka development is not sufficient to maintain and support applications that use Kafka. The support personnel require other skills like zoo-keeper, networking, disk storage too.
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.
Kafka和RabbitMQ的5个主要区别:
应该选择哪个消息传递系统,还是应该更改现有的消息传递系统?
以上问题没有唯一的答案。当您必须决定使用哪个消息传递系统或是否应该更改现有系统时,一种可能的检查方法是“评估范围和成本”
如果你有复杂的路由需求,想要一个内置的GUI来监控代理,那么RabbitMQ可能是最适合你的应用程序。否则,如果你正在寻找一个消息代理来处理高吞吐量并提供对流历史的访问,Kafka可能是更好的选择。
推荐文章
- RabbitMQ / AMQP:单队列,同一消息的多个消费者?
- 从RabbitMQ中删除所有队列?
- RabbitMQ与通道和连接之间的关系
- 重新安装后无法访问RabbitMQ web管理界面
- 卡夫卡在控制台生产
- 删除芹菜/ rabbitmq中所有挂起的任务
- 在卡夫卡的作品中,有没有一种方法可以清除这个话题?
- 是什么决定了Kafka的消费抵消?
- 为什么我们需要像RabbitMQ这样的消息代理而不是像PostgreSQL这样的数据库?
- 消息队列vs. Web服务?
- 使用Kafka作为(CQRS)事件存储。好主意吗?
- 理解Kafka主题和分区
- 何时在Kafka上使用RabbitMQ ?
- ActiveMQ或RabbitMQ或ZeroMQ或