Table of Contents
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
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.
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.
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 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.
Let’s discuss Kafka’s basic facts of message broker.
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.
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.
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.
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 DevOps, Agile, DevSecOps and App Development.
Experienced DevSecOps Practitioner, Tech Blogger, Expertise in Designing Solutions in Public and Private Cloud. Opensource Community Contributor.