Concepts
Rate Limits
Rate limits are per-second values that can be whole numbers or fractions.
In Trypema, a rate limit is a per-second value stored in RateLimit.
Fractional rates are normal
You are not limited to whole numbers:
10.0means ten requests per second5.5means five and a half requests per second0.5means roughly one request every two seconds
Window capacity
Trypema enforces rates over a sliding window, so the rough budget for a key is:
window capacity = rate_limit_per_second × window_size_seconds
Example:
- rate limit =
5.0 - window =
60s - capacity = about
300requests in the current moving window
Sticky per key
The first inc(...) call for a key stores that key's rate limit. Later calls for the same key keep using the stored value instead of replacing it mid-window.
This prevents inconsistent behavior when multiple parts of an application accidentally pass different limits for the same key.
How to think about it
- Use low fractional values for sparse events.
- Use whole-number rates for common request budgets.
- Treat the first rate applied to a key as the rate that key will carry while it remains active.

