StreamHub uses RabbitMQ for task queues (transcode jobs with priority routing) and Kafka for event streams (viewer analytics, audit logs, and cross-service fan-out). Picking the wrong one costs operability or replay capability.
Mental model difference
| Aspect | RabbitMQ (smart broker) | Kafka (dumb broker, smart consumers) |
|---|---|---|
| Data model | Messages deleted after ack | Append-only log retained by time/size |
| Delivery | Broker pushes to consumers | Consumers pull at their offset |
| Routing | Exchanges, bindings, routing keys | Topics + partitions; no built-in routing |
| Replay | Not designed for replay | Reset offset and re-read history |
| Throughput | Thousands/sec per queue | Millions/sec per cluster |
| Best for | Task queues, RPC, priority jobs | Event streaming, analytics, audit |
Data model
RabbitMQ (smart broker)Messages deleted after ackKafka (dumb broker, smart consumers)Append-only log retained by time/sizeDelivery
RabbitMQ (smart broker)Broker pushes to consumersKafka (dumb broker, smart consumers)Consumers pull at their offsetRouting
RabbitMQ (smart broker)Exchanges, bindings, routing keysKafka (dumb broker, smart consumers)Topics + partitions; no built-in routingReplay
RabbitMQ (smart broker)Not designed for replayKafka (dumb broker, smart consumers)Reset offset and re-read historyThroughput
RabbitMQ (smart broker)Thousands/sec per queueKafka (dumb broker, smart consumers)Millions/sec per clusterBest for
RabbitMQ (smart broker)Task queues, RPC, priority jobsKafka (dumb broker, smart consumers)Event streaming, analytics, audit
Amazon MSK event pipeline
RabbitMQ patterns
Exchange types
- Direct: Route by exact routing key —
transcode.hd→ HD worker queue. - Fanout: Broadcast to all bound queues — deploy notifications to every service.
- Topic: Pattern match on routing key —
video.*.readymatchesvideo.hd.ready. - Headers: Route by message header attributes — multi-tenant routing by
tenant_id.
# RabbitMQ topology (pseudo-config)
exchanges:
- name: streamhub.tasks
type: topic
queues:
- name: transcode.hd
bindings:
- exchange: streamhub.tasks
routing_key: transcode.hd
- name: transcode.sd
bindings:
- exchange: streamhub.tasks
routing_key: transcode.sd
Kafka patterns
Kafka building blocks
- Topic: Named log split into ordered partitions.
- Partition: Unit of parallelism — one consumer per partition in a group.
- Consumer group: Competing consumers share partition assignment.
- Offset: Consumer's read position — commit after processing for at-least-once.
- Retention: Messages kept 7 days (configurable) regardless of consumption.
# Kafka topic config (pseudo)
topics:
- name: viewer.events
partitions: 24
replication_factor: 3
retention_ms: 604800000 # 7 days
cleanup_policy: delete
Partition key = streamer_id keeps all events for one streamer ordered on one partition.
When to pick which
| Use case | Pick | Why |
|---|---|---|
| Transcode job queue with priorities | RabbitMQ | Smart routing, per-message ack, DLQ built-in |
| Viewer analytics event stream | Kafka | High throughput, replay for batch jobs |
| Payment event bus | Kafka | Audit trail, multiple consumers, retention |
| Delayed retry with TTL | RabbitMQ | Per-message TTL and dead-letter exchanges |
| Cross-region event replication | Kafka MirrorMaker | Log-based replication at scale |
Transcode job queue with priorities
PickRabbitMQWhySmart routing, per-message ack, DLQ built-inViewer analytics event stream
PickKafkaWhyHigh throughput, replay for batch jobsPayment event bus
PickKafkaWhyAudit trail, multiple consumers, retentionDelayed retry with TTL
PickRabbitMQWhyPer-message TTL and dead-letter exchangesCross-region event replication
PickKafka MirrorMakerWhyLog-based replication at scale
StreamHub hybrid architecture
Cloud building blocks toolbox
API writes to RabbitMQ for immediate task dispatch; workers publish results to Kafka for downstream fan-out. Analytics team consumes Kafka independently without touching the task queue.
Quick recall
Everything you need if you only revisit this box.
- RabbitMQ: smart broker, push delivery, messages deleted after ack — great for task queues.
- Kafka: append-only log, pull by offset, retained for replay — great for event streams.
- Kafka partitions provide ordering within a partition; partition key controls co-location.
- Consumer groups in Kafka enable competing consumers and independent replay groups.
- StreamHub uses RabbitMQ for jobs, Kafka for events — hybrid is common at scale.
- Always design Kafka consumers to be idempotent; offsets commit after processing.
Test yourself
Answer these before moving on — recall is what makes it stick.