- What is the difference between a queue and a topic?
A queue delivers each message to one consumer. A topic delivers each message to every subscribed consumer. Queues are for distributing work (competing consumers); topics are for broadcasting events (fan-out). Pub/sub systems like Google Pub/Sub or AWS SNS offer both, often combined: a topic fans out to multiple queues, and each queue delivers to one consumer per message.
- What is exactly-once delivery and why is it hard?
Exactly-once means each message is processed precisely once, no duplicates and no losses. Achieving it requires transactional coordination across producer, queue, and consumer, which is expensive in latency and complexity. In practice, most systems achieve "at-least-once delivery plus idempotent processing", which produces exactly-once effects at the cost of writing every consumer idempotently.
- Should I use a queue or a database as a work queue?
A database can act as a queue (jobs table with status column), and for low volume it is perfectly fine. At higher volume, database queues suffer from lock contention, polling overhead, and poor throughput. Purpose-built queues (SQS, RabbitMQ, Kafka) are designed for the throughput and durability requirements of production messaging. The right answer depends on scale: start with a database if volume is modest; move to a dedicated queue when the volume justifies the operational cost.
- How do I handle a poison message?
Configure a maximum retry count and a dead letter queue. After N failed attempts, the queue moves the message to the DLQ instead of retrying forever. The DLQ is monitored separately; humans investigate and either fix the message and re-inject it, or discard it. Without a DLQ, a single malformed message can block an entire pipeline.
- What is backpressure and how does it relate to queues?
Backpressure is the mechanism by which a system signals its inability to accept more work. In a queue-based pipeline, backpressure takes the form of a growing backlog: as the queue fills, either the producer slows down, the queue rejects new messages, or the backlog grows until it triggers an alert. Configuring backpressure correctly means deciding which of those three behaviors is acceptable, per queue.