Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to Redis using a unix socket #346

Open
jamesk-au opened this issue Sep 12, 2016 · 3 comments
Open

Connect to Redis using a unix socket #346

jamesk-au opened this issue Sep 12, 2016 · 3 comments

Comments

@jamesk-au
Copy link

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)".

@manast
Copy link
Member

manast commented Nov 22, 2016

Makes sense performance wise, but it is still an edge case since normally redis will run in a separate machine or container than the worker process. We can keep it as a potential enhancement since it is not difficult to fix. PR welcome.

@CaptainYarb
Copy link

CaptainYarb commented Feb 9, 2017

You can get around this functionality by passing null into both the port and hostname:

var queue = Queue('my queue', null, null, redisConfig);

I'd also like to comment that this really isn't something I would consider an edge case scenario. It might not be for your your specific work, but with Docker and network defined storage this is still a very likely setup.

@CaptainYarb
Copy link

Update: The above workaround changed in the 3.0.0 release of bull. You can now do:

var queue = Queue('my queue', {redis: redisConfig});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants