Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enhance limit-count Plugin to Support Aligned Time Windows #11880

Open
bozorgmehr96 opened this issue Jan 1, 2025 · 0 comments
Open

feat: Enhance limit-count Plugin to Support Aligned Time Windows #11880

bozorgmehr96 opened this issue Jan 1, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@bozorgmehr96
Copy link

bozorgmehr96 commented Jan 1, 2025

Description

The limit-count plugin starts its time window based on the timestamp of the first request. This approach is problematic for quota-based use cases, especially when quotas need to align with standard periods such as calendar months.

To address this, I propose introducing a new attribute:

  • aligned_time_window: A configuration option to define time intervals in named units (e.g., "minute", "hour", "day", "month", "year") and automatically align them to standard boundaries.

This attribute would be mutually exclusive with the existing time_window attribute.


Proposed Changes

New Attribute:

  1. aligned_time_window:
    • Type: string
    • Accepted Values: "minute", "hour", "day", "month", "year"
    • Default: Not set

Use Case

Monthly Quota Enforcement:
A user has a monthly quota of 10,000 requests. With the current implementation, if the first request occurs on January 15th, the quota applies from January 15th to February 14th. Instead, the quota should align with the calendar month (January 1st to January 31st) for better consistency, fairness, and integration with monitoring tools.


Examples

Aligned Window with aligned_time_window

{
  "plugins": {
    "limit-count": {
      "count": 10000,
      "aligned_time_window": "month",
      "key": "remote_addr",
      "policy": "redis"
    }
  }
}
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Apache APISIX backlog Jan 1, 2025
@dosubot dosubot bot added the enhancement New feature or request label Jan 1, 2025
@bozorgmehr96 bozorgmehr96 changed the title feat: Enhanced window types for limit-count plugin feat: Enhance limit-count Plugin to Support Aligned Time Windows Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant