Algocraft
/
System Design
/
Message Queues
← All Designs
📨
Message Queues
Decouple producers and consumers for async, resilient communication
Async
Decoupling
🎮 What you can do
Switch between Kafka and RabbitMQ
Set producers, partitions, and consumer count
Toggle
Lag Mode
to slow consumers and build a backlog
👁 What to watch
Messages stack in Kafka partitions, flow through RabbitMQ pipe
Consumer lag bar grows red when consumers fall behind
Throughput and lag stats update every second
Queue Type
Kafka
RabbitMQ
Producers
1
2
3
Partitions
1
2
3
4
Consumers
1
2
3
Rate
Slow
Normal
Fast
Lag Mode
🐢 Enable Lag Mode
Consumers process at 20% speed — watch lag accumulate
Controls
▶ Start
⏸ Pause
↺ Reset
Kafka
Partitioned commit log. Durable, replayable. Consumers track their own offset. Messages are ordered within a partition.
0
Total Produced
0
Total Consumed
0
Consumer Lag
0
Msgs/sec
Producers
Kafka Topic (1 Partition)
Consumers
When to Use
Order processing, analytics pipelines, microservice decoupling, event sourcing, log aggregation, real-time data streaming, IoT telemetry.
Trade-offs
At-least-once
vs
exactly-once
. Ordering only within partition. Dead Letter Queue for failures. Backpressure when consumers are slow.
Interview Tip
Kafka
consumer groups
— each group independently tracks offsets, enabling multiple independent views of the same stream of data simultaneously.