Per-client rate limit
Answer "may this client spend this weight now" for every client a trace names, without remembering every client forever. This private workload replays one seeded per-client trace through all four `knotkit/rate-limit` kinds held in a bounded `keyedRateLimitTable`, and through the fixed-window counter a server writes by hand: a `Map` from client key to `\{ windowIndex, used \}`. It reports three things per preset — decisions per second, retained bytes per client, and the most weight any one client was admitted inside one trailing window — and checks that last number against the promise each kind documents.
Answer “may this client spend this weight now” for every client a trace names, without remembering every client forever. This private workload replays one seeded per-client trace through all four knotkit/rate-limit kinds held in a bounded keyedRateLimitTable, and through the fixed-window counter a server writes by hand: a Map from client key to \{ windowIndex, used \}. It reports three things per preset — decisions per second, retained bytes per client, and the most weight any one client was admitted inside one trailing window — and checks that last number against the promise each kind documents.
Result
Section titled “Result”On a 7,510-arrival trace the bounded table keeps 64 clients in at most 170 KB; the hand-written Map counter keeps 4,146 in 684 KB
Modules
Section titled “Modules”knotkit/rate-limit: Limits each client’s request weight by a fixed window, a sliding window, or a token bucket, returning the least whole millisecond a denial must wait
Reproduce
Section titled “Reproduce”git clone https://github.com/jkomyno/knotkit.git && cd knotkit && bun installThis package ships no demo.ts; its README lists the commands that produce the result above.
problems/per-client-rate-limit/README.md states the fixture, the seed, and the result table.