Connect to Redis using a unix socket
Created by: jamesk-au
The node_redis
documentation provides that the following arguments may be used to create a Redis client:
redis.createClient([options])
redis.createClient(unix_socket[, options])
redis.createClient(redis_url[, options])
redis.createClient(port[, host][, options])
Tip: If the Redis server runs on the same machine as the client consider using unix sockets if possible to increase throughput.
Currently, the Queue
constructor does not appear to provide any way of creating a Redis client using a socket.
One way to implement this might be to check whether the redisConnectionString
argument has been provided and is a file path to a unix socket. The default socket path used by Redis is "/tmp/redis.sock".
But I can see there are module-scoped redisHost
and redisPort
variables in the Queue class, and it's not clear to me exactly how they are used, or whether other parts of the bull package make assumptions about those variables or the nature of the Redis connection. If there are no such assumptions, it may be relatively straightforward to add socket support.
Redis benchmarks show that, depending on the platform, "unix domain sockets can achieve around 50% more throughput than the TCP/IP loopback (on Linux for instance)".