Free preview

Evaluation: Functional Requirements

Why this matters: message deletion is the most interesting operation in the whole API, because the two available mechanisms produce entirely different systems from the same requirement.

Key takeaway

Five operations, all satisfied. The one worth real attention is delete, which has two implementations — offset tracking and visibility timeout — and the choice shapes everything downstream.

Queue creation and deletion

OperationHow it works
CreationThe frontend validates the client's details. The cluster manager assigns servers to the new queue and updates the metadata stores and caches via the metadata service
DeletionThe cluster manager deallocates the queue's storage space and removes the associated data from metadata stores and caches

Send and receive

Producers deliver messages to specific queues. At the backend, incoming messages are sorted by timestamps to preserve order and placed in the queue. Consumers then retrieve messages from these queues.

When the frontend receives a message, it identifies the primary host or cluster where the queue resides — depending on the replication model — and forwards the request to that entity for enqueueing.

Message deletion: two approaches

1. No immediate deletion (offset tracking)

Messages are not deleted upon consumption. Instead, the system maintains message order, and consumers track their own progress (offsets). A background job deletes messages once expiration conditions are met. Apache Kafka uses this model to allow multiple processes to consume the same message stream.

Queue (append-only log)

[ m1 ][ m2 ][ m3 ][ m4 ][ m5 ][ m6 ][ m7 ]
              ^                 ^
        consumer B        consumer A
         offset 3          offset 6

Both read the same messages. Neither removes anything.
A background job deletes older messages once they expire.

2. Visibility timeout

Messages are not deleted immediately but are made invisible to other consumers for a specific duration (visibility_timeout). The consumer must explicitly delete the message via an API call after processing. If the consumer fails to delete it within the timeout, the message becomes visible again.

The consumer is responsible for the final deletion. This ensures high durability: if a consumer crashes before processing is complete, the message reappears in the queue for another worker to handle.

This mechanism provides at-least-once delivery semantics. If a worker fails, the message eventually becomes visible again, ensuring it is processed at least once.

Dead-letter queues

"How should we handle messages a consumer fails to consume after the maximum number of retry attempts?"

A dead-letter queue handles messages that aren't consumed after the consumer has made the maximum number of processing attempts.

It also holds messages that can't be processed successfully due to:

  • The messages are intended for a queue that doesn't exist anymore.
  • The queue length limit is exceededalthough this would rarely occur with our current design.
  • The message expires due to per-message time-to-live (TTL).

A dead-letter queue is also important for determining the cause of failure and identifying system faults.

Key takeaway

All five operations are satisfied, and delete is where the design decisions live. Offset tracking turns the queue into a replayable log with natural fan-out; visibility timeout turns it into a work queue with per-message retry and at-least-once delivery. The dead-letter queue catches what neither can complete.

Interview signal by level

LevelWhat a strong answer sounds like
L4"The consumer deletes the message after it finishes processing."
L5Explains the mechanism: "receive makes the message invisible for a timeout rather than deleting it — if the consumer crashes it reappears for another worker, which is how we get at-least-once."
Staff+Chooses between the two and names the trap: "offsets if this is a stream with multiple readers and replay value; visibility timeout if it's a work queue needing per-message retry. And I'd size the timeout off p99.9 processing time and extend it via heartbeat, because a timeout expiring mid-processing duplicates work under exactly the load conditions that caused it — a slow consumer becomes a duplicate storm."

Next: the non-functional side.

Enjoying the preview?

Create a free account to unlock the rest of this course, the in-browser judge, and live AI mock interviews.

Sign up free to continue