Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56db9b5

Browse files
authored
docs: refine updates
1 parent 0c6b669 commit 56db9b5

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -232,46 +232,46 @@ To make this happen, workers periodically phone home to Redis about each job the
232232

233233
By default, every time you create a queue instance with `new Queue()` a new redis connection will be created. If you have a small number of queues accross a large number of servers this will probably be fine. If you have a large number of queues with a small number of servers, this will probably be fine too. If your deployment gets a bit larger you will likely need to optimize the Redis connections.
234234

235-
Let's say for example you have a web application with 30 producer queues and you run 10 webservers & 10 worker servers, each one with 4 processes/server. With the default settings this is going to add up to a lot of Redis connections.
235+
Let's say for example you have a web application with 30 producer queues and you run 10 webservers & 10 worker servers, each one with 4 processes/server. With the default settings this is going to add up to a lot of Redis connections. Each Redis connection consumes a fairly large chunk of memory, and it adds up quickly!
236236

237237
The producer queues are the ones that run on the webserver and they push jobs into the queue. These queues do not need to receive events so they can all share one redis connection by passing in an instance of [node_redis `RedisClient`](https://github.com/NodeRedis/node_redis#rediscreateclient).
238238

239239
Example:
240240

241-
```javascript
241+
```js
242242
// producer queues running on the web server
243-
const Queue = require('bee-queue')
244-
const redis = require('redis')
243+
const Queue = require('bee-queue');
244+
const redis = require('redis');
245245
const sharedConfig = {
246246
getEvents: false,
247247
isWorker: false,
248248
redis: redis.createClient(process.env.REDIS_URL)
249-
}
249+
};
250250

251-
const emailQueue = new Queue('EMAIL_DELIVERY', sharedConfig)
252-
const facebookUpdateQueue = new Queue('FACEBOOK_UPDATE', sharedConfig)
251+
const emailQueue = new Queue('EMAIL_DELIVERY', sharedConfig);
252+
const facebookUpdateQueue = new Queue('FACEBOOK_UPDATE', sharedConfig);
253253

254-
emailQueue.createJob({})
255-
facebookUpdateQueue.createJob({})
254+
emailQueue.createJob({});
255+
facebookUpdateQueue.createJob({});
256256
```
257257

258258
Note that these "producer queues" above are only relevant for the processes that have to put jobs into the queue, not for the workers that need to actually process the jobs.
259259

260260
In your worker process where you define how to process the job with `queue.process` you will have to run "worker queues" instead of "producer queues". In the example below, even though you are passing in the shared config with the same redis instance, because this is a worker queue Bee-Queue will `duplicate()` the client because it needs the blocking commands for PubSub subscriptions. This will result in a new connection for each queue.
261261

262-
```javascript
262+
```js
263263
// worker queues running on the worker server
264-
const Queue = require('bee-queue')
265-
const redis = require('redis')
264+
const Queue = require('bee-queue');
265+
const redis = require('redis');
266266
const sharedConfig = {
267267
redis: redis.createClient(process.env.REDIS_URL)
268-
}
268+
};
269269

270-
const emailQueue = new Queue('EMAIL_DELIVERY', sharedConfig)
271-
const facebookUpdateQueue = new Queue('FACEBOOK_UPDATE', sharedConfig)
270+
const emailQueue = new Queue('EMAIL_DELIVERY', sharedConfig);
271+
const facebookUpdateQueue = new Queue('FACEBOOK_UPDATE', sharedConfig);
272272

273-
emailQueue.process((job) => { })
274-
facebookUpdateQueue.process((job) => { })
273+
emailQueue.process((job) => {});
274+
facebookUpdateQueue.process((job) => {});
275275
```
276276

277277
For a more detailed example and explanation see [#96](https://github.com/bee-queue/bee-queue/issues/96)

0 commit comments

Comments
 (0)