apache / apache/apisix

feat: As a gateway user, I want adaptive rate limiting per consumer, so that abnormal traffic spikes can be automatically controlled

Open
#13,027 10 comments 0 reactions 0 assignees View on GitHub
feature-request
Dominant language
Lua
Stars
17.1k
Forks
2.9k
Avg merge
3d 16h
Merged PRs (30d)
63

Description

### Description

---

## Problem

Current rate limiting plugins such as limit-req, limit-count, and limit-concurrency use static thresholds. These limits work well for predictable traffic, but they do not adapt when a specific consumer suddenly changes behavior.

In real-world scenarios, abuse or misconfiguration often appears as sudden traffic spikes from an otherwise normal consumer. With static limits, operators must manually adjust configurations or rely on external monitoring systems.

---

## Proposed Feature

As a gateway user, I want an optional adaptive rate limiting mode per consumer, so that the gateway can automatically respond to abnormal traffic patterns without constant manual intervention.

This could work at a high level as follows:

- Track a rolling request baseline for each consumer (e.g., average over a recent time window).

- Detect abnormal spikes compared to the historical baseline.

- Temporarily tighten rate limits when abnormal behavior is detected.

- Gradually relax limits once traffic returns to normal patterns.

---

## Why This Is Useful

- Improves security by mitigating sudden abuse patterns.

- Reduces operational overhead for gateway operators.

- Adds intelligent traffic control at the gateway level.

- Enhances production-grade resilience without external systems.

---

## Possible Direction

- This could potentially be implemented:

- As an extension to existing rate limit plugins, or

- As a separate plugin (e.g., adaptive-limit)

- Using shared memory or Redis to maintain rolling consumer metrics.

---

This is a feature proposal and not a duplicate of existing static rate limiting discussions. I would appreciate feedback on feasibility and design considerations and if any suggestions and guidance regarding this please guide me.

---

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing limit-req, limit-count, and limit-concurrency plugins to understand their current static-threshold behavior. Compare an extension versus a separate adaptive-limit plugin, and evaluate shared memory or Redis for rolling consumer metrics; done requires an agreed design for detection, temporary tightening, and recovery.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, redis
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.