One payment notification uses five weeks of system design
transcript
2,400 rupees received from Arjun. One little ping. Getting it safely to her screen uses five weeks of system design.
The payments service sends it with an idempotency key. Named after the business event. Every retry carries the same key. The Send API stores it with an outbox row. One transaction. It rides the transactional lane. A campaign can't cut in. The in-app worker writes the inbox item first. Next sequence number. Only then is she told. Live socket, or push if nobody acknowledges.
But here's the catch. Why write the inbox before the socket? Because sockets die silently. The inbox is the record.
Tell first, and the socket turns out dead. It's gone. Store first, and her app reconnects later. It resumes after its last sequence number. Nothing lost.
The socket is a hint. The inbox is the truth. Store it first. Then tell her.
Full breakdown in the lecture.