Object-Oriented Programming · Snowflake · Medium
Per-Client Token Bucket with Live Tier Lookup A tiered rate limiter has to answer one question per request: given who this caller is, do they have budget left right now? A token bucket answers this cheaply. Each client owns a bucket that holds at most capacity tokens and refills continuously at refillPerSecond. A request spends one token. If less than one full token is available, the request is rejected. The tier sets the two numbers, capacity for burst size and refill rate…