Skip to content

Commit f48fc3a

Browse files
feat(rate-limiter): complete rust hot-path integration
Signed-off-by: Pratik Gandhi <gandhipratik203@gmail.com>
1 parent 4bfc250 commit f48fc3a

22 files changed

Lines changed: 7219 additions & 32 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ docs/build/
303303
# PyBuilder
304304
target/
305305
**/target/
306+
**/target/**
306307

307308
# Jupyter Notebook
308309
.ipynb_checkpoints

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,7 @@ load-test-agentgateway-mcp-server-time: ## Load test external MCP server (loc
23222322
MCP_PROTOCOL_LOCUSTFILE ?= tests/loadtest/locustfile_mcp_protocol.py
23232323
MCP_RATE_LIMITER_LOCUSTFILE ?= tests/loadtest/locustfile_rate_limiter_backend_correctness.py
23242324
MCP_RATE_LIMITER_SCALE_LOCUSTFILE ?= tests/loadtest/locustfile_rate_limiter_scale.py
2325+
MCP_RATE_LIMITER_REDIS_CAPACITY_LOCUSTFILE ?= tests/loadtest/locustfile_rate_limiter_redis_capacity.py
23252326
RL_ALGORITHM ?= fixed_window
23262327
RL_USERS ?= 100
23272328
RL_SPAWN_RATE ?= 10
@@ -2475,6 +2476,36 @@ benchmark-rate-limiter-scale: ## Scale test: 500 unique users, Red
24752476
--only-summary \
24762477
ScaleComparisonUser || true'
24772478

2479+
2480+
# help: benchmark-rate-limiter-redis-capacity - Multi-instance prompt-path concurrency benchmark for Redis rate limiting
2481+
.PHONY: benchmark-rate-limiter-redis-capacity
2482+
benchmark-rate-limiter-redis-capacity: ## Capacity test: 3 gateways + Redis on prompt_pre_fetch path
2483+
@echo "🚀 Running rate limiter Redis capacity test..."
2484+
@echo " Host: $(MCP_BENCHMARK_HOST)"
2485+
@echo " Topology: nginx -> 3 gateways -> shared Redis"
2486+
@echo " Path: REST /prompts/{id} (prompt_pre_fetch)"
2487+
@echo " Users: $(RL_USERS)"
2488+
@echo " Spawn rate: $(RL_SPAWN_RATE)/s"
2489+
@echo " Pace: $(RL_REQS_PER_SECOND) req/s per user"
2490+
@echo " Duration: $(RL_RUN_TIME)"
2491+
@test -d "$(VENV_DIR)" || $(MAKE) venv
2492+
@/bin/bash -eu -o pipefail -c 'source $(VENV_DIR)/bin/activate && \
2493+
LOCUST_LOG_LEVEL=ERROR \
2494+
RL_USERS=$(RL_USERS) \
2495+
RL_SPAWN_RATE=$(RL_SPAWN_RATE) \
2496+
RL_RUN_TIME=$(RL_RUN_TIME) \
2497+
RL_REQS_PER_SECOND=$(RL_REQS_PER_SECOND) \
2498+
RL_LIMIT_PER_MIN=$(RL_LIMIT_PER_MIN) \
2499+
RL_PROMPT_ID=$(RL_PROMPT_ID) \
2500+
locust -f $(MCP_RATE_LIMITER_REDIS_CAPACITY_LOCUSTFILE) \
2501+
--host=$(MCP_BENCHMARK_HOST) \
2502+
--users=$(RL_USERS) \
2503+
--spawn-rate=$(RL_SPAWN_RATE) \
2504+
--run-time=$(RL_RUN_TIME) \
2505+
--headless \
2506+
--only-summary \
2507+
CapacityPromptUser || true'
2508+
24782509
.PHONY: benchmark-mcp-mixed-300
24792510
benchmark-mcp-mixed-300: ## Distributed 300-user mixed MCP benchmark
24802511
@echo "📊 Running distributed mixed MCP benchmark..."

plugins/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ plugins:
214214
author: "Mihai Criveti"
215215
hooks: ["prompt_pre_fetch", "tool_pre_invoke"]
216216
tags: ["limits", "throttle"]
217-
mode: "permissive"
217+
mode: "enforce"
218218
priority: 20
219219
conditions: []
220220
config:

plugins/rate_limiter/rate_limiter.py

Lines changed: 495 additions & 15 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)