diff --git a/.config/example.yml b/.config/example.yml index ca47c31415..e23ab126c6 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 b698548d47..381c4bc4ca 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 9ecf495c42..18382d7435 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 a7e9b9814f..0b20017291 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); }