Module 06 · Lesson 01

Queues and logs are not the same tool

A queue deletes a message when it is done; a log keeps it and lets readers move a bookmark.

Intermediate 8 min read Updated 2026-11-02

What you will be able to do

  • Choose between a work queue and a partitioned log for a given workload
  • Explain consumer groups, partitions and offsets
  • Estimate storage and throughput for a log-based pipeline
  • Recognise when a queue silently loses ordering guarantees

The mental model

Picture a queue as a stack of job tickets on a shared desk. Any worker can take the top ticket, and once the work succeeds the ticket is gone. This is what you want for sending an email, resizing a thumbnail, or charging a card: the work must happen once, and it does not matter which worker does it.

Now picture a log as a ledger that only grows. Writers append entries to the end. Each reader keeps its own bookmark, called an offset, and can move forward, pause, or rewind to the beginning and replay history. Deleting entries is a retention decision — seven days, thirty days — never a side effect of somebody processing them.

QuestionWork queuePartitioned log
Who sees a message?One consumer in the groupEvery consumer group sees all of it
Is data removed after processing?Yes, on acknowledgementNo, only when retention expires
Can I reprocess yesterday's data?Only if you kept a copyYes, reset the offset
OrderingBest effort, or per-group with limitsStrict within a partition
Typical jobSend email, transcode videoEvent stream, change data capture, metrics
Scaling readsAdd workers to split workAdd partitions and parallel readers

Partitions are the unit of everything

A log is split into partitions. Each partition is an ordered sequence stored on one broker, and a consumer group assigns each partition to exactly one consumer in that group. That gives you both guarantees at once: order is preserved inside a partition, and parallelism scales with the number of partitions — not the number of consumers.

Ordering is a partitioning decision, not a broker feature
If you partition orders by a random key, two events for the same order can land on different partitions and be processed out of order. Partition by the entity whose order matters — order id, user id, account id — and accept that a single hot key caps your parallelism.
Partition throughput
5-50 MB/s
Per partition, disk and network dependent
Retention at 10 MB/s
~864 GB/day
Multiply before promising 30-day replay
Consumer rebalance
seconds to a minute
Why long batches and short sessions fight
Offset commit interval
1-5 s
Sets the at-least-once redelivery window

That second row is the one interviews forget. Retention is a cost commitment. At 10 MB/s sustained, a thirty-day window is roughly 26 TB before replication; with three replicas it is closer to 78 TB. Say the number out loud before you promise replay.

Where queues still win

  • Long or variable jobs. A transcode that takes twenty minutes needs a visibility timeout, retries and dead-letter handling — queue semantics, not offsets.
  • Per-message delay and scheduling. "Run this in two hours" is natural in a queue and awkward in a log.
  • One-off work with a clear owner. If exactly one team consumes it and history has no value, a log is storage you will never read.
  • Priority lanes. A queue can serve high-priority work first; a log is read in order by design.

The combination that actually ships

Production systems usually run both. A log carries the facts — order placed, payment captured, item shipped — and small queue-backed workers do the slow side effects. The log is the source of truth for what happened; the queue is a scheduler for what should happen next.

Name the fact
Write the event in past tense with the entity id and the fields a consumer needs. If it needs a database lookup to be useful, the event is too thin.
Pick the key
Partition on the entity whose ordering matters. Check for hot keys before you commit.
Decide retention
State how long replay must work and compute the storage. Retention is a product requirement, not a default.
Make consumers idempotent
Assume every message arrives twice. Deduplicate on an event id or make the write naturally idempotent.
One sentence that scores points
"I'd put order events on a partitioned log keyed by order id, so per-order ordering is guaranteed, and use a queue for the email worker because that work needs retries and delay rather than replay."

Worth remembering

  • A queue is about distributing work; a log is about distributing facts.
  • Logs make replay, fan-out and reprocessing cheap because retention is a policy, not an accident.
  • A partition is the unit of ordering and the unit of parallelism in a log.
  • Adding consumers to a queue is easy; adding a second independent reader to a queue forces you to copy data.

Checkpoint

Answer all 3 questions to finish the lesson.
1. Three teams need the same order events, each at its own pace. What fits best?
A log lets independent consumer groups read the same history with their own offsets. A queue distributes each message to only one worker, so you would have to copy events three ways.
2. Events for the same account are processed out of order. Most likely cause?
Ordering is guaranteed only within a partition. If account events are spread by a random key, ordering is lost before the consumer ever sees the data.
3. You need a job retried in two hours if it fails. Which primitive is the better fit?
Per-message delay and visibility timeouts are queue semantics. A log gives you replay, but not scheduled redelivery of an individual unit of work.