fix(bridge): 429 Rate Limit 무한 루프 방지 — 지수 백오프 + Collector 폴링 보호 + rate limit 완화

This commit is contained in:
Variet Worker
2026-03-12 00:49:37 +09:00
parent feb8c05a73
commit 52c9526fdb
6 changed files with 75 additions and 9 deletions

View File

@@ -28,7 +28,7 @@ logger = logging.getLogger(__name__)
# Rate limiting
RATE_LIMIT_WINDOW = 1.0 # seconds
RATE_LIMIT_MAX = 10 # max requests per window per IP
RATE_LIMIT_MAX = 30 # max requests per window per IP (Collector needs ~15-20/cycle)
COMMAND_TTL = 1800 # 30 min — stale commands auto-deleted
@@ -89,6 +89,7 @@ class GatewayAPI:
return web.json_response(
{"error": "Too Many Requests"},
status=429,
headers={"Retry-After": str(int(RATE_LIMIT_WINDOW * 2))},
)
window.append(now)
self._rate_limits[ip] = window