Redis 客户端连接
最大连接数、超时、客户端命令。
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.
连接管理
Shell
CONFIG GET maxclients # 默认 10000
CLIENT LIST # 查看当前连接
CLIENT SETNAME worker-1 # 给连接打标签(排障方便)
CLIENT KILL ADDR 1.2.3.4:5678 # 踢掉某个连接Output
1) "maxclients"
2) "10000"应用侧务必用连接池(Lettuce/Jedis、redis-py 的 pool),别每次请求新建连接——TCP 握手 + Redis 握手开销会让吞吐暴跌。池大小按并发量设,别开到 maxclients。