Rate Limiting¶
The Titlani server supports token bucket rate limiting via tlacacoca's RateLimiter middleware.
Enable in Config¶
Add a [rate_limit] section to your TOML config:
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
enable |
bool | false |
Enable rate limiting |
capacity |
int | 10 |
Maximum tokens in the bucket |
refill_rate |
float | 1.0 |
Tokens added per second |
retry_after |
int | 30 |
Seconds to suggest in slow-down response |
How It Works¶
The rate limiter uses a token bucket algorithm:
- Each client (identified by IP) gets a bucket with
capacitytokens - Each request consumes one token
- Tokens refill at
refill_rateper second - When the bucket is empty, the server responds with status 44 (slow down)
Tuning¶
Permissive — Allow bursts, quick refill:
Restrictive — Small bursts, slow refill:
Client Behavior¶
When rate limited, clients receive:
Well-behaved clients should wait at least retry_after seconds before retrying. Titlani's MisfinClient does not automatically retry on status 44 — the caller should implement retry logic as needed.