Problem
Brokers limit message size and degrade when carrying megabytes. Large messages inflate memory, replication and network cost for every subscriber, even those that ignore the body.
Also known as: reference-based messaging, large payload offloading
Keep messages small by storing large payloads in external storage and sending only a reference through the broker.
Brokers limit message size and degrade when carrying megabytes. Large messages inflate memory, replication and network cost for every subscriber, even those that ignore the body.
Like a coat check ticket, the message carries a claim token while the heavy item sits in storage.
The order of operations matters: upload first, publish second, so a message never points at a missing object.
A related choice is how consumers authenticate to storage. Pre-signed URLs with short expiry let the message carry a self-contained link, but they can expire before a delayed consumer reads them. References plus consumer IAM roles avoid this, at the cost of managing permissions for every reader.
The producer uploads the blob, then publishes the reference. Consumers dereference lazily, verifying the checksum.
key = s3.put("payloads/" + uuid, body)
broker.publish("reports", {
"claim": key, "bytes": len(body),
"sha256": digest, "type": "report.ready"
})
Some client libraries implement the pattern transparently, offloading bodies above a threshold, for example a quarter of a megabyte. That is convenient, but you still own cleanup and must understand what happens on partial failure. Encrypt stored payloads, since object storage often outlives the broker and holds sensitive data, and tag objects with the message id for traceability.
Medium - object store plus broker
Medium - lifecycle and cleanup
Low - simple concept
Message published but payload upload failed or vice versa
Payload deleted before a slow consumer reads it
Orphaned blobs accumulate cost