RabbitMQ
ActiveMQ
Redis
High Volume Messaging
Message Brokers

RabbitMQ / ActiveMQ or Redis for over 250,000 msg/s

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

When it comes to handling high throughput and mass volumes in message processing, three prominent players emerge: RabbitMQ, ActiveMQ, and Redis. Here, we'll delve into their capabilities, configurations, and best practices for handling over 250,000 messages per second.

RabbitMQ

RabbitMQ is one of the most popular open-source message brokers, noted for its reliability, clustering, and robust messaging capabilities. It supports multiple messaging protocols, primarily AMQP (Advanced Message Queuing Protocol).

High Throughput Handling in RabbitMQ:

To achieve high throughput, RabbitMQ can be configured in a cluster setup to distribute the load across several nodes. Here’s a general approach to optimize RabbitMQ for high traffic:

  • Increase Network Bandwidth and Resources: Provision high network bandwidth and ample CPU/RAM resources.
  • Clustering and Load Balancing: Deploy RabbitMQ in a cluster and use load balancers to distribute traffic among nodes.
  • Queue Design: Use multiple queues to distribute and balance the load.
  • Tuning and Configurations:
    • Increase the frame size to maximize network utilization.
    • Adjust the prefetch count to control how many messages are delivered to consumers before acknowledgments are received.

Example Configuration:

ini
1[
2  {rabbit, [
3    {frame_max, 131072},
4    {heartbeat, 600}
5  ]}
6]

ActiveMQ

ActiveMQ, another robust open-source messaging broker, supports a variety of Cross Language Clients and Protocols from Java, C, C++, Python, etc., with powerful features such as high availability, clustering, and client-side acknowledgements.

High Throughput Handling in ActiveMQ:

ActiveMQ can handle large-scale messaging through the following optimizations:

  • Broker Networks: Implement a network of brokers to efficiently route traffic.
  • KahaDB Persistence Adapter: Use the KahaDB storage mechanism designed for fast persistence.
  • Asynchronous Dispatch: Enable asynchronous dispatch to boost consumer performance.
  • Connection Settings Optimization: Maximize broker performance with optimized connection settings.

Example Configuration:

xml
<persistenceAdapter>
  <kahaDB directory="kahadb"/>
</persistenceAdapter>

Redis

Redis, primarily known as an in-memory data structure store, also functions as a message broker with Pub/Sub capabilities, streamlined for handling high volumes of messages with minimal delay.

High Throughput Handling in Redis:

To use Redis for messaging at very high throughput rates, consider the following:

  • In-memory Operations: All operations are in-memory, which drastically reduces access times.
  • Data Persistence: Optional data persistence configurations can be adjusted based on the use-case, impacting throughput if enabled.
  • Horizontal Scaling: Use Redis clustering for horizontal scaling.

Example Usage:

bash
1# Subscriber
2redis-cli subscribe channel_name
3
4# Publisher
5redis-cli publish channel_name "message"

Comparative Summary

Below is a table summarizing the key features of RabbitMQ, ActiveMQ, and Redis for handling over 250,000 messages per second:

FeatureRabbitMQActiveMQRedis
Protocol SupportAMQP, MQTT, HTTP, STOMPAMQP, MQTT, HTTP, JMS, STOMPRedis proprietary protocol
Broker TypeMessage BrokerMessage BrokerData Structure Store
PersistenceDisk-based, DurablePluggable persistenceSnapshots, AOF
High AvailabilityClustering, Mirrored QueuesShared File System, Master-SlaveRedis Cluster
Best Use CaseEnterprise grade messagingJMS compatible enterprise messagingReal-time messaging, caching

Conclusion

Choosing the right message broker depends heavily on the specific requirements of your project. RabbitMQ and ActiveMQ are more suited to traditional enterprise messaging with strong durability guarantees, whereas Redis, with its minimal latency in-memory processes, excels in scenarios where speed is paramount. Implementing any of these solutions at a scale supporting over 250,000 messages per second will require careful tuning, resource allocation, and possibly custom configuration to meet optimal performance metrics.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.