From c87354a603965a73e7500cd07c2fad32839f2c5e Mon Sep 17 00:00:00 2001 From: Manuel Astudillo Date: Mon, 4 Dec 2023 22:27:00 +0000 Subject: [PATCH] GITBOOK-183: change request with no subject merged in GitBook --- docs/gitbook/SUMMARY.md | 4 ++ docs/gitbook/bull/patterns/redis-cluster.md | 9 ++++- docs/gitbook/guide/redis-tm-hosting/README.md | 8 ++++ .../guide/redis-tm-hosting/aws-elasticache.md | 2 + .../guide/redis-tm-hosting/aws-memorydb.md | 37 +++++++++++++++++++ docs/gitbook/patterns/redis-cluster.md | 2 + 6 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 docs/gitbook/guide/redis-tm-hosting/README.md create mode 100644 docs/gitbook/guide/redis-tm-hosting/aws-elasticache.md create mode 100644 docs/gitbook/guide/redis-tm-hosting/aws-memorydb.md create mode 100644 docs/gitbook/patterns/redis-cluster.md diff --git a/docs/gitbook/SUMMARY.md b/docs/gitbook/SUMMARY.md index 3b353011fe..ac3a702586 100644 --- a/docs/gitbook/SUMMARY.md +++ b/docs/gitbook/SUMMARY.md @@ -42,6 +42,9 @@ * [QueueScheduler](guide/queuescheduler.md) * [Redis™ Compatibility](guide/redis-tm-compatibility/README.md) * [Dragonfly](guide/redis-tm-compatibility/dragonfly.md) +* [Redis™ hosting](guide/redis-tm-hosting/README.md) + * [AWS MemoryDB](guide/redis-tm-hosting/aws-memorydb.md) + * [AWS Elasticache](guide/redis-tm-hosting/aws-elasticache.md) * [Architecture](guide/architecture.md) * [NestJs](guide/nestjs/README.md) * [Producers](guide/nestjs/producers.md) @@ -60,6 +63,7 @@ * [Process Step Jobs](patterns/process-step-jobs.md) * [Failing fast when Redis is down](patterns/failing-fast-when-redis-is-down.md) * [Stop retrying jobs](patterns/stop-retrying-jobs.md) +* [Redis Cluster](patterns/redis-cluster.md) ## BullMQ Pro diff --git a/docs/gitbook/bull/patterns/redis-cluster.md b/docs/gitbook/bull/patterns/redis-cluster.md index ac2eac0c60..8f19b0b9c1 100644 --- a/docs/gitbook/bull/patterns/redis-cluster.md +++ b/docs/gitbook/bull/patterns/redis-cluster.md @@ -4,11 +4,18 @@ Bull internals require atomic operations that span different keys. This behavior In summary, to make bull compatible with Redis cluster, use a queue prefix inside brackets. For example: +You can use two approaches in order to make the Queues compatible with Cluster. Either define a queue prefix: + ```typescript const queue = new Queue('cluster', { prefix: '{myprefix}' }); ``` -If you use several queues in the same cluster, you should use different prefixes so that the queues are evenly placed in the cluster nodes. +or prefix the queue name itself: + +```typescript +const queue = new Queue('{cluster}'); +``` +Note that If you use several queues in the same cluster, you should use different prefixes so that the queues are evenly placed in the cluster nodes, potentially increasing performance and memory usage. diff --git a/docs/gitbook/guide/redis-tm-hosting/README.md b/docs/gitbook/guide/redis-tm-hosting/README.md new file mode 100644 index 0000000000..2124f62822 --- /dev/null +++ b/docs/gitbook/guide/redis-tm-hosting/README.md @@ -0,0 +1,8 @@ +--- +description: >- + For BullMQ you are going to need a proper Redis™ hosting solution. In this + section we provide instructions on how to use some of the most popular ones. +--- + +# Redis™ hosting + diff --git a/docs/gitbook/guide/redis-tm-hosting/aws-elasticache.md b/docs/gitbook/guide/redis-tm-hosting/aws-elasticache.md new file mode 100644 index 0000000000..e553bc2964 --- /dev/null +++ b/docs/gitbook/guide/redis-tm-hosting/aws-elasticache.md @@ -0,0 +1,2 @@ +# AWS Elasticache + diff --git a/docs/gitbook/guide/redis-tm-hosting/aws-memorydb.md b/docs/gitbook/guide/redis-tm-hosting/aws-memorydb.md new file mode 100644 index 0000000000..7d82489662 --- /dev/null +++ b/docs/gitbook/guide/redis-tm-hosting/aws-memorydb.md @@ -0,0 +1,37 @@ +# AWS MemoryDB + +AWS provides a Redis™ 7 compatible managed database that is easy to use and is fully compatible with BullMQ. + +There are some considerations to take care when using MemoryDB though. + +* MemoryDB only works in Cluster mode. So you need to use "hash tags" so that the queues get attached to a given cluster node ([read more here](../../bull/patterns/redis-cluster.md)). +* MemoryDB can only be accessed within an AWS VPC, so you cannot access the Redis™ cluster outside of AWS. + +The easiest way to use MemoryDB with BullMQ is to first instantiate a IORedis Cluster instance, and then use that connection as an option to your workers or queue instances, for example: + +```typescript +import { Cluster } from "ioredis" +import { Worker } from "bullmq" + +const connection = new Cluster( + [ + { + host: "clustercfg.xxx.amazonaws.com", + port: 6379, + }, + ], + { + tls: {}, + } +); + +const worker = new Worker("myqueue", async (job: Job) => { + // Do some usefull stuff +}, { connection }); + +// ... + +// Do not forget to close the connection as well as the worker when shutting down +await worker.close(); +await connection.quit(); +``` diff --git a/docs/gitbook/patterns/redis-cluster.md b/docs/gitbook/patterns/redis-cluster.md new file mode 100644 index 0000000000..c67e2127e8 --- /dev/null +++ b/docs/gitbook/patterns/redis-cluster.md @@ -0,0 +1,2 @@ +# Redis Cluster +