redis-async icon indicating copy to clipboard operation
redis-async copied to clipboard

how does one configure the max # of clients in the pool?

Open funston opened this issue 9 years ago • 1 comments

debugging the redis client list, my app seems to always only be creating a single connection, not a pool

funston avatar Feb 13 '16 04:02 funston

The number of connections is not configurable at present.

This is because the pool isn't a connection pool in the conventional sense, rather it uses multiple connections based on the type of Redis command being issued. So for the majority of Redis commands where there is a single response to a single question, these will all use the same connection.

There are some exceptions to the rule where commands are either blocking (and therefore require a dedicated connection) or where a single command can expect multiple responses (like the pub/sub stuff). If you use these features then more than one connection will be created.

The single connection should not be a bottleneck however, although I haven't tested too many configurations, due to the Redis protocol being pipelined (so we can stream many commands before reading the responses). Also multiple threads on the client side can write to the same connection, and have their commands multiplexed. For example, if you had several threads writing to Redis as fast as they can, then each TCP packet sent to Redis will contain multiple commands, including several from each thread.

The more we pipeline, the higher the memory requirements for the Redis server: http://redis.io/topics/pipelining but redis-async doesn't enforce any limits, it leaves that up to the application.

In theory multiple threads writing through one shared channel ought to be the most efficient way to send data back and forwards from Redis. In practice I imagine there will be some application loads where this works very well, and others where it works less well.

benashford avatar Feb 13 '16 16:02 benashford