Connection pooling 复用一组已建立的 Redis 连接,跨越许多请求,而不是为每个操作打开和关闭连接。对于处理并发请求的应用程序,它对性能和资源效率很重要,大多数 Redis 客户端默认都会进行池化。
问题:连接开销
Opening a new connection per request is wasteful:
→ TCP handshake + (TLS handshake) + AUTH on EVERY request → latency + CPU
→ many short-lived connections exhaust file descriptors / Redis's client limit
→ Under load, creating/destroying connections becomes a real bottleneck.
Connection pooling:复用连接
redis = ({
: ,
});
