The cheapest retry system is the one that can recover a shipment update without sending it twice. For a small property-management SaaS, I would start with a managed queue and a dead-letter queue, then add delayed retries with bounded backoff. Self-host RabbitMQ only when broker control is worth the operational hours; use a cloud-native queue when the rest of the application already lives there.
Short answer: choose managed delivery for the first version, make every fan-out operation idempotent, and let measured latency and operator time decide when to move to a self-managed broker.
Here is the decision note I use before writing worker code:
| Path | Latency shape | Failure handling | Team cost | Good fit |
|---|---|---|---|---|
| Managed queue | Predictable regional hop | Built-in redrive and DLQ primitives | Low broker work, cloud-specific setup | A small SaaS shipping weekly |
| RabbitMQ | Tunable and often very fast inside one region | Flexible exchanges, queues, and dead lettering | You own upgrades, capacity, and alerts | Broker behavior is a product requirement |
| Cloud messaging service | Strong integration with its cloud | Service-specific retry and retention controls | Low broker work, cloud coupling | Workers already depend on that cloud |
The recommendation is deliberately boring. A property manager cares that a tenant sees “package delivered” once, not which exchange type moved the event. Revenue per engineering hour favors the design that a solo operator can explain during an incident.
Ship weekly.
What should a small SaaS measure before choosing delayed retry infrastructure?
Start with the event, not the queue. A shipment update has an immutable shipment ID, an update sequence, the property ID, and a list of subscribers. The producer stores that event durably, then creates one delivery job per subscriber or per channel. A worker may receive the same job again; the subscriber must still see one logical update.
Two measurements make the choice concrete. First is end-to-end latency: time from carrier webhook to the last successful subscriber delivery. Second is recovery cost: minutes to find a failed job, inspect its attempts, and redrive it safely. A queue that saves a few milliseconds but requires a specialist at 2 a.m. is not cheaper for a one-person company.
I keep a tiny ledger keyed by (shipment_id, update_sequence, subscriber_id). Before sending, the worker claims the key with an expiration long enough for the downstream request. After a successful response, it marks the key complete. If the process dies between those two operations, the next attempt can check the downstream idempotency key or reconcile the delivery record. Exactly-once execution is not a promise most queues make. Idempotency is the practical substitute.
Keep the retry schedule finite. A transient timeout can retry after 5 seconds, 30 seconds, and 5 minutes, with jitter. A permanent 4xx response should go directly to a review path. After the final attempt, the message belongs in a dead-letter queue (DLQ) with the original payload, attempt count, and last error category. Delayed retry is a scheduling tool, not a substitute for classifying failures.
The catch is retention. SQS, RabbitMQ, and managed messaging services expose different limits and semantics for visibility, retention, and redrive. Check the current service contract, then test it in the region where the workers run. I am not sure a generic “cheapest per message” comparison would survive your traffic pattern; batch size, cross-region transfer, and existing cloud commitments can dominate the invoice.
How do EU and US workers fan out one shipment update safely?
For EU and US properties, I use a single canonical event and regional consumers. The producer signs the webhook body with HMAC before it enters the queue, and each consumer validates the signature and sequence number. RFC 2104 describes the keyed-hash construction; the important engineering detail is to compare the received MAC in constant time and to reject stale sequence numbers.
The fan-out boundary should be explicit. One queue per delivery concern (email, SMS, resident portal, or partner webhook) keeps a slow channel from delaying the others. If a platform offers native topics, that can reduce plumbing, but it does not remove the need for per-subscriber idempotency. If it does not, publish separate jobs from the canonical event. That is more work, yet it makes retries and ownership visible.
Here is the shape of a Node.js worker. The queue client is an interface so the same policy can sit over SQS, RabbitMQ, or another managed service. The example omits provider-specific calls on purpose; those calls belong in one adapter, while business rules stay testable.
type ShipmentJob = {
shipmentId: string;
updateSequence: number;
subscriberId: string;
channel: "email" | "sms" | "webhook";
payloadRef: string;
};
interface QueueAdapter {
receive(signal: AbortSignal): Promise<{ id: string; body: ShipmentJob } | null>;
ack(id: string): Promise<void>;
retry(id: string, delaySeconds: number): Promise<void>;
deadLetter(id: string, reason: string): Promise<void>;
}
const delays = [5, 30, 300];
async function processJob(
adapter: QueueAdapter,
message: { id: string; body: ShipmentJob },
): Promise<void> {
const key = [
message.body.shipmentId,
message.body.updateSequence,
message.body.subscriberId,
].join(":");
if (await deliveryLedger.isComplete(key)) {
await adapter.ack(message.id);
return;
}
try {
await deliveryLedger.claim(key);
await sendToChannel(message.body.channel, message.body.payloadRef, key);
await deliveryLedger.complete(key);
await adapter.ack(message.id);
} catch (error) {
const attempt = await deliveryLedger.attempts(key);
if (isPermanent(error) || attempt >= delays.length) {
await adapter.deadLetter(message.id, classify(error));
return;
}
await adapter.retry(message.id, delays[attempt]);
}
}
The ledger and adapter need integration tests for duplicate delivery, worker termination after sendToChannel, and a poison message that reaches the DLQ. For one concrete drill, publish an update for shipment EU-4821 with sequence 17 to the email queue, terminate the worker after the provider accepts the request but before complete(key) commits, then let visibility expire. The second worker should observe the same key, query the ledger or provider idempotency record, acknowledge the message, and leave the resident with one email. Repeat the drill in the US region with a deliberately delayed webhook, then inspect queue age and redrive counts. A controlled failure drill is more useful than a throughput chart: it proves the recovery path that a real operator must execute.
Where do SQS, RabbitMQ, and managed queues differ in practice?
SQS removes broker patching and scales behind an AWS account, but its delivery model and visibility timeout still shape the worker. RabbitMQ gives direct control over exchanges, routing keys, consumer prefetch, and dead-letter exchanges; that control comes with responsibility for durable disks, upgrades, quorum behavior, and monitoring. Google Cloud Pub/Sub provides managed topics and subscriptions with cloud-native integration, while its retry and retention settings remain service-specific. None of these facts makes one universally cheapest.
The portability boundary matters. Keep queue-specific configuration in an adapter and store only provider-neutral fields in the job envelope. Then a migration changes connection code and deployment manifests, not the idempotency key or failure taxonomy. A self-hosted broker is unsuitable when nobody can own patching and capacity planning. A managed service is a poor fit when strict on-premise placement or custom routing semantics are non-negotiable. Stick with the cloud-native option when cross-service identity and observability already exist there.
I also separate “delay” from “calendar scheduling.” A queue delay handles minutes or hours of backoff. A shipment dispute that must reopen in 30 days belongs in a database or workflow scheduler that can emit a fresh queue job. Mixing those timelines creates expired messages and confusing DLQ reports.
The operating loop that keeps retries affordable
Tag every job with region, channel, attempt, and failure class. Export queue age, oldest DLQ message age, redrive count, and delivery-duplicate count. Alert on age and rate, not on every individual retry. During an incident, pause redrive first; otherwise a bad payload can fan out across thousands of subscribers before anyone reads the error.
Review one week of data: p50 and p95 delivery latency, percentage reaching the DLQ, operator minutes per redrive, and queue-related spend. Then adjust backoff, batch size, or the adapter. This is a weekly shipping loop, not a six-month platform project. Outsource the undifferentiated broker maintenance until your measurements show that its control is worth the time.
Top comments (0)