Design a notification service 00:00:00 Make a prediction You will record delivery attempts per channel and explain how to avoid repeating a successful channel after a partial failure. Email succeeds and push fails for one order update. If a retry replays the whole logical notification, what might the customer receive? A second email as well as another push attempt. Keep the logical notification identity, but track delivery outcomes per channel and retry only the appropriate channel. 00:00:30 One shopkeeper, three ways to tell the hill A hill shopkeeper uses a bell, a lantern and a runner to send news. Fog can hide the lamp even after the runner delivered the message. Sending the runner again does not fix the lamp. Separate the message from each channel attempt. A failed or uncertain result on one path does not erase evidence from other paths. A notification service, as a class design, takes an event for a person and gets one message to them in the way they chose. It decides the route, waits when it must, tries a slow outside channel, and remembers how it ended. Without it, every module of a product talks to vendors itself. Wishes are honoured by some and ignored by others, night is forgotten, and each retry loop has its own bug. 00:01:18 Track a delivery across a retry A shopper opts into email for an order update. Freeze the relevant message and recipient details and identify this logical notification once. A worker asks the email channel to send it, outside any lock protecting the request queue. Record success, explicit failure or an uncertain result. If the response is lost, use the provider's supported idempotency or reconciliation mechanism where available. A fresh unconstrained send can deliver two emails. Send a text and lose its acknowledgment. Record that attempt as uncertain. On retry, reuse the original delivery identity if the provider supports deduplication; creating an entirely new identity can send the same alert twice. Keep the notice itself independent from those transport attempts. 00:02:08 A second channel has its own rules A reminder may use email and push independently. If email succeeds and push fails, retrying the whole notification can duplicate the email. Track the status of each channel attempt and retry only according to its own policy. A customer receives the email immediately while push fails. A single delivered flag cannot say which channel needs work. Retry push only, and let that policy decide whether to fall back to another provider. The successful email receipt must survive the failed push attempt. A provider timeout may still mean it accepted the message. A local retry flag cannot single-handedly guarantee exactly one external email. Use provider-supported idempotency or reconciliation when available; when it is not, explain the tradeoff between a possible duplicate and a missed notification. A notification framework can choose email, chat or a text message according to the message’s importance. It can also choose a fallback transport when a provider fails. Separate the channel a customer expects from the vendor that happens to deliver it. Those are two distinct decisions and may have different retry rules. 00:03:26 Try an interview follow-up Why should EmailNotification not be a subclass of Notification? Because email is not a property of the news. One event may travel as push and, if that fails, as email. With subclasses these are two unrelated objects. I keep the notice free of channels and put the channel into the route. The only subtypes are senders, because only there the behaviour differs. A promotional email is queued and the customer withdraws consent before delivery. Should a retry send it anyway? Define when delivery eligibility is checked. If current consent is required, recheck it immediately before dispatch and record suppression as a distinct terminal outcome. A transport retry must not resurrect a delivery that policy has forbidden. 00:04:18 What to take with you The caller says what happened. The profile turns that into an ordered route and an earliest moment. Templates make the words. A delivery remembers where the notice is on its way, and senders do one try each. Accept renders, claims the key and queues. Work pops under the lock, sends without it and settles under it: sent, again later, next stop, or failed. The quiet rule sits where entries join the heap, so nothing passes it by.