David
David

Reputation: 999

Why is my node.js server process cloned?

Why is my node.js server process cloned? And I did no requests since I put it up. I'm using forever node module. Could it be related?

enter image description here

Upvotes: 1

Views: 41

Answers (1)

mscdex
mscdex

Reputation: 106696

What you are seeing are the threads in the same node process. v8 (for optimizing functions, collecting garbage, etc.) and libuv/node (for performing file system operations on most platforms, DNS lookups, zlib, etc.) use additional threads, so those are what you are seeing.

As of this writing, v8 uses at most 4 threads (although an option to configure this previously hardcoded value is available in node v5.10.0+). Also, libuv by default creates a thread pool of 4 threads, but this number can be changed by setting the UV_THREADPOOL_SIZE environment variable. Care should be taken when adjusting these values since it could affect performance negatively if set too low or set too high.

FWIW in htop's setup menu you can configure it (under display settings) to both show process trees and make threads a different color. Those changes will make it easier to see the difference between threads and processes.

Upvotes: 1

Related Questions