Kafka vs ActiveMQ vs RabbitMQ vs ZeroMQ

Introduction

Communication between Microservices is very important. We cannot afford to lose even a single message in the communications. Hence, we had two different Communication methods for microservices. We call those are Asynchronous and Synchronous Communications. Synchronous communication will wait for the response but on the other hand, Asynchronous communication will not wait for the response to send the subsequent messages. In another article, we will discuss what is Asynchronous and Synchronous Communications in detail. In this article, we will Compare different popular Message Broker tools. Especially, Kafka vs ActiveMQ vs RabbitMQ vs ZeroMQ.

Note

In this entire article, we will address Requestor and Responder which means, the Requestor is the service or App which sends the message to other services to get a response. Responders are the Other services that will send the message in response to the Requestors’ message

Note: In this entire article, we will address Requestor and Responder which means, the Requestor is the service or App which sends the message to other services to get a response. Responders are the Other services that will send the message in response to the Requestors’ message

A glance of Asynchronous Communication

When you implement Asynchronous Communication in your microservices, Requester will send a message to another service and will not wait for the response, but it will continue sending further messages to other services as per the logic. The Receiver will get the message from the Requester whenever it gets free. In Microservices, Instance Resource and Network capacity are very important and at the same time, both will be utilized at max. As we discussed, we cannot afford to lose even a single message in microservice communication. Hence, to reduce the load to service resources, Asynchronous Communication is very useful in Microservices. Refer to the below Image.

Asynchronous Communication
Asynchronous Communication

Things to consider for Message Broker.

Just like another system in your software architecture, you need to consider some important facts before choosing your Message Broker. Those are.

  • Scalability – Ability to serve the number of messages sent per second.
  • Persistency – Data persistency is the Ability to retrieve messages after the crash
  • Service Capability – Capability of messaging between Point to Point or Point to Many services
  • Security – Features of securing communication with various technologies.

Based on the above facts, all the Messaging Brokers we are going to discuss are matured enough. But they have some differences which will help you to select an appropriate messaging Broker for your Microservices. Let’s compare the famous Messaging Brokers. Kafka vs ActiveMQ vs RabbitMQ vs ZeroMQ.

Comparing Kafka vs ActiveMQ vs RabbitMQ vs ZeroMQ

When we say Messaging Brokers, Kafka vs ActiveMQ vs RabbitMQ vs ZeroMQ are famous in the market and each one is having its own unique ability to fulfill the matured microservices ecosystem. So, Let’s compare these messaging brokers one by one.

Kafka

Kafka is Apache’s open-source project for distributed event streaming platform which is a better solution for Asynchronous Data Transmission. which is popular for high throughput which is useful for real-time data streaming messages like logs or metrics.

A single instance of Kafka is called Kafka Broker. Brokers will collect the messages from Requestors as Records. Each Broker will have a Topic which is like a category name that will store the record by category. Kafka Topics are again divided as Partitions which contain an unchangeable sequence of records. Since a Kafka Topic is having multiple Partitions, it will allow multiple requests for the responders.

How Kafka works
How Kafka works

Let’s discuss Kafka’s basic facts of message broker.

  • Scalability – Ability to serve the number of messages sent per second.
  • Persistency – Data persistency is the Ability to retrieve messages after the crash
  • Service Capability – Capability of messaging between Point to Point or Point to Many services
  • Security – Features of securing communication with various technologies.

ActiveMQ

ActiveMQ is another Opensource Project of Apache. This Implements Message-Oriented Middleware (MOM). ActiveMQ is using Java Message Service API in the backend. Hence it is a completed Java-based application. But it supports almost all the popular programming platforms like NodeJS, Python, Ruby, and more.

ActiveMQ supports two methods. One is Point-to-Point Communication which is called Messaging Queue that will collect all the messages from Requestors as Queue and distributes to the Responder in Round Robin Scheduling. Another Method is the Point-to-Many model called the Publish-Subscribe model. On this, Requester will Publish the message in the topic, and Responder will Subscribe to the Topic and start receiving the message Asynchronously.

How ActiveMQ works
How ActiveMQ works
  • Scalability – ActiveMQ supports Vertical Scaling which will allow 1000s of queues in a single broker.
  • Persistency – By default ActiveMQ uses persisted to dick/database. You have the option to make it non-persistent
  • Service Capability – ActiveMQ is capable of messaging between Point to Point or Point to Many services which we call Request-response and Publish-Subscribe Methods.
  • Security – ActiveMQ uses JAAS for Authentications and the entire communication is encrypted.

RabbitMQ

RabbitMQ is another Popular Opensource Messaging Queue Software which will also be used as Message Broker. It supports Messaging Technologies like Advanced Message Queuing Protocol (AMQP) Message Queuing Telemetry Transport (MQTT), Streaming Text Oriented Messaging Protocol (STOMP), and several other common protocols.

RabbitMQ has four major components. Requestor, Exchange, Queues, and Responder. In this, Requestor is the service or application which sends a message to get a response from other services. Responder is the service that will receive the message and give the response. Exchange is where the logic of routing messages takes place. It will decide in which way the message will be routed to the responder. For example, Fanout, Topic Based, Direct Routing, Header exchange, and more. The queue is the buffer like a system that will have the messages in sequence and maintain a certain mechanism to distribute the Message.

 

How RabbitMQ works
How RabbitMQ works
  • Scalability – RabbitMQ can be scaled both Horizontally (Nodes) and Vertically (Queues)
  • Persistency – RabbitMQ always writes the messages in the disk once it reaches the Queue. So, Data Persistency is highly maintained.
  • Service Capability – The Exchange concept of the RabbitMQ has message methods like Fanout, Topic Based, Direct Routing, Header exchange, and more.
  • Security – All the messages are SSL encrypted and the application access is powered by SAML/SSO.

ZeroMQ

ZeroMQ is a high-performance Opensource asynchronous Messaging platform. This is written in C++. ZeroMQ can implement different communication models like a request-reply model, Publish-Subscribe model, and Push and Pull model. ZeroMQ supports In-Process (INPROC), Inter-Process (IPC), TCP, and PGM.

As we already discussed, ZeroMQ supports the Asynchronous Request-Reply model and Publish and Subscribe model. The Request-Reply model means when the Requestor sends the message it will be collected in the ZeroMQ State Requester and will be kept in the queue. Once the Responder is available, it will be delivered. On another hand, the Publish-Subscribe model will have to publish block in the Requestor and Subscribe block in the Responder and the Message will be communication happens based on subscribing to the topic. Importantly, ZeroMQ is configured without Broker by default. You can enable broker in the configuration.

How ZeroMQ Works
How ZeroMQ Works
  • Scalability – ZeroMQ is limited to scale 16 core boxes in vertical scaling.
  • Persistency – Unfortunately, ZeroMQ does not support Data Persistency at this moment. But you can make it programmatically.
  • Service Capability – ZeroMQ supports Point-To-Point and Point-To-Many communication.
  • Security – For Authentication and Traffic Encryption, ZeroMQ used CurveZMQ protocol,

Conclusion

In this article, we have Compared and discussed the various popular Message Broker tools, Kafka vs ActiveMQ vs RabbitMQ vs ZeroMQ. In the upcoming article, we will discuss the Architectural and working methods of each tool. Also, we will discuss how to implement in popular programming platform and how to automate the infrastructural implementation and Continuous Integration of Message Broker powered Software. Stay tuned and subscribe DigitalVarys for more articles and study materials on DevOpsAgileDevSecOps and App Development.

2 thoughts on “Kafka vs ActiveMQ vs RabbitMQ vs ZeroMQ”

  1. Nice article, simple and well written. I notice some spelling mistakes in ActiveMQ feature break down, I think there it should be “disk” and i assume in the RabbitMQ picture the second responders should be “using Topic”

Leave a Reply