Goal
Protect the ingestion gateway from volumetric traffic surges and DDoS attacks.
Problem
There is currently no rate limiting on the /v1/events endpoint. A single malicious client can flood the gateway, causing resource exhaustion across Redpanda and PostgreSQL.
Task
- Implement a rate limiter in
src/middleware/rateLimiter.ts using Redis sorted sets (zsets).
- Maintain a sliding-window duration of 60 seconds allowing a maximum of 100 requests.
- Execute the Redis operations atomically using a multi-pipeline transaction (
ZREMRANGEBYSCORE, ZADD, ZCARD, EXPIRE).
- Return an HTTP 429 status code with a 'Retry-After' header if the count is exceeded.
Goal
Protect the ingestion gateway from volumetric traffic surges and DDoS attacks.
Problem
There is currently no rate limiting on the
/v1/eventsendpoint. A single malicious client can flood the gateway, causing resource exhaustion across Redpanda and PostgreSQL.Task
src/middleware/rateLimiter.tsusing Redis sorted sets (zsets).ZREMRANGEBYSCORE,ZADD,ZCARD,EXPIRE).