ADR 0008: Redis Bus Connection Pooling
Status
Accepted
Context
High-frequency invalidations in distributed mode were creating a new Redis connection for every publish call. This led to connection exhaustion on the Redis server and high latency due to TCP handshake overhead.
Decision
- Use
r2d2Pooling: Implement a connection pool for theRedisPubSubBus. - Recycle Connections: Reuse existing connections for metadata publication and listener threads.
- Exponential Backoff: Implement robust reconnection logic in the listener thread using the pool.
Consequences
- Positive: Extremely stable invalidation bus under extreme load.
- Positive: Lower latency for
invalidate()calls in Redis mode. - Negative: Increased memory usage to maintain the connection pool (configurable).