Fixed window strategy
The Fixed window strategy restricts API request volume within a predefined time window. When request volume reaches the maximum limit within a specified timeframe, LLM Gateway blocks subsequent requests until the window resets.
This strategy defines a maximum request threshold (max) permitted within a configured interval. Setting a duration value (such as 24 hours) determines the counter reset frequency.
Grouping by specific headers (such as x-lunar-consumer-tag) applies targeted limits per user or subscription tier. For example, a fixed-window quota assigned to endpoint api.website.com/ permits 10,000 requests per month.
The following configuration example defines a monthly fixed-window quota:
/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