Every morning 8% of the notifications go missing, always in the same four minutes, and the retry is there precisely so that would not happen.
Context, code, logs and metrics, the same material you would have in production, with nobody pointing at the problem.
No multiple choice and no single right answer: you write what you think is happening, what you would do and what it costs.
The moment you submit, the solution written by an engineer opens next to your answers. Nobody scores you: the comparison is yours to make, and it stays open to reread.
The notifications-worker sends push notifications through an external provider. At 9am a job fires the day's batch: 12,000 notifications, 40 sends in parallel. The provider's contract allows 50 requests per second.
Since the network fails now and then, sending is tried three times:
async function send(notification: Notification) {
for (let attempt = 1; attempt <= 3; attempt++) {
const res = await fetch(PROVIDER_URL, {
method: "POST",
body: JSON.stringify(notification),
});
if (res.ok) return;
console.warn(`send failed (${res.status}), attempt ${attempt} id=${notification.id}`);
}
console.error(`giving up on ${notification.id}`);
}> The example is in TypeScript because it is the most widely read. The fetch > could be any HTTP client in any language.
Every day, between 09:00 and 09:04, about 8% of the notifications never arrive. Outside that window nothing fails — the same function runs all day for one-off sends and delivers everything.
The log for an id that got lost:
09:00:04.118 send failed (429), attempt 1 id=ntf_8c21
09:00:04.121 send failed (429), attempt 2 id=ntf_8c21
09:00:04.129 send failed (429), attempt 3 id=ntf_8c21
09:00:04.130 giving up on ntf_8c21The response the provider returned on all three:
HTTP/1.1 429 Too Many Requests
Retry-After: 2
X-RateLimit-Limit: 50
X-RateLimit-Remaining: 0
{"error":"rate_limit_exceeded"}And the provider's dashboard, 09:00 to 09:05:
requests 28,714
delivered 11,043
rejected (429) 17,671What opens
Reading is free; answering is what uses a credit. Every new account starts with 3, no card.