Common275 Documents

Cpu Count Parallelism

Always set parallelism to the number of CPU cores available to the process. Derive the value from the operating system at runtime and never hardcode a parallelism or concurrency count.

Correct

import { availableParallelism } from 'node:os'

const parallelism = availableParallelism()

Incorrect

const parallelism = 4
const concurrency = 8