Tyk v2.2 Documentation Components


A quota is similar to a rate limit, as it allows a certain number of requests through in a time period. However traditionally these periods are much longer, so for example if you would like to have a user only have 10,000 requests to the API per month, you can create a key that has no rate limiting but will disallow access once the quota is empty. Tyk will automatically reset the quota if the time limit on reset has been exceeded.

How do quotas work?

Quotas in tyk use a decrementing counter in the token’s session object to measure when to block inbound requests.

How do quotas renew?

In Tyk, most things are event-driven, the same goes for quotas, since all quotas have a reset time limit, they do not “reset” on a specific date (e.g. 1st of the month), instead the “reset” on or after a date has passed, and only when the key is actively being used, this means that the period can “move” if the token is only partially active.

Why is the quota system like this?

In a system wit5h 1,000,000 tokens, managing timers to watch and monitor each token is extremely expensive and inefficient. So in order to keep quotas sane and not clutter up the DB with unnecessary timers, quotas are event-driven.

It is possible to have monthly quotas that set on a specific date, using the tyk gateway API it is possible to reset known token quotas periodically using an external timer.

Was this article helpful to you? Yes No