15. Quota Management

Chapter 15 of 24 · 25 min
EXERCISE

Implement a quota system that supports rollover (unused quota from previous month carries forward up to a cap). Create a rollover calculation that runs at billing cycle end, archives current usage, and updates the Redis quota key to include carried-over amounts. Test with a tenant who used 30% of their 5M token limit in month one, verifying the rollover adds 3.5M tokens (70% of 5M) to month two's allocation, capped at 10M total.