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.
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:
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:
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:
Comparative Summary
Below is a table summarizing the key features of RabbitMQ, ActiveMQ, and Redis for handling over 250,000 messages per second:
| Feature | RabbitMQ | ActiveMQ | Redis |
| Protocol Support | AMQP, MQTT, HTTP, STOMP | AMQP, MQTT, HTTP, JMS, STOMP | Redis proprietary protocol |
| Broker Type | Message Broker | Message Broker | Data Structure Store |
| Persistence | Disk-based, Durable | Pluggable persistence | Snapshots, AOF |
| High Availability | Clustering, Mirrored Queues | Shared File System, Master-Slave | Redis Cluster |
| Best Use Case | Enterprise grade messaging | JMS compatible enterprise messaging | Real-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
- RabbitMQ / AMQP single queue, multiple consumers for same message?
- RabbitMQ + C# + SSL
- RabbitMQ + Memory Limits
- RabbitMQ ** WARNING ** Mnesia is overloaded
- RabbitMQ and Delivery Guarantees in Distributed Database Transaction
- Rails API - Process multiple transactions in parallel - Balanced payments
- Rabbitmq Ack or Nack, leaving messages on the queue
- RabbitMQ Ack Timeout

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack 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.