Food,Code and Cloud Computing. You can support here :https://www.buymeacoffee.com/anishansari
Markdown supported · ⌘↵ to post
The seq number plus resync-from-DB approach is the right call, and it quietly makes the pub/sub backplane's at-most-once delivery a non-issue, which a lot of chat writeups never explain. One thing I'd add for the reconnect storm: when a WebSocket node dies, all its clients reconnect within a second or two, and they all hit the same after_seq endpoint at once. Jitter on the client reconnect delay plus the Redis recent-messages cache mentioned above usually covers it. Also good call questioning whether order tracking needs WebSockets at all. Location updates every few seconds with tolerance for a missed one is a great fit for SSE or even polling, and it keeps the stateful connection count reserved for chat where it actually matters.
I would add a short Redis cache of recent messages per conversation for resync. When many clients reconnect at once, serving those recent messages from Redis instead of MySQL avoids a spike on the database, and MySQL still covers older gaps.
OneLifeVibe
The 'save first, broadcast second' rule is the clearest takeaway for me — it reframes the socket as a best-effort notification layer rather than the system of record, which is exactly why a message to an offline user still exists. I also liked the unconditional resync on reconnect: fetching everything after the last seq without waiting to detect a gap removes a whole class of 'did I miss something' bugs. Parsa's point about a small Redis cache of recent messages per conversation pairs well with that, since it would keep the reconnect spike off MySQL when many clients come back at once.