Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

494 B
Raw Blame
import os from 'node:os'

const DEFAULT_UV_THREADPOOL_SIZE = 4

/**
 * How much work the libuv threadpool can carry at once. `os.availableParallelism()` respects cgroup CPU limits, so
 * in-container this sees the pod's cores rather than the node's.
 */
export function threadpoolConcurrency(): number {
    const uvThreadpoolSize = parseInt(process.env.UV_THREADPOOL_SIZE ?? '', 10) || DEFAULT_UV_THREADPOOL_SIZE
    return Math.max(1, Math.min(os.availableParallelism(), uvThreadpoolSize))
}