How one developer replaced cron-based rankings with a static SQL sort key
A developer building a 1,000-tile auction board needed tiles ranked by time-decaying "heat" without running any scheduled recomputation jobs. By expressing exponential decay mathematically, they showed that each tile's full payment history can be compressed into just two values: a combined payment score and a timestamp. Taking the logarithm of the heat formula reveals that the time-dependent term is identical across all rows and therefore irrelevant to ordering, leaving a static constant called rank_key that only changes when a payment occurs. Storing rank_key in the database and indexing it means a simple ORDER BY query always returns a correct real-time ranking with no background processing. The post also covers numerical stability pitfalls, choosing appropriate time units to preserve floating-point precision, and concurrency risks when using Cloudflare Durable Objects.
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