Food,Code and Cloud Computing. You can support here :https://www.buymeacoffee.com/anishansari
Markdown supported · ⌘↵ to post
The failover path seems to need one more distinction: a definite rejection versus a timeout after the provider may have accepted the SMS. A provider-scoped idempotency key may not carry across to the fallback provider. I'd test 'A accepts, response is lost, B is selected' and document how that uncertain outcome is reconciled or deliberately retried. Row locking alone cannot settle what happened outside the database.
The OTP behind the campaign queue story is a great opener because everyone has lived some version of it. One thing worth adding, separate queues is necessary but not sufficient. If both queues drain through the same provider account, the campaign still eats your OTP throughput at the rate limit. Priority has to survive all the way to the provider, separate sending identities or reserved capacity, otherwise you just moved the head of line blocking one hop downstream. Also OTPs deserve a short TTL. Delivering a login code five minutes late is worse than dropping it, the user already asked for a new one.
Great breakdown on decoupling priority queues from delivery providers. Handling provider-side rate limits and backpressure with exponential backoff and dead-letter queues is crucial when spikes hit.
Steven Mock
Really useful drill. The OTP-behind-a-marketing-campaign example makes the priority point stick — I have lived the version where a time-sensitive message sat behind a bulk send. Giving OTPs and receipts their own lane, with a separate queue per channel, is the part I would build first. The dedup key plus row locking before calling the provider is also a clean way to stop the double-SMS problem without overcomplicating it.