Redis 客户端连接

最大连接数、超时、客户端命令。

Beginner
Key Points连接是宝贵资源:服务端有 maxclients 上限,应用侧要用连接池复用。

连接管理

Shell
CONFIG GET maxclients          # 默认 10000
CLIENT LIST                    # 查看当前连接
CLIENT SETNAME worker-1        # 给连接打标签(排障方便)
CLIENT KILL ADDR 1.2.3.4:5678 # 踢掉某个连接
Output
1) "maxclients"
2) "10000"
Always use a connection pool client-side (Lettuce/Jedis, redis-py pool); never open a new connection per request — the handshake overhead kills throughput. Size the pool to concurrency, not to maxclients.

Friends & Partners