DEV Community

Barney
Barney

Posted on

How many threads should I create? (worker_threads) Nodejs

I recently started looking into nodejs's thead_workers module. It seems really interesting however there is one thing that is not self-evident. The official documentation says that I should create a threadpool. But what should be the size of my threadpool? Should it be equal to my phyisical CPU count or cpu's thread count? For example I have a i5 with 4 cores and 8 threads. On my machine should I create a threadpool of 4 or 8? Less or more?

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post