Problem
The public API currently creates a new Redis connection per request for rate limiting, lockout checks, and caching. Under high load (1000+ concurrent requests), this causes connection exhaustion, increased latency, and potential Redis ECONNREFUSED errors. The existing ioredis or redis client is likely instantiated without pooling.
Proposed Improvement
Implement a Redis connection pool for all public API endpoints that interact with Redis (rate limiting, lockout, caching, analytics). The feature should:
- Use a single shared Redis connection pool (max 20 connections, min 5) across the public API
- Apply pooling to
checkLockout, recordFailedAttempt, clearLockout, and analytics counters
- Add connection health checks and automatic reconnection with jittered backoff
- Expose pool metrics (active connections, wait queue size, total commands) via
GET /api/health/redis
- Reduce P99 latency for auth endpoints by eliminating per-request connection overhead
Expected Impact
- Better performance under high concurrency
- Reduced Redis server load and connection count
- Improved reliability with connection health monitoring
- Better long-term scalability for production deployments
Possible Implementation
- Add
RedisPool class in packages/common/redis/ using ioredis cluster mode or generic-pool
- Refactor
apps/public-api/middleware/rateLimiter.js to use pooled connections
- Refactor
apps/public-api/services/lockout.js (checkLockout/recordFailedAttempt/clearLockout)
- Add
redisPoolMetrics middleware exposing pool stats
- Update
docker-compose.yml to include Redis with maxclients config
- Write load tests using
autocannon or k6 to verify latency improvement
- Add resilience tests for pool exhaustion and connection failure scenarios
I'm GSSoC'26 contributor, Please assign this task to me!
Problem
The public API currently creates a new Redis connection per request for rate limiting, lockout checks, and caching. Under high load (1000+ concurrent requests), this causes connection exhaustion, increased latency, and potential Redis
ECONNREFUSEDerrors. The existingioredisorredisclient is likely instantiated without pooling.Proposed Improvement
Implement a Redis connection pool for all public API endpoints that interact with Redis (rate limiting, lockout, caching, analytics). The feature should:
checkLockout,recordFailedAttempt,clearLockout, and analytics countersGET /api/health/redisExpected Impact
Possible Implementation
RedisPoolclass inpackages/common/redis/usingiorediscluster mode orgeneric-poolapps/public-api/middleware/rateLimiter.jsto use pooled connectionsapps/public-api/services/lockout.js(checkLockout/recordFailedAttempt/clearLockout)redisPoolMetricsmiddleware exposing pool statsdocker-compose.ymlto include Redis withmaxclientsconfigautocannonork6to verify latency improvementI'm GSSoC'26 contributor, Please assign this task to me!