Kafka phù hợp cho event streaming với replay và throughput cao; RabbitMQ phù hợp cho task queue với routing phức tạp và TTL ngắn.
Kafka:
- Pull model: consumer tự pull theo tốc độ riêng
- Message retention: lưu trên disk theo retention policy (ngày/GB), có thể replay
- Throughput: hàng triệu msg/s, horizontal scale via partition
- Ordering: đảm bảo trong partition
- Routing: đơn giản (topic/partition), không có flexible routing
- Protocol: Kafka binary protocol
- Use case: event streaming, CDC, log aggregation, data pipeline, event sourcing
RabbitMQ:
- Push model: broker push đến consumer
- Message: xóa sau khi consumer ack
- Throughput: cao với quorum queues (500k+ msg/s trong equivalent workloads), scale phức tạp hơn Kafka
- Ordering: best-effort (không đảm bảo với multiple consumers)
- Routing: flexible (fanout/direct/topic/headers exchange)
- Protocol: AMQP, STOMP, MQTT
- Use case: task queue, RPC, microservices command, priority queue, complex routing
Chọn Kafka khi: cần replay, audit trail, multiple independent consumers, throughput > 100k/s, event-driven architecture.
Chọn RabbitMQ khi: cần complex routing, message priority, request-reply, team quen với message broker truyền thống.
Kafka suits event streaming with replay and high throughput; RabbitMQ suits task queues with complex routing and short TTLs.
Kafka:
- Pull model: consumers pull at their own pace
- Message retention: stored on disk per retention policy (days/GB), replayable
- Throughput: millions of msg/s, horizontal scale via partitions
- Ordering: guaranteed within a partition
- Routing: simple (topic/partition), no flexible routing
- Protocol: Kafka binary protocol
- Use cases: event streaming, CDC, log aggregation, data pipelines, event sourcing
RabbitMQ:
- Push model: broker pushes to consumers
- Message lifecycle: deleted after consumer ack
- Throughput: high with quorum queues (500k+ msg/s in equivalent workloads), harder to scale horizontally than Kafka
- Ordering: best-effort (not guaranteed with multiple consumers)
- Routing: flexible (fanout/direct/topic/headers exchanges)
- Protocol: AMQP, STOMP, MQTT
- Use cases: task queues, RPC, microservice commands, priority queues, complex routing
Choose Kafka when: you need replay, audit trails, multiple independent consumers, throughput > 100k/s, or an event-driven architecture.
Choose RabbitMQ when: you need complex routing, message priority, request-reply patterns, or your team is familiar with traditional message brokers.