Severity: Medium
Type: Performance
Scope: Redis, Throttler, Health
Labels: refactoring, help wanted
Description
The application opens at least three independent ioredis clients:
RedisModule registers a KeyvRedis store for the cache manager.
ThrottlerRedisStorage constructs new Redis(config.get('REDIS_URL', ...)) in its constructor (src/throttler/throttler-redis.storage.ts, line ~18).
RedisHealthIndicator instantiates yet another new Redis(...) for health checks (src/health/redis.health.ts, line ~14).
Each client maintains its own socket pool (maxRetriesPerRequest, enableReadyCheck). Under load (rate limiter + notification subscription + cron + queue draining) the Redis connection count grows linearly with the connection options set by each module.
Recommendation
- Wrap
ioredis in a single provider (REDIS_CLIENT) imported by all three modules.
- Use
ioredis-mock or redis-memory-server for local tests; share the mock across the same singleton.
- Reduce health-check traffic by exposing a
PING from the cache manager's underlying connection via cacheManager.store.client.
Severity: Medium
Type: Performance
Scope: Redis, Throttler, Health
Labels:
refactoring,help wantedDescription
The application opens at least three independent
ioredisclients:RedisModuleregisters aKeyvRedisstore for the cache manager.ThrottlerRedisStorageconstructsnew Redis(config.get('REDIS_URL', ...))in its constructor (src/throttler/throttler-redis.storage.ts, line ~18).RedisHealthIndicatorinstantiates yet anothernew Redis(...)for health checks (src/health/redis.health.ts, line ~14).Each client maintains its own socket pool (
maxRetriesPerRequest,enableReadyCheck). Under load (rate limiter + notification subscription + cron + queue draining) the Redis connection count grows linearly with the connection options set by each module.Recommendation
ioredisin a single provider (REDIS_CLIENT) imported by all three modules.ioredis-mockorredis-memory-serverfor local tests; share the mock across the same singleton.PINGfrom the cache manager's underlying connection viacacheManager.store.client.