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.