AWS MemoryDB
Source URL: https://docs.bullmq.io/guide/redis-tm-hosting/aws-memorydb
AWS MemoryDB
Section titled “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).
- 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:
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 downawait worker.close();await connection.quit();