Design a Notification System, stage 1 of 11: model
What the numbers say
Start with arithmetic and the provider's contract. Eight million notifications a day, a 500/s email limit, a five-million-user announcement, and a 30-second promise for security alerts.
System so far· 3 parts
Select a component to see what it is responsible for and which state it owns.
- 1Product services → Event stream: Domain events via outbox
- 2Event stream → Notification planner: Events, at least once
What you need to know
When a provider caps your sending rate, that cap is a shared budget. Every email of every kind draws from it: security alerts, comment notifications and marketing alike. The first numbers to work out are how long the big jobs occupy that budget, and what is left for everything else meanwhile.
Work it out
An announcement goes to 5 million users, and the provider allows 500 emails a second. About how many hours does it take?Work it out
8 million notifications a day, with work-hour peaks at 10× the average. About how many a second at peak?An idempotency key is an id you send with a request so the receiver can recognise a retry: "you already did 812, here's the same result". Payment APIs usually accept one. This email provider doesn't.
Without it, a request that times out is ambiguous: the email may or may not have been sent, and the provider gives you no way to ask.
Check
A send to the provider times out after 10 seconds. What do you know?