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

Question: reusing Redis bclient #880

Closed
yulianovdey opened this issue Mar 2, 2018 · 6 comments
Closed

Question: reusing Redis bclient #880

yulianovdey opened this issue Mar 2, 2018 · 6 comments
Labels

Comments

@yulianovdey
Copy link

yulianovdey commented Mar 2, 2018

Hello!

In PATTERNS.md it says that bull requires 3 connections, and lists two types - client and server subscriber. I noticed that there's also a bclient type that gets passed to createClient. Can this connection be reused as well, or is that not advised?

Thanks in advance!

@ritter
Copy link

ritter commented Mar 2, 2018

From my experience, bclient was not shareable. Bull degraded terribly when I tried to share that redis connection.

The 3 types I've seen are client, subscriber, and bclient ... I've never seen server.

@yulianovdey
Copy link
Author

@ritter Good to know, thanks. Also you're right; I definitely meant subscriber.

@manast
Copy link
Member

manast commented Mar 2, 2018

bclient cannot be shared because it is the client used for blocking calls, so if one instance for instance blocks it waiting for jobs to arrive to the queue, all the other instance sharing it will stall.

@manast manast added the question label Mar 2, 2018
@yulianovdey
Copy link
Author

@manast Makes sense, thanks for the super fast reply!

@ritter
Copy link

ritter commented Mar 2, 2018

In regards to sharing redis connections, we are sharing client connections, and subscriber with other subscribers, but every bclient gets its own connection.

@joshuapaling
Copy link
Contributor

Bit of extra info for future readers: the relevant source is at https://github.com/OptimalBits/bull/blob/develop/lib/queue.js#L1098

    return this.bclient
      .brpoplpush(this.keys.wait, this.keys.active, this.settings.drainDelay)

When a queue is empty, that queue opens a blocking connection to redis to wait for the next item to be added to the queue. That connection is then kept around as "the blocking connection to use next time this same queue is empty". Hence the need for one blocking connection per queue.

I've opened up a PR to make this more clear in the example code for re-using connections: #1714

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

No branches or pull requests

4 participants