Queue
Description
A queue is a FIFO buffer that decouples producer from consumer in time, rate, and identity. The producer doesn’t have to wait for the consumer to finish processing; the consumer doesn’t have to keep up with the producer’s instantaneous rate. The queue absorbs the temporal mismatch and preserves order. The structural payoff is asynchrony with bounded memory (if the queue is bounded) and load-leveling (consumers see a smoothed rate, not the producer’s bursts). The diagnostic shape: any producer-consumer pair where their rates differ in the short term, where the work is independent enough to be batched-and-handed-off, and where order preservation (or partition-order preservation, in a sharded queue) matters. Queues are the load-bearing primitive under message brokers, async task systems, OS process scheduling, postal services, and most multi-stage industrial processes. Queue is structurally the buffer half of the bottleneck-buffer pair. Bottleneck names the rate-limiting step; buffer names the reservoir that smooths the upstream. Queue is the canonical implementation of the buffer. The vocabulary differs by community — message broker, work queue, task queue, mailbox, inbox — but the structural primitive is one.Triggers
User-initiated: User describes producer-consumer rate mismatch, wants to add asynchrony, or proposes decoupling components. Vocabulary cues: “queue,” “FIFO,” “message broker,” “work queue,” “task queue,” “Kafka,” “SQS,” “producer,” “consumer.” Agent-initiated: Engine notices a synchronous request-response pattern where the response isn’t immediately needed (the caller is waiting unnecessarily). Candidate inference: “this could be a queue — what’s the work item, who’s the consumer, and what’s the at-least-once-vs-exactly-once requirement?” Situation-shape signals: Producer-consumer rate mismatch; asynchronous processing acceptable; need to scale producer and consumer independently; need durability of in-flight work.Exclusions
- Synchronous response required — if the consumer’s output is needed in the caller’s request scope, the queue’s asynchrony is incompatible.
- No producer-consumer rate mismatch — if the producer always waits for the consumer anyway, the queue is overhead without benefit.
- Strict ordering across producers required globally — FIFO is per-queue (or per-partition in sharded queues); across-partition global ordering requires consensus, not just queueing.
- Memory-cost is dominant and load is well-controlled — for bounded systems with smooth rates, direct synchronous calls may be cheaper than queue infrastructure.
Structure
Relationships
- bottleneck-buffer — queue is the buffer; bottleneck is the consumer’s rate limit.
- backpressure — bounded queues signal backpressure via fullness.
- flow — queues are flow with explicit ordering and buffering.
- seam — queues are seams between async components.
- load-balancing — multiple consumers competing for a queue is the simplest load-balance.
- write-ahead-log — durable queues (Kafka) are structurally WALs promoted to architectural primitives.
Examples
Lines at the deli · business
Lines at the deli · business
Hospital triage / waiting rooms · medicine-and-health
Hospital triage / waiting rooms · medicine-and-health
Apache Kafka documentation and the original LinkedIn paper (Kreps et al., 2011) — the canonical durable-distributed-queu · computer-science
Apache Kafka documentation and the original LinkedIn paper (Kreps et al., 2011) — the canonical durable-distributed-queu · computer-science
CPU instruction reorder buffer · computer-science
CPU instruction reorder buffer · computer-science
Customer-service ticket systems · business
Customer-service ticket systems · business
Email inbox · computer-science
Email inbox · computer-science
A. K. Erlang, "The Theory of Probabilities and Telephone Conversations," *Nyt Tidsskrift for Matematik B*, 20, 33–39 (1909) — the founding paper of queueing theory. · mathematics
A. K. Erlang, "The Theory of Probabilities and Telephone Conversations," *Nyt Tidsskrift for Matematik B*, 20, 33–39 (1909) — the founding paper of queueing theory. · mathematics
Kafka / RabbitMQ / SQS / Pub-Sub · computer-science
Kafka / RabbitMQ / SQS / Pub-Sub · computer-science
Leonard Kleinrock, *Queueing Systems, Volume 1: Theory* (Wiley-Interscience, 1975) — the mathematical foundation of modern queueing theory. · mathematics
Leonard Kleinrock, *Queueing Systems, Volume 1: Theory* (Wiley-Interscience, 1975) — the mathematical foundation of modern queueing theory. · mathematics
Kleppmann (2017), Designing Data-Intensive Applications, Chapter 11 (Stream Processing); Tanenbaum, Modern Operating Systems (process scheduling queues); Hello Interview primer on message queues · computer-science
Kleppmann (2017), Designing Data-Intensive Applications, Chapter 11 (Stream Processing); Tanenbaum, Modern Operating Systems (process scheduling queues); Hello Interview primer on message queues · computer-science
OS process scheduler ready-queue · computer-science
OS process scheduler ready-queue · computer-science
Postal sorting facilities · transportation
Postal sorting facilities · transportation
Print spoolers · computer-science
Print spoolers · computer-science
queueing theory (Kleinrock, Queueing Systems; Erlang's loss formula); operations research literature · mathematics
queueing theory (Kleinrock, Queueing Systems; Erlang's loss formula); operations research literature · mathematics
Andrew S. Tanenbaum, *Modern Operating Systems* (Prentice Hall / Pearson, multiple editions) — process scheduling and the OS ready queue. · computer-science
Andrew S. Tanenbaum, *Modern Operating Systems* (Prentice Hall / Pearson, multiple editions) — process scheduling and the OS ready queue. · computer-science