Message queue selection is a common interview question. Each of the three mainstream MQs has its own strengths.
Quick Comparison
| Feature | Kafka | RabbitMQ | RocketMQ |
|---|---|---|---|
| Throughput | Extremely high (millions/sec) | Medium (tens of thousands/sec) | High (hundreds of thousands/sec) |
| Latency | Millisecond-level | Microsecond-level | Millisecond-level |
| Reliability | High (replicas + ISR) | High (mirrored queues) | Very high (synchronous disk flush) |
| Protocol | Proprietary protocol | AMQP | Custom (JMS-compatible) |
| Transactional Messages | Not natively supported | Not supported | Supported |
| Ordered Messages | Ordered within partitions | Not guaranteed | Supported |
| Delayed Messages | Not natively supported | Supported via plugins | Natively supported |
Ideal Use Cases for Each
Kafka: Log collection, stream processing, big data pipelines. Core strengths are high throughput + persistence + message replay.
RabbitMQ: Business decoupling, asynchronous calls. Core strengths are flexible routing + rich plugins.
RocketMQ: Alibaba's transaction, logistics, and payment scenarios. Core strengths are transactional messages + ordered messages + billion-level message accumulation.
How to Answer in an Interview
Selection mainly depends on the scenario. For big data stream processing, choose Kafka (high throughput, persistence); for traditional business decoupling, choose RabbitMQ (flexible routing); for financial-grade reliability requirements, choose RocketMQ (transactional messages, ordered messages).
Bonus Points
- Kafka's Topic is logically divided into multiple Partitions, which is the foundation of parallelism and scalability
- RabbitMQ's Exchange has four types (direct, topic, fanout, headers)
- RocketMQ is the core infrastructure behind Alibaba's Double 11, battle-tested under extreme conditions
It's best to have a working knowledge of all three. But go deep into at least one.
Comments
Comments are closed.