How do you stop retries from creating duplicate messages?
Have the client generate a unique id for each message before sending and have the server deduplicate on it. A retry after a timeout carries the same id and is recognised as the same message, so the user sees one message regardless of how many attempts were made.
Answered in
Real-Time Chat That Never Lies: Persist Before You Broadcast, and Cache the Cold StartWhy send flows must store a message before showing it, how an approximation of atomic broadcast works, and why session bootstrap needs an edge cache.
Read the full analysisOther questions this article answers
More system design & architecture questions
- What is a Backend for Frontend?
- What is the main risk of the BFF pattern?
- What is a value-added service layer?
- What does a field mask do in an API?
- What is a cold cache problem?
- How does change data capture keep a cache correct?
- Why use add instead of set when warming a cache?
- Why partition the cache differently from the database?
Every answer on Crashtech is written by the editor of the article it comes from — never auto-summarised. Browse all answers or the System Design & Architecture beat.