Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Run nodejs script with 100% cpu

I’d like to run my nodejs script with 100% cpu usage. How can I achieve this?

I want to do some calculations really fast and I think with more cpu usage it will run faster.

It is stuck at 15% cpu usage.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Javascript is single threaded, it can only run in a single core of your processor.

Your JS process currently uses 100% of a core, hence, 15% (1/6) of your total computational power.

You need to do parallel computations with cluster module to use all your processor power.

This can be very tricky to do efficiently because you will need a common memory between processes to avoid useless computations.

If you want to do it, the easiest way is to have the primary process giving await numbers to workers to compute.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading