DEV Community

Jérôme Chauveau
Jérôme Chauveau

Posted on

Nodejs worker pools fine tuning

Hi everyone,

If I understood correctly:

1) by default nodejs provides a worker pool, whose size can be tuned with UV_THREADPOOL_SIZE (default: 4)
2) a cpu or io intensive task can use thread from this worker pool (this is the case for node modules like DNS or Crypto) or create a dedicated worker pool
3) total number of worker pools should not exceed the actual number of cpu capability of where the application is running

My questions:

1) how do you track the actual number of workers being used by your application ?
2) when using third party modules (for instance mongoose or JSONStream), one should be aware of those modules strategy (use of default worker pool or dedicated worker pool). Does that mean that for every module used one should look into the code to determine its strategy?
3) the use of node cluster (for instance with pm2) seems that it complicates the fine tuning of the number of workers, and that it'd be better to just scale out. Your advice on this matter?

Thanks for your feedback

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more