~learn.
0:00 / 1:26
Interview problem · Notification system

The SMS went out. Then the worker crashed. Two SMS?

transcript

Your SMS just went out. Then the worker crashed. Kafka hands the job to someone else. Does the user get two?

A job arrives: send this SMS. The worker calls the gateway. The SMS reaches the phone. Then it crashes, before it records success. Success was never recorded. So Kafka redelivers the same job.

Here's the hard truth. With an outside provider, exactly once is impossible. The best you get is at-least-once. Plus deduplication.

So before calling the provider, the worker sets a key in Redis. Notification ID plus channel. Set only if it doesn't exist. With a TTL. First time? The key is new. Send the SMS. The redelivered job finds the key already set. It skips. One SMS.

It's layers. Retry the API call with the same idempotency key? Same ID back. The worker key is per channel. One notification can go by push and email. And after too many tries, a dead-letter queue. Status: failed. Never silently dropped.

Be precise in the interview. This narrows the duplicate window. Narrow. Not zero. Say exactly that.

You can't make delivery exactly once. So make duplicates harmless. At least once, plus a key.

Full breakdown in the lecture.