SD System Design In Depth
0%
lesson system-designqueuesstreams

Task queue vs event stream

Module 4.2: Asynchronous Workflows & Partitioned Logs Updated Sep 17, 2026
📄 Cheat Sheet
Kafka vs RabbitMQ
Hello Interview Kafka vs RabbitMQ Watch on YouTube ↗

Hello Interview contrasts RabbitMQ's per-message acknowledgement and deletion with Kafka's retained, offset-based log, which is exactly the task-queue versus stream divide. The current video (also mislabelled as ByteByteGo) only covers queues.

0:00 / --:--

The Architectural Divide: Message Queues vs Event Streams

Engineers frequently confuse message task queues (RabbitMQ, Amazon SQS, Celery) with distributed event streams (Apache Kafka, Redpanda, AWS Kinesis). While both buffer asynchronous data, they represent fundamentally different architectural models.

Comparison: Task Queue vs Partitioned Event Stream

flowchart TD subgraph TaskQueue ["Task Queue: Claim, Ack, Redeliver"] P1["Producer"] -->|"Push Job"| Q["Central Queue FIFO"] Q -->|"Deliver Job"| W1["Worker 1 (Processes Job)"] Q -->|"Deliver Job"| W2["Worker 2"] W1 -->|"Ack completed job"| Q NoteA["Broker tracks availability and in-flight ownership; retention varies."] end subgraph EventStream ["Event Stream (Kafka / Kinesis): Append-Only Commit Log"] P2["Producer"] -->|"Append Event"| Log["Partition Log [0, 1, 2, 3, 4, 5, 6, 7]"] Log -->|"Read from Offset 2"| CG1["Consumer Group: Analytics (Offset: 2)"] Log -->|"Read from Offset 6"| CG2["Consumer Group: Fraud Detection (Offset: 6)"] NoteB["Data is immutable on disk. Multiple consumer groups read independently and replay."] end

Detailed Tradeoff Matrix

DimensionTask Queue (RabbitMQ / SQS)Event Stream (Kafka / Redpanda)
Message LifecycleUsually tracks each job through available, leased/in-flight, acknowledged, and redelivery states; deletion or retention behavior is broker-specific.Records are retained by time or size policy independently of one consumer group's progress.
ReplayabilityOften limited after acknowledgement, though dead-lettering, mirroring, or explicit retention can preserve history.Possible while records remain retained; replay must still handle changed code, schemas, and duplicate effects.
Consumer TrackingBroker commonly tracks availability, lease/visibility, acknowledgement, and redelivery per job.A group commits progress per partition, plus application state needed to make effects and retries safe.
Ordering GuaranteesDepends on queue type, worker concurrency, leases, and retries.Offsets order records within a partition; concurrent handlers and retries can still complete side effects out of order.
Throughput ProfileMeasure with the required payload, durability, replication, partition count, acknowledgement policy, and consumer work; product labels do not determine a universal rate.

Worked example: the same workload on each

An image-processing workload: 2,000 jobs per second, each taking 50 ms to 30 s (heavily skewed).

  • SQS or RabbitMQ: 500 workers each pull the next job. A 30-second job occupies one worker while the others continue. Scale by adding workers, and there is no partition limit.
  • Kafka with 50 partitions: at most 50 consumers in a group. A 30-second job at offset 1,000 of partition 7 holds up every later message in partition 7 unless the consumer hands work to an internal thread pool, which then complicates offset commits.

Now an order-events workload: 5,000 OrderPlaced events per second, needed by billing, search, the email service and a data lake, with the ability to replay the last 7 days after a bug fix. On Kafka this is one topic with 7-day retention and four consumer groups, each with its own offsets, and a replay is an offset reset. On a queue it would take four queues fed by a fan-out, and no replay once messages are acknowledged.

Semantics side by side

AspectTask queue (SQS, RabbitMQ classic)Log stream (Kafka, Kinesis, Pulsar)
Unit of trackingPer message: in flight, acked, redeliveredPer partition: a committed offset
After consumptionDeletedRetained until time or size limits
Multiple consumers of one messageNeeds a fan-out (SNS to SQS, exchanges)Native: one consumer group per use
ParallelismAny number of workersAt most the partition count per group
Per-message retry or delayNative (visibility timeout, DLQ, delay)Build it with retry topics
OrderingBest effort (SQS FIFO per message group)Strict per partition
ReplayNo, unless archivedYes, within retention

Convergence

The line is blurring. RabbitMQ Streams add a retained log, Kafka share groups add queue-like per-record acknowledgement, and Pulsar supports both subscription models on one topic. In interviews, reason about the semantics you need (per-message ack versus retained log, fan-out, replay, ordering) rather than brand names.

Check yourself Question 1 of 3
Skewed job workload apply
From: Worked example: the same workload on each

You need to run 2,000 image-processing jobs per second, each taking between 50 ms and 30 s, consumed by a single service, with no need to replay history. Which design fits best?

Key Takeaways

Task queues coordinate ownership and acknowledgement of individual jobs; retention and deletion semantics vary by broker.
Event streams retain ordered partition records independently of a consumer group's committed progress, permitting replay within retention.
Use RabbitMQ/SQS for discrete background jobs; use Kafka for event-driven pub/sub, audit logs, and streaming analytics.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue