Notifications: tell the right person once, built serverless with Nami

Real-world systems
Notifications
Nami, cloud architect
Nami
Thank you

You built the notifications with me.

From a fact on the bus to one message on a lock screen. You learned:

  • Why services announce facts, and only one service decides who is told.
  • How a queue and dead letters protect the system during a rush.
  • How preferences, quiet hours and a conditional write keep every message wanted and unique.
  • How channels get their own queues, limits and retries.
  • How a workflow handles later reminders, and a cap stops people muting the app.
See the whole system

    Read this story as text

    Notifications: the story, written out

    Your order is on the way, one line on a lock screen. Nami, a cloud architect, builds the serverless AWS setup behind it: EventBridge, SQS, Lambda, DynamoDB, SNS, Step Functions and dead-letter queues.

    1. Your phone buzzes: 'rider outside'. Now it buzzes three times. How do we stop that?
    2. Every service has news, and none knows what the others already said. A recipe for spam.
    3. Three rules to keep: Tell the right person, on the channel they chose. Say it once, even when events repeat. Never become the app that people mute.
    4. Wait for the queue per channel. That is where most systems break. Scroll.
    5. Everyone has news. Checkout, dispatch, tracking: all have news. But none sends a message. They only announce a fact on the event bus. Why?
    6. One front line. So one service owns messaging. A rule drops events into one queue. A thousand at once? They wait in line, nothing is lost.
    7. Should we tell them? A function asks: who is this about, and what do they want? A promotion at two a.m. gets dropped. A rider at your door never does.
    8. Say it once. Events arrive twice. So each has an id, written with a condition: only the first wins. Nobody gets three buzzes.
    9. Write it for a person. Messages come from templates, per language, with slots for names and times. Services publish facts, never copy.
    10. A queue for each channel. Push, SMS and email each get their own queue. A slow email provider must never hold up 'rider outside'. Different speeds, different lanes.
    11. Send, with manners. A function sends through SNS and SES, inside every limit, backing off when told. Hammer a limit, lose messages. And when sending fails?
    12. When sending fails. Failed sends retry, then land in a dead-letter queue for a human. Dead push tokens get deleted, never retried forever.
    13. Later, only if it still matters. 'You left something in your cart': thirty minutes later, only if they did not order. A workflow waits, checks, then sends or ends.
    14. Not too many. Without a cap, someone gets nine messages an hour and mutes us. So there is a cap per person, and low priority gets bundled or dropped.
    15. Did it arrive? SNS and SES report delivered, bounced, opened. Numbers by channel. Silence is data too.
    16. Watch the line. I watch the oldest message in the front queue. Minutes means 'rider outside' arrives after he left.
    17. The whole picture. That is one message, event to lock screen. Trace one, or open the full diagram.

    More stories on Real-world systems