RabbitMQ vs Kaleidoscope: How the new broker achieves 12x message throughput (1100% speedup)
Tags: cloud, microservices, dotnet, backend
Published: 2024-06-12 09:03:21

In today's data-driven world, a fast and efficient message broker is essential for building efficient and scalable applications. In this blog post, we'll delve into a comparison between RabbitMQ, a well-established message broker, and Kaleidoscope, a new high-performance broker from the [Phoesion Glow](https://glow.phoesion.com) framework. We'll take a close look at their benchmark results to see how they perform in real-world scenarios.
  

## Overview of RabbitMQ and Kaleidoscope

**RabbitMQ** is one of the most popular message brokers available.
It implements the Advanced Message Queuing Protocol (AMQP) and is renowned for its reliability, robustness, and extensive feature set, making it a staple in many production environments.

**Kaleidoscope**, is a new transient message broker, written entirely in .NET 8.0. It is engineered to deliver high performance as it was designed to be the backbone of [Phoesion Glow](https://glow.phoesion.com), a cloud backend service development and cluster management solution. In peer-to-peer _(P2P)_ mode, the Kaleidoscope broker acts as the routing authority, sending peer/routing updates to the clients, while the clients form a P2P mesh and can send data directly to each other, thus removing significant resource overhead _(cpu/memory/networking)_ from the broker and improving throughput and latency for the clients.


  


## Benchmark Results

The benchmark tests yielded the following results:

| Broker | Message Throughput | Latency |
|------------|----------|-----------|
| Kaleidoscope (Normal) |  140,000 | 0ms |
| Kaleidoscope (P2P) | **710,000** | 0ms |
| RabbitMQ - Direct exchange | 60,000 | 80ms |
| RabbitMQ - Topic exchange | 40,000 | 80ms |

- Message Throughput: messages per second _(higher is better)_
- Latency: time _(milliseconds)_ for the first message to arrive

### Charts

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fgodupd72bdres33bbtt.png)

_Another chart without Kaleidoscope P2P mode, comparing the performance using the same topology_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pof97vzvim6bqu050epn.png)

These results highlight a significant performance advantage for Kaleidoscope, especially in P2P mode.


  


## Benchmark Setup

To provide a fair comparison, both RabbitMQ and Kaleidoscope were tested under the same conditions:

- **Hosting**: Both broker service and benchmark client run on the same machine, using the loopback interface (127.0.0.1) to ensure networking consistency.
- **Hardware**: The same hardware setup and machine were used for both tests to ensure consistency.
- **Metrics**: The primary metric was message throughput, measured in messages per second. The latency of the first message was also measured as a secondary metric.
- **Scope**: The scope of the benchmark includes both broker and client libraries (as they would be used in a real-world application). For RabbitMQ the "RabbitMQ.Client" library is used.

#### Machine specifications: 

- **CPU**: Intel Core i7-7700K @ 4.20GHz 
- **Memory**: 32.0 GB @ 2133 MHz
- **OS**: Windows 10 (22H2)

#### Benchmark design: 

- **OS Processes**: We have one broker process and one benchmark-app process. 
- **Benchmark-app**: will have 2 connections to the broker, one for the producer and one for the consumer. 
- **Producer**: spawns 40 concurrent C# Tasks that will flood-send messages to the broker.
- **Consumer**: counts the received messages and once all messages are received the benchmark is completed.
- **Payload**: 250 byte-array _(pre-serialized)_ message.

#### Broker setup: 

- The brokers will have one exchange, with a binding to one queue. The queue must NOT be exclusive since in a real-world scenario there will be multiple consumers (future benchmark). 
- For RabbitMQ, both 'Topic' and 'Direct' exchange types were tested, while Kaleidoscope uses only a 'Topic'-like exchange.
- Both brokers use transient queues and messages

#### Constraints: 

- No messages are allowed to be lost, so Acknowledgments must be enabled in both brokers.
- No duplicate messages are allowed.


  

## Performance Analysis

#### P2P mode
- Kaleidoscope: Achieving an impressive 710,000 messages/second, making it highly suitable for applications requiring rapid, low-latency communication between endpoints.
- RabbitMQ: P2P mode is not supported.

#### Normal mode
- Kaleidoscope: Even in normal mode, Kaleidoscope's throughput of 140,000 messages/second more than doubles RabbitMQ's performance, indicating its efficiency in handling standard messaging tasks.
- RabbitMQ: Handles 40.000 to 60,000 messages/second, which, while solid, is outpaced by Kaleidoscope.

#### Exchange type
- Kaleidoscope: Only supports 'Topic' exchange
- RabbitMQ: The 'Direct' exchange type, with its reduced overhead, offers better performance than the 'Topic' exchange but is suited for more specific scenarios


  

## Use cases

While both brokers can be used similarly, each is uniquely designed with specialized features tailored to their specific use cases.
- **RabbitMQ**: Better queuing features like persistence, dead-letter handling, and job-scheduling
- **Kaleidoscope**: Faster messaging/RPC throughput with low latency, orchestrating clients in p2p to reduce _(CPU/network)_ overhead, tunneling and streaming as a service-bus for cloud backend.


  


## Topology

These diagrams show how data move in different setups:
- RabbitMQ using Topic/Direct exchanges. \
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nfmi51k3fkdjnrfw3lu8.png)
- Kaleidoscope in Normal mode. \
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r64ck4vdfsn4q4aa2rt1.png)
- Kaleidoscope in P2P mode.\
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhd744p9968232kpzq70.png)


  

## Conclusion

These benchmarks suggest that while RabbitMQ remains a reliable and feature-rich option, Kaleidoscope offers substantial performance benefits, particularly for high-throughput applications. The higher message throughput can lead to more responsive systems and better utilization of resources, which is crucial for modern, data-intensive applications.

Kaleidoscope is not available _(documented/supported)_ as a standalone product, but instead, it serves as the backbone of the [Phoesion Glow](https://glow.phoesion.com) framework by interconnecting all cloud components/services, providing significant performance benefits with its high message throughput and low latency.

As always, it's important to consider your specific requirements and test in your environment to determine the best fit for your needs. If you have any questions or insights based on your experiences with these message brokers, feel free to share them in the comments below!

More benchmarks are needed to get the full picture. Some benchmarks planned for the future include:
- Test on Linux OS
- Test using multiple machines with producer, broker and consumer each running on a separate machine
- Test using multiple consumers.
- Test clustering

Stay tuned for more insights and benchmarks as we continue to explore the capabilities of the latest messaging technologies!


  


## Source Code

Source code is available at [https://github.com/gepa21/broker_benchmark](https://github.com/gepa21/broker_benchmark)

More info about [getting started with Phoesion Glow](https://dev.to/gepa21/getting-started-with-phoesion-glow-the-backend-service-development-solution-for-human-beings-437e)