常见消息队列对比(ActiveMQZeroMQkafkaRabbitMQ)?

Posted Data+Science+Insight

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了常见消息队列对比(ActiveMQZeroMQkafkaRabbitMQ)?相关的知识,希望对你有一定的参考价值。

常见消息队列对比?

消息队列是分布式应用间交换信息的重要组件,消息队列可驻留在内存或磁盘上, 队列可以存储消息直到它们被应用程序读走。

通过消息队列,应用程序可以在不知道彼此位置的情况下独立处理消息,或者在处理消息前不需要等待接收此消息。

所以消息队列可以解决应用解耦、异步消息、流量削锋等问题,是实现高性能、高可用、可伸缩和最终一致性架构中不可以或缺的一环。

现在比较常见的消息队列产品主要有ActiveMQ、RabbitMQ、ZeroMQ、Kafka、RocketMQ等。

Kafka与常见消息队列的对比

RabbitMQ

  • Erlang编写
  • 支持很多的协议:AMQP,XMPP, SMTP, STOMP
  • 非常重量级,更适合于企业级的开发
  • 发送给客户端时先在中心队列排队。对路由,负载均衡或者数据持久化都有很好的支持。

Redis

  • 基于Key-Value对的NoSQL数据库
  • 入队时,当数据比较小时Redis的性能要高于RabbitMQ,而如果数据大小超过了10K,Redis则慢的无法忍受;
  • 出队时,无论数据大小,Redis都表现出非常好的性能,而RabbitMQ的出队性能则远低于Redis。

ZeroMQ

  • 号称最快的消息队列系统,尤其针对大吞吐量的需求场景。
  • 高级/复杂的队列,但是开发人员需要自己组合多种技术框架,技术上的复杂度是对这MQ能够应用成功的挑战。
  • 具有一个独特的非中间件的模式,不需要安装和运行一个消息服务器或中间件
  • ZeroMQ仅提供非持久性的队列,也就是说如果宕机,数据将会丢失。

ActiveMQ

  • 类似于ZeroMQ,它能够以代理人和点对点的技术实现队列。
  • 类似于RabbitMQ,它少量代码就可以高效地实现高级应用场景。

Kafka/Jafka

  • 高性能跨语言分布式发布/订阅消息队列系统
  • 快速持久化,可以在O(1)的系统开销下进行消息持久化;
  • 高吞吐,在一台普通的服务器上既可以达到10W/s的吞吐速率;
  • 完全的分布式系统,Broker、Producer、Consumer都原生自动支持分布式,自动实现负载均衡;
  • 支持Hadoop数据并行加载,对于像Hadoop的一样的日志数据和离线分析系统,但又要求实时处理的限制,这是一个可行的解决方案。Kafka通过Hadoop的并行加载机制统一了在线和离线的消息处理。
  • 一个非常轻量级的消息系统,除了性能非常好之外,还是一个工作良好的分布式系统。


Message Oriented Middleware or MOM concept involves the exchange of data between different applications using messages asynchronously. Using this mechanism, applications are decoupled and senders and receivers exist without the knowledge of each other. It becomes the responsibility of the messaging system (Message Oriented Middleware) to transfer the messages between applications. Queues allow you to store metadata for processing jobs at a later
date. They can aid in the development of SOA (service-oriented architecture) by providing the flexibility to defer tasks to separate processes. When applied correctly, queues can dramatically increase the user experience of a web site by reducing load times.


Advantages of message queues:
•Asynchronous: Queue it now, run it later.
•Decoupling: Separates application logic.
•Resilience: Won't take down your whole application if part of it fails.
•Redundancy: Can retry jobs if they fail.
•Guarantees: Makes sure that jobs will be processed.
•Scalable: Many workers can process individual jobs in a queue.



Use cases of message queues:
•Sending/receiving data from a third-party APIs
•Communication between various application asynchronously
•Sending an e-mail, Uploading documents
•Running labour intensive processes

JMS vs AMQP
AMQP is an application-level standard for Message Oriented Middleware (MOM). JMS is a standard API for Java for communicating with MOM.
Two different Java applications using JMS could be using different MOM and hence still be unable to communicate. ActiveMQ is a MOM system with a JMS library that allows Java programs to access it using JMS, but it can't necessarily communicate with another JMS Java program using, say, WebLogic MOM.
Different AMQP MOM systems can interoperate with each other (assuming that they are using the same version of AMQP) since AMQP is a standard along the same lines as, say SMTP. There is no reason that an AMQP MOM system could not also provide a JMS library for its Java clients.


OpenSource Message Queue

1. RabbitMQ is one of the leading implementation of the AMQP protocol (along with ApacheQpid). Therefore, it implements a broker architecture, meaning that messages are queued on a central node before being sent to clients. This approach makes RabbitMQ very easy to use and deploy, because advanced scenarios like routing, load balancing or persistent message queuing,Negetive Ackowledgement(NACK), Requeing and Delay or Schedule messaging are supported in just a few lines of code. However, it also makes it less scalable and “slower” because the central node adds latency and message envelopes are quite big.

2. Apache ActiveMQ is the most popular and powerful open source messaging and Integration Patterns server.Supports many advanced featuressuch as Message Groups, Virtual Destinations, Wildcards and Composite Destinations.It makes for a reliable hub in any message-oriented enterprise application and integrates beautifully with Java EE containers,ESBs, and other JMS providers
ActiveMQ Apollo is a faster, more reliable, easier to maintain messaging broker built from the foundations of the original ActiveMQ- a new Gen ActiveMQ. It accomplishes this using a radically different threading and message dispatching architecture. Like ActiveMQ, Apollo is a multi-protocol broker and supports STOMP, AMQP, MQTT, Openwire, SSL, and WebSockets.

3. ZeroMQ is a very lightweight messaging system specially designed for high throughput/low latency scenarios like the one you can find in the financial world. Zmq supports many advanced messaging scenarios but contrary to ActiveMQ/RabbitMQ, you’ll have to implement most of them yourself by combining various pieces of the framework (e.g : sockets and devices).ZeroMQ is a lightweight message orientated socket implementation. It is also suitable
for in-process asynchronous programming. It is possible to run a "Enterprise Messaging System" over ZeroMQ, but you would have to implement a lot on your own.

4. Kafka is a high throughput distributed messaging system.Written and used by LinkedIn to offload processing of all page and other views .Defaults to using persistence, uses OS disk cache for hot data (has higher throughput then any of the above having persistence enabled).Supports both on-line as off-line processing.Kafka does work on the push - pull basic and capable of handling large scale real time streams.

5. Apache Qpid, an open-source messaging system, implements the Advanced Message Queuing Protocol. It provides transaction management, queuing, distribution, security,management, clustering, federation and heterogeneous multi-platform support.

6. IronMQ is an easy-to-use highly available message queuing service. It is available as a cloud service on Amazon and Rackspace as well as on-premise with Iron.io's enterprise offering.Features include a nice dashboard to manage queues, easy to create webhooks, unicast and multicast Push Queues, autoscaling alerts for worker processes, and error queues.An easy-to-
use highly available message queuing service. Built for distributed cloud applications with critical messaging needs. Provides on-demand message queuing with HTTPS transport, one-time FIFO delivery, message persistence,and cloud-optimized performance.


Message Queue Comparison


BenchMark / Performance

• ActiveMQ (https://activemq.apache.org/benchmark-tests.html)

• Apollo (http://activemq.apache.org/apollo/documentation/performance-scaling.html)

• RabbitMQ (http://www.rabbitmq.com/blog/)

• ZeroMQ (http://zeromq.org/results:ib-tests-v206)

• Apache Qpid (http://qpid.apache.org/releases/qpid-0.20/)

• Kafka (https://kafka.apache.org/07/performance.html)

Conclusion
• ActiveMQ or Apollo is simply the leader when it comes to ease of configariton and different persistentstore, at the cost of performance in persistence mode.ApacheMQ and Apache Qpid seems to bevery good among broker based MQ at performing without persistence.Apollo is better in terms of performance and reliability than ActiveMQ /Apache Qpid.

•Just like other brokers based MQ, RabbitMQ is is best sutable for advance messaging pattren having routing,load balancing.However, it also makes it less scalable and “slower” because the central node adds latency and message envelopes are quite big. However even in persistent mode RabbitMQ performs better than ActiveMQ or Apache Qpid.

• ZeroMQ broker outperforms all others for simple messaging pattern between application. This means that unless you have a need for complex broker features,ZeroMQ is a perfect message dispatcher among processes.If you want one application to send messages to another as quickly as possible, you need ZeroMQ.Its crazy fast for transient message.

•Kafka does work on the push - pull basic and capable of handling large scale real time streams.It also provide ordered message delivery.Kafka's performance is effectively constant with respect to data size so retaining lots of data will not be a problem.Kafka is ideal if you are looking for reliable distributed messaging system with good throughput.Kafka is used at LinkedIn and it handles over 10
billion message writes per day with a sustained load that averages 172,000 messages per second.

•IronMQ is good in case of distributed cloud based queueing.It integrates with application running in Amazon or Rackspace,but its commercial.

参考:Kafka与常见消息队列的对比

参考:常用消息队列介绍和对比

参考:较主流的消息队列的比较与选型

参考:ActiveMQ vs RabbitMQ vs ZeroMQ vs Apache Qpid vs Kafka vs IronMQ -Message Queue Comparision

参考:ActiveMQ vs RabbitMQ vs ZeroMQ

以上是关于常见消息队列对比(ActiveMQZeroMQkafkaRabbitMQ)?的主要内容,如果未能解决你的问题,请参考以下文章

常用消息队列介绍和对比

6种消息队列介绍和对比

MQ消息队列及常见MQ比较

消息队列小结

分享5款主流分布式MQ消息队列对比

超详细消息队列MQ使用时常见问题以及解决办法