At-Most-Once, At-Least-Once, Exactly-Once Semantics
What you'll learn: How distributed notification systems guarantee (or don't guarantee) message delivery, and the tradeoffs between duplicate messages, lost messages, and perfect delivery.
The Three Delivery Guarantees
When a notification system sends messages across networks, failures happen—servers crash, networks partition, requests timeout. How do we handle retries? Three models exist:
At-Most-Once
Send the message once and never retry. If it fails, tough luck—users might miss the notification. Like mailing a postcard with no tracking: either it arrives or it doesn't.
Tradeoff: No duplicates, but messages can be lost. Acceptable for low-priority notifications (promotional emails, optional app updates).
At-Least-Once
Retry until you get confirmation. The message definitely arrives, but network issues might cause duplicates—the user could receive the same notification 2-3 times.
Tradeoff: Guaranteed delivery, but duplicates possible. Common in notification systems because you can use idempotency keys and deduplication to handle repeats on the client side.
Exactly-Once
The holy grail: deliver each message precisely once, no matter what fails. Extremely hard (some argue impossible) in distributed systems without distributed transactions.
Tradeoff: Requires complex coordination, state tracking, and often degrades to "effectively once" through idempotent processing. Rarely worth the cost for notifications.
Practical Choice
Most notification systems use at-least-once with idempotency. The Notification Processing Workers retry failed deliveries, the Notification State Tracking system logs attempts, and clients deduplicate using message IDs. Push providers (APNs, FCM) themselves offer at-least-once guarantees, making exactly-once nearly impossible without application-level deduplication.
Key Takeaway: At-least-once delivery with client-side deduplication offers the best balance for notification systems—users don't miss critical alerts, and duplicate detection is cheaper than distributed exactly-once guarantees.