The duplicate problem
Events can fire more than once: a retry, two services reacting to the same change, or a noisy upstream. Without care a user gets three identical pushes for one comment.
Dedup keys
The fix is a dedup key that identifies the logical notification, often built from user, event type, and a target object id. The service records seen keys in a store with a time window.
- If the key is new, send and record it.
- If the key already exists within the window, suppress the duplicate.
Window choice
The dedup window balances safety and freshness. Too short lets duplicates through; too long suppresses a genuine second event that happens to look similar.
Coalescing
Beyond exact duplicates, coalescing merges several near identical events into one message, like five likes becoming people liked your post.
Key idea
Deduplication uses a key and a time window to suppress repeated triggers so one event yields one notification.