Cloud Parts

Queue, stream or pub/sub?

DimensionMessage queuesEvent streamsPub/sub
After a message is readDeleted once a worker confirms itKept until retention expires, from hours to foreverGone once delivered to current subscribers
Who gets each messageOne worker out of manyEvery consumer group, each at its own paceEvery subscriber gets a copy
Replay old messagesNoYes, from any offsetUsually not; Google Pub/Sub and SNS FIFO topics can replay retained messages
OrderingBest effort; FIFO queues existGuaranteed within a partitionUsually none
A slow consumerBacklog grows; add workersFalls behind and catches up laterMisses messages or slows delivery
Reach for it forBackground jobs and work distributionTelemetry, event history, many readersNotifications and fan-out
ExamplesSQS, RabbitMQKafka, Kinesis, Event HubsSNS, MQTT, Google Pub/Sub

Rule of thumb

If the work should happen once, use a queue. If several systems care and nobody needs history, use pub/sub. If you’d ever want to rewind, use a stream. Real systems often combine them, such as SNS fanning out to one SQS queue per subscriber.

Sources