| Users / Messages | Kafka | RabbitMQ | SQS |
|---|---|---|---|
| 100 users / 1K msg/sec | Works well; single broker or small cluster | Works well; single node or small cluster | Works well; fully managed, no setup needed |
| 10K users / 100K msg/sec | Needs multi-broker cluster, partitioning, replication | Needs clustering, federation; may face throughput limits | Handles scale easily; pay per request; latency may increase |
| 1M users / 1M+ msg/sec | Large cluster with many partitions; careful tuning needed | Scaling harder; may require sharding or multiple clusters | Scales automatically; cost and latency considerations rise |
| 100M users / 10M+ msg/sec | Very large cluster; complex management; high ops effort | Not ideal; likely multiple RabbitMQ clusters or redesign | Still scales; cost and throttling become major factors |
Kafka vs RabbitMQ vs SQS in HLD - Scaling Approaches Compared
Kafka: Broker disk I/O and network bandwidth limit throughput first because Kafka stores messages on disk and replicates them across brokers.
RabbitMQ: Broker CPU and memory become bottlenecks early due to message routing and in-memory queues.
SQS: Latency and cost become bottlenecks at very high scale since it is a managed service with request limits and pricing per request.
- Kafka: Add more brokers, increase partitions for parallelism, use replication for fault tolerance, optimize disk and network.
- RabbitMQ: Use clustering and federation to distribute load, shard queues, optimize routing, and offload consumers.
- SQS: Use multiple queues to distribute load, batch requests to reduce cost, and leverage AWS autoscaling for consumers.
- Kafka: 1 broker handles ~1000-5000 concurrent connections; 1 partition ~100K msg/sec; storage depends on retention (e.g., 1TB per broker for logs); network ~1 Gbps per broker.
- RabbitMQ: Single node handles ~10K msg/sec; clustering needed beyond that; memory usage grows with queue size; network bandwidth ~100-500 Mbps per node.
- SQS: Handles millions of requests per second; cost is $0.40 per million requests; storage is managed; bandwidth depends on message size and request volume.
Start by clarifying workload size and message patterns. Identify bottlenecks by scale. Discuss trade-offs: operational complexity (Kafka), ease of use (SQS), and flexibility (RabbitMQ). Propose scaling steps matching bottlenecks. Mention cost and latency impacts.
Your database handles 1000 QPS. Traffic grows 10x. What do you do first?
Answer: Add read replicas or caching to reduce load on the primary database before scaling vertically or sharding.
Practice
Solution
Step 1: Understand Kafka's design for streaming
Kafka is designed for high-throughput, distributed streaming where multiple consumers can read independently from the same stream.Step 2: Compare with RabbitMQ and SQS
RabbitMQ focuses on complex routing and guaranteed delivery with message removal, while SQS is a simple managed queue service without streaming capabilities.Final Answer:
Kafka -> Option CQuick Check:
High-speed streaming = Kafka [OK]
- Confusing RabbitMQ's routing with Kafka's streaming
- Assuming SQS supports multiple independent consumers reading the same message
- Choosing a generic queue like ActiveMQ without streaming focus
Solution
Step 1: Recall RabbitMQ message handling
RabbitMQ removes messages from the queue once they are consumed to ensure guaranteed delivery and avoid duplicate processing.Step 2: Eliminate incorrect options
Kafka stores messages for replay, SQS is managed cloud service, and RabbitMQ supports multiple consumers with routing.Final Answer:
It removes messages after they are consumed -> Option DQuick Check:
RabbitMQ message removal = It removes messages after they are consumed [OK]
- Thinking RabbitMQ stores messages indefinitely like Kafka
- Confusing SQS managed service with RabbitMQ
- Assuming RabbitMQ supports only one consumer
Solution
Step 1: Identify managed services for scalability
AWS SQS is a fully managed queue service that scales automatically without server management.Step 2: Compare with other options
Kafka and RabbitMQ require managing clusters or servers, while local queues lack scalability and reliability.Final Answer:
AWS SQS managed queue -> Option BQuick Check:
Simple, scalable, no server management = SQS [OK]
- Choosing Kafka or RabbitMQ without considering management overhead
- Assuming local queues scale well
- Confusing managed service with self-hosted
Solution
Step 1: Understand RabbitMQ message lifecycle
RabbitMQ deletes messages once consumed, preventing replay by multiple consumers independently.Step 2: Validate other options
RabbitMQ supports multiple consumers and guarantees delivery; scalability depends on setup but is not the main issue here.Final Answer:
RabbitMQ removes messages after consumption, so replay is not possible -> Option AQuick Check:
Message replay issue = RabbitMQ message removal [OK]
- Assuming RabbitMQ supports message replay like Kafka
- Thinking RabbitMQ lacks multiple consumer support
- Confusing delivery guarantees with replay capability
Solution
Step 1: Match requirements to system strengths
Kafka excels at high-throughput streaming with message retention and replay for multiple consumers.Step 2: Address complex routing needs
RabbitMQ provides advanced routing capabilities that Kafka lacks.Step 3: Combine systems for best fit
Use Kafka for event streaming and replay, RabbitMQ for routing messages to appropriate consumers.Final Answer:
Kafka for streaming and replay, RabbitMQ for routing -> Option AQuick Check:
Streaming + replay + routing = Kafka + RabbitMQ [OK]
- Using SQS for streaming or replay which it doesn't support
- Assuming RabbitMQ can handle large-scale streaming with replay
- Mixing roles of Kafka and RabbitMQ incorrectly
Ready to prove it?
Pass the test and this pattern moves unknown
