Menu

How an autosave feature took down production — and five fixes that stuck
📰

How an autosave feature took down production — and five fixes that stuck

DEV Community: postgres·Noam Tzuberi·8 days ago
#iNyIpwVp
#devtopostgresql#devto#dev#database#feature
Reading 0:00
15s threshold

An editor I built saves your work as you type. That's the feature users love most, and one evening it was the reason the whole app stopped answering.

No single bug caused it. Five ordinary decisions, each reasonable on its own, lined up. Here they are, with what I changed.

1. Saving things that hadn't changed

The editor sent the cursor position and the current scene on a timer. The server wrote them every time — even when nothing had changed. And the "last saved" baseline on the client never advanced, so every tick looked like a new change.

At normal traffic this was invisible. When usage climbed, the database spent most of its time writing identical rows.

Fix: compare before you write. The client keeps a baseline and sends only real diffs; the server skips writes where the value is unchanged. A no-op save should cost nothing.

2. Read-before-write on every save

Each save first selected the row, then updated it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.