Node.js Worker Threads Test

The worker threads module of Node.js allows users to create multiple tasks in parallel and execute those tasks. These worker threads divide CPU-bound tasks to many workers for optimization and do not block the main thread. This means each worker thread runs its js code entirely in isolation from the other worker threads. Worker threads do not help much with I/O-intensive work. They can perform long-running tasks without affecting or blocking the main execution thread. The Node.js built-in asynchronous I/O operations are more efficient than Workers can be.

Node. js worker threads spawn child processes that operate independently of the JavaScript code in the main process. They work by spawning an isolated instance of Node's V8 JavaScript runtime. The new runtime can then be used to execute a JavaScript file out of the main event loop.

If there is a sudden/gradual increase in the heap memory and CPU utilized by the threads, then, the resources allocated to the threads will not be shared among all the threads that are executing. This imbalance will lead to a few threads in want of more resources and hence may delay the execution of the threads. To avoid such eventualities, it is essential to monitor the performance of the threads that are executing on the target Node.js server round the clock. The Node.js Worker Threads test helps administrators in this regard!

This test auto-discovers the worker threads executing on the target Node.js server and for each worker thread, this test reports the overall performance and resource utilization of each thread. Using this test, administrators can easily identify the threads that are consuming too much of memory and CPU resources. This test also throws light on the tests that are taking too long to perform a full garbage collection and minor garbage collection. This test also reports the overall cont of threads that are executing on the target server.

Target of the test : A Node.js V8 Engine

Agent deploying the test : An internal agent

Outputs of the test : One set of results for every worker thread executing on each instance of the target Node.js server being monitored

Descriptor: Thread

Configurable parameters for the test
Parameter Description

Test Period

How often should the test be executed.

Host

The IP address of the host for which this test is to be configured.

Port

The port at which the target Host listens to. By default this is 3000.

DD Frequency

Refers to the frequency with which detailed diagnosis measures are to be generated for this test. The default is 1:1. This indicates that, by default, detailed measures will be generated every time this test runs, and also every time the test detects a problem. You can modify this frequency, if you so desire. Also, if you intend to disable the detailed diagnosis capability for this test, you can do so by specifying none against DD frequency.

Detailed Diagnosis

To make diagnosis more efficient and accurate, the eG Enterprise embeds an optional detailed diagnostic capability. With this capability, the eG agents can be configured to run detailed, more elaborate tests as and when specific problems are detected. To enable the detailed diagnosis capability of this test for a particular server, choose the On option. To disable the capability, click on the Off option.

The option to selectively enable/disable the detailed diagnosis capability will be available only if the following conditions are fulfilled:

  • The eG manager license should allow the detailed diagnosis capability
  • Both the normal and abnormal frequencies configured for the detailed diagnosis measures should not be 0.
Measurements made by the test
Measurement Description Measurement Unit Interpretation

Uptime

Indicates the uptime of this thread.

Minutes

The detailed diagnosis of this measure lists the path to the exact file on which the thread was executed.

Mean execution time

Indicates the mean time of the recorded event loop delays.

Seconds

Compare the value of this measure across threads to identify the thread that took too long to record event loop delays.

Idle time

Indicates the time duration for which this thread was idle during the last measurement period.

Seconds

Ideally, the value of this measure should be high, as the presence of idle threads is a sign that threads are available for processing future queries.

Compare the value of this measure across threads to identify the thread that has been idle for a longer duration.

Active time

Indicates the time duration for which this thread was active during the last measurement period.

Seconds

Compare the value of this measure across threads to identify the thread that was most active for the maximum time duration.

Utilization

Indicates the percentage utilization of this thread.

Percent

Compare the value of this measure across threads to identify the threads that are the most/least busiest.

Full GC time

Indicates the time taken by this thread to complete a full garbage collection.

 

 

Minor GC time

Indicates the time taken by this thread to complete a minor garbage collection.

 

 

Full GC count

Indicates the number of times this thread performed full garbage collection.

Number

Compare the value of this measure across threads to identify the thread that has performed full garbage collection for maximum number of times.

Minor GC count

Indicates the number of times this thread performed minor garbage collection.

Number

 

Heap used

Indicates the amount of heap memory utilized by this thread.

MB

 

Max heap

Indicates the maximum amount of heap memory utilized by this thread.

MB

 

Free heap

Indicates the amount of heap memory that is available for use by this thread.

MB

 

Heap used Percentage

Indicates the percentage of heap memory that was utilized by this thread.

Percent

Compare the value of this measure across threads to identify the thread that had utilized maximum heap memory.

Thread cpu usage

Indicates the CPU utilization of this thread.

Percent

Compare the value of this measure across threads to identify the thread with maximum CPU utilization.

Total thread count

Indicates the total number of threads executing on the server.

Number

This measure is applicable only for the Summary descriptor.