Skip to main content
Version: Next

Fixed Window Strategy

The Fixed Window strategy is a rate limiting approach, where requests are restricted within a predefined time window. Once the limit is reached within the specified window, subsequent requests are blocked until the window resets.

Using this strategy you can define a maximum number of requests (max) allowed within a specific interval. This interval is configured by specifying the duration (e.g., 24 hours), after which the counter resets.

The Fixed Window stratey can be grouped by a specific header, such as x-lunar-consumer-tag, allowing limits to be applied per user or subscription level.

For example, we have a fixed window quota for the enpoint api.website.com/*. Here we allow 10000 requests to that endpoint per month. The quota will reset on the 1st day of each month at 00:00 UTC.

 
/etc/lunar-proxy/quotas/{fileName}.yaml
quotas:
- id: FixedWindowQuota # Unique identifier for the quota
filter: # Define filter conditions for this quota
url: api.website.com/* # URL pattern to apply the quota
strategy:
fixed_window:
max: 10000 # Maximum requests allowed within the window
interval: 1 # Window duration
interval_unit: month # Unit of time for the interval (second/minute/hour/day/month)
monthly_renewal:
day: 1
hour: 0
minute: 0
timezone: UTC # Optional: Monthly renewal configuration