From 6a0affcec10088ff60ab725f2564e7df7f0eaf17 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Tue, 27 Aug 2019 05:33:24 +0900 Subject: [PATCH] Tune worker/job counts (#5346) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * デフォルトのワーカー数を1に * Tune default job count --- .config/example.yml | 6 +++++- src/boot/master.ts | 2 +- src/config/types.ts | 3 +++ src/queue/index.ts | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index ca47c3141..e23ab126c 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -116,8 +116,12 @@ autoAdmin: true # Whether disable HSTS #disableHsts: true -# Clustering +# Number of worker processes #clusterLimit: 1 +# Job concurrency per worker +# deliverJobConcurrency: 128; +# inboxJobConcurrency: 16; + # IP address family used for outgoing request (ipv4, ipv6 or dual) #outgoingAddressFamily: ipv4 diff --git a/src/boot/master.ts b/src/boot/master.ts index b698548d4..381c4bc4c 100644 --- a/src/boot/master.ts +++ b/src/boot/master.ts @@ -159,7 +159,7 @@ async function init(): Promise { return config; } -async function spawnWorkers(limit: number = Infinity) { +async function spawnWorkers(limit: number = 1) { const workers = Math.min(limit, os.cpus().length); bootLogger.info(`Starting ${workers} worker${workers === 1 ? '' : 's'}...`); await Promise.all([...Array(workers)].map(spawnWorker)); diff --git a/src/config/types.ts b/src/config/types.ts index 9ecf495c4..18382d743 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -42,6 +42,9 @@ export type Source = { id: string; outgoingAddressFamily?: 'ipv4' | 'ipv6' | 'dual'; + + deliverJobConcurrency?: number; + inboxJobConcurrency?: number; }; /** diff --git a/src/queue/index.ts b/src/queue/index.ts index a7e9b9814..0b2001729 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -203,8 +203,8 @@ export function createCleanRemoteFilesJob() { export default function() { if (!program.onlyServer) { - deliverQueue.process(128, processDeliver); - inboxQueue.process(128, processInbox); + deliverQueue.process(config.deliverJobConcurrency || 128, processDeliver); + inboxQueue.process(config.inboxJobConcurrency || 16, processInbox); processDb(dbQueue); procesObjectStorage(objectStorageQueue); }