From d65037d4e73db76f928c2e3bd5ada12b20d19e3d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 2 Sep 2024 09:31:18 -0400 Subject: [PATCH] perf: Increase default concurrency on worker --- server/env.ts | 18 ++++++++++++++++++ server/services/worker.ts | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/server/env.ts b/server/env.ts index 84ac65f70f..5b420f2e11 100644 --- a/server/env.ts +++ b/server/env.ts @@ -406,6 +406,24 @@ export class Environment { environment.SOURCE_COMMIT || environment.SOURCE_VERSION ); + /** + * The maximum number of concurrent events processed per-worker. To get total + * concurrency you should multiply this by the number of workers. + */ + @IsOptional() + @IsNumber() + public WORKER_CONCURRENCY_EVENTS = + this.toOptionalNumber(environment.WORKER_CONCURRENCY_EVENTS) ?? 10; + + /** + * The maximum number of concurrent tasks processed per-worker. To get total + * concurrency you should multiply this by the number of workers. + */ + @IsOptional() + @IsNumber() + public WORKER_CONCURRENCY_TASKS = + this.toOptionalNumber(environment.WORKER_CONCURRENCY_TASKS) ?? 10; + /** * A boolean switch to toggle the rate limiter at application web server. */ diff --git a/server/services/worker.ts b/server/services/worker.ts index 003f74aa83..5e0e7ad5f8 100644 --- a/server/services/worker.ts +++ b/server/services/worker.ts @@ -1,3 +1,4 @@ +import env from "@server/env"; import Logger from "@server/logging/Logger"; import { setResource, addTags } from "@server/logging/tracer"; import { traceFunction } from "@server/logging/tracing"; @@ -18,6 +19,7 @@ export default function init() { // This queue processes the global event bus globalEventQueue .process( + env.WORKER_CONCURRENCY_EVENTS, traceFunction({ serviceName: "worker", spanName: "process", @@ -79,6 +81,7 @@ export default function init() { // as unapplicable events were filtered in the global event queue above. processorEventQueue .process( + env.WORKER_CONCURRENCY_EVENTS, traceFunction({ serviceName: "worker", spanName: "process", @@ -123,6 +126,7 @@ export default function init() { // Jobs for async tasks are processed here. taskQueue .process( + env.WORKER_CONCURRENCY_TASKS, traceFunction({ serviceName: "worker", spanName: "process",