Skip to content

[MEDIUM] — Three independent Redis client connections across CacheModule, ThrottlerRedisStorage, and RedisHealthIndicator; no shared connection pool #14

@Alqku

Description

@Alqku

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.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignAudit finding under the Official Campaignhelp wantedExtra attention is neededrefactoringCode restructuring without behavioural change

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions