Prompt
How do I choose a message broker for low-latency event data?
Latest observation
Choosing a message broker for low-latency event data depends on what you mean by “low latency” and what tradeoffs you can accept. The best choice usually comes down to a few dimensions:
1) Define your latency target
Be explicit about the goal:
- Sub-millisecond
- 1–10 ms
- 10–100 ms
- At-least-once vs exactly-once
- Peak throughput and message size
A broker that is great for millions of messages/sec may not be the best for very low end-to-end latency if it adds durability or replication overhead.
2) Pick the right architecture style
If you need the lowest latency and very high throughput
Consider:
-
Apache Kafka
Best for high throughput event streaming, durable logs, replayability, and ecosystem support.- Pros: great throughput, partitioning, durability, replay, strong tooling
- Cons: not usually the absolute lowest-latency option; latency depends on batching, replication, disk, and tuning
-
Redpanda
Kafka-compatible, often simpler to operate, with good latency characteristics.- Pros: Kafka API compatibility, lower ops overhead, strong performance
- Cons: still log-based, operational maturity depends on your environment
If you need ultra-low latency pub/sub
Consider:
-
NATS / NATS JetStream
- Pros: very low latency, simple, lightweight
- Cons: less suited than Kafka for very large durable event pipelines and long retention
-
Aeron
- Pros: extremely low latency, high performance
- Cons: more specialized, less “broker as a service” style, more engineering effort
If you need enterprise messaging with strong routing patterns
Consider:
- RabbitMQ
- Pros: flexible routing, mature, good for work queues and classic messaging
- Cons: generally not the best choice for extreme throughput or the lowest latency at scale
If you’re on managed cloud services
Consider:
- AWS Kinesis, Google Pub/Sub, Azure Event Hubs
- Pros: managed, scalable, easy to integrate
- Cons: latency can be good but is often less predictable than self-managed systems; vendor-specific tradeoffs
3) Match broker to use case
Choose Kafka / Redpanda if:
- You need event replay
- You need durable retention
- You have multiple consumers
- You need analytics / streaming pipelines
- You need a broad ecosystem
Choose NATS if:
- You need very low latency
- You want simple pub/sub
- You can tolerate shorter retention or use JetStream for durability
Choose RabbitMQ if:
- You need complex routing
- You have task queues
- You need mature messaging semantics more than high-scale streaming
Choose Aeron if:
- You are building a latency-sensitive trading, telemetry, or real-time control system
- You can invest in specialized engineering
4) Evaluate the latency drivers
Broker latency is affected by:
- Network round trips
- Replication factor
- Acknowledgment settings
- Batching
- Compression
- Disk flush policy
- Consumer fetch settings
- Message size
- Serialization/deserialization
- Client library performance
For low latency:
- Use smaller batches or tune batch intervals carefully
- Reduce replication if acceptable
- Avoid unnecessary compression for tiny messages
- Place producers, brokers, and consumers close together geographically
- Benchmark with your actual message schema and traffic pattern
5) Don’t ignore operational factors
A broker that is “fast” on paper may be wrong if it is hard to run reliably.
Check:
- Operational complexity
- Cluster scaling
- Failure recovery
- Monitoring
- Tooling
- Managed service availability
- Team familiarity
A slightly slower broker that your team can operate well may outperform a faster broker that is poorly tuned or fragile in production.
6) Benchmark with your workload
This is the most important step.
Create a test that reflects:
- Real message sizes
- Real producer/consumer concurrency
- Real ack and durability requirements
- Real network conditions
- Peak and sustained load
Measure:
- p50, p95, p99 latency
- throughput
- consumer lag
- CPU, memory, disk, and network usage
- recovery behavior after failures
Practical recommendation
A quick rule of thumb:
- Kafka / Redpanda: best general-purpose choice for durable event streams
- NATS: best for very low-latency messaging
- RabbitMQ: best for routing/work queues
- Aeron: best when latency is everything and you can specialize
If you tell me:
- your latency target,
- message rate,
- message size,
- whether you need replay/durability, and
- cloud vs on-prem,
I can recommend a specific broker and configuration direction.