Why a tiny two-user chat app racked up tens of MB in daily database reads
A developer building a small chat app on Convex, a reactive backend platform, was puzzled to find tens of megabytes of daily database bandwidth usage despite storing only a few hundred kilobytes of actual data. The root cause was how Convex's reactive queries work: every time a document changes, the entire query re-executes and re-sends its full result to all subscribed clients, making bandwidth a product of result size multiplied by re-execution count. A growing message list compounded the problem, as each new message triggered a full re-read and re-delivery of all previous messages. Switching to Convex's paginated query system resolved the issue, since only the newest page re-runs on updates while older pages remain static. A secondary culprit was an AI streaming feature that rewrote an entire accumulated text string to the database on every token, creating quadratic write costs that were eliminated by storing only incremental token chunks instead.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in