diff --git a/apps/platform/src/config/env.ts b/apps/platform/src/config/env.ts index 3866faa3..e444f7fc 100644 --- a/apps/platform/src/config/env.ts +++ b/apps/platform/src/config/env.ts @@ -79,6 +79,7 @@ export default (type?: EnvType): Env => { host: process.env.REDIS_HOST!, port: parseInt(process.env.REDIS_PORT!), tls: process.env.REDIS_TLS === 'true', + concurrency: parseInt(process.env.REDIS_CONCURRENCY ?? '10'), }), }), storage: driver(process.env.STORAGE_DRIVER ?? 'local', { diff --git a/apps/platform/src/queue/RedisQueueProvider.ts b/apps/platform/src/queue/RedisQueueProvider.ts index a7f218c2..bbd0894f 100644 --- a/apps/platform/src/queue/RedisQueueProvider.ts +++ b/apps/platform/src/queue/RedisQueueProvider.ts @@ -9,6 +9,7 @@ import { DefaultRedis, Redis, RedisConfig } from '../config/redis' export interface RedisQueueConfig extends QueueTypeConfig, RedisConfig { driver: 'redis' + concurrency: number } export default class RedisQueueProvider implements QueueProvider { @@ -17,11 +18,13 @@ export default class RedisQueueProvider implements QueueProvider { queue: Queue bull: BullQueue worker?: Worker + concurrency: number batchSize = 40 as const queueName = 'parcelvoy' as const - constructor(config: RedisQueueConfig, queue: Queue) { + constructor({ concurrency, ...config }: RedisQueueConfig, queue: Queue) { this.queue = queue + this.concurrency = concurrency this.redis = DefaultRedis(config, { maxRetriesPerRequest: null, }) @@ -98,7 +101,7 @@ export default class RedisQueueProvider implements QueueProvider { }) }, { connection: this.redis, - concurrency: this.batchSize, + concurrency: this.concurrency, metrics: { maxDataPoints: MetricsTime.TWO_WEEKS, },