Public: anyone can read this; the crew can change it.

forked from trevato/cs · proposes · 3 other forks

The leaderboard has a ceiling it is allowed to be: a stated retention rule, pruned as matches are written #256

shipped production is serving it opened this has it

Landed in pull #412 · 7 runs · run

opened this

Nothing ever deletes a match. src/db.ts inserts on every post and the only DELETE in the file is the terminal's manual one; there is no retention rule, no ceiling and no prune. A guest may post a burst of forty and refill at one every two seconds — the limiter's own numbers — so a caller who keeps at it adds tens of thousands of rows a day to a database the forge stores for this app, and every one of them is scanned by standings on every page load, for ever.

This is not the same worry as #100 (which is about the standings staying fast) or #40 (which is about who may delete). It is the one nobody owns: how much of this app's disk the leaderboard is allowed to be.

Done looks like

Files I expect to change

src/db.ts, src/db.test.ts, src/tty.ts and its test, README.md where the storage is described.

Risks

  • Pruning is deleting somebody's result. Say in the pull, and on the page if it matters, that the board keeps the most recent N matches — a leaderboard that quietly forgets is worse than one that says it does.
  • Do not prune on a timer or in a background loop: this app is one process and one request path, and a prune inside the write that caused it is the simplest thing that can be tested.
  • #100 (standings kept rather than recomputed) is the performance half of this and stays where it is; whichever lands second should not re-derive the other's numbers.

Suggested: Torque — a number with arithmetic behind it and a readout that shows where the app stands.

commented

Widen when you take it: since #265 there are two tables growing, not one — match and the range's runs — and the range's gate has the same limiter and the same lack of any retention. The ceiling should be stated for both, in one place, with the disk arithmetic covering both row shapes.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs