Skip to content

Commit 779c38d

Browse files
committed
feat(redis): implement connection pooling and key migration for Redis
- Introduced a connection pool for Redis to improve resource management and reduce connection churn. - Added backward compatibility for Redis key formats, migrating legacy keys to new formats during access. - Enhanced metrics for tracking key migration progress and connection pool health. - Updated Redis client interactions across the application to utilize the new pooling mechanism. - Implemented health checks and logging for Redis connections to improve operational visibility.
1 parent 9cd5706 commit 779c38d

File tree

15 files changed

+726
-148
lines changed

15 files changed

+726
-148
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Changelog
2+
3+
## Redis Connection Management Improvements
4+
5+
1. **Connection Pool Implementation**
6+
- Replace the singleton Redis client with a properly managed connection pool
7+
- Reduce minimum connections from 15 to 3 for startup efficiency
8+
- Increase maximum connections to 50 for high-throughput scenarios
9+
- Configure pool parameters via environment variables (REDIS_POOL_MIN, REDIS_POOL_MAX)
10+
11+
2. **Socket.IO Redis Adapter Integration**
12+
- Ensure Socket.IO cluster support with proper Redis adapter configuration
13+
- Fix compatibility issues between Socket.IO and ioredis library
14+
15+
3. **Monitoring and Metrics**
16+
- Add Redis pool metrics for connection usage tracking
17+
- Add API endpoint for monitoring pool health (/redis-pool-stats)
18+
- Log connection pool statistics for better operational visibility
19+
20+
4. **Improved Stability**
21+
- Add graceful shutdown to properly close Redis connections
22+
- Implement health checking with automatic connection recovery
23+
- Validate connections to ensure they're working properly
24+
25+
5. **Backward Compatibility**
26+
- Maintain existing API through proxy mechanism
27+
- Support existing key migration patterns
28+
- Fix redundant connection logs

packages/sdk-socket-server-next/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949
"express-rate-limit": "^7.1.5",
5050
"generic-pool": "^3.9.0",
5151
"helmet": "^5.1.1",
52-
"ioredis": "^5.3.2",
52+
"ioredis": "^5.6.0",
5353
"logform": "^2.6.0",
5454
"lru-cache": "^10.0.0",
5555
"prom-client": "^15.1.3",
5656
"rate-limiter-flexible": "^2.3.8",
5757
"redis": "^4.6.12",
5858
"rimraf": "^4.4.0",
59-
"socket.io": "^4.4.1",
59+
"socket.io": "^4.7.2",
6060
"uuid": "^9.0.1",
6161
"winston": "^3.11.0",
6262
"winston-loki": "^6.0.8"

0 commit comments

Comments
 (0)