I
I
ikerya2018-09-23 21:28:38
Node.js
ikerya, 2018-09-23 21:28:38

What in a NodeJS script can load the CPU and how to track exactly where in the code this situation occurs?

Hello. I began to notice that one socket server script loads the processor very heavily. And if you disable this script, then the load on the processor will disappear. Tell me, please, what is the first thing to pay attention to.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Aleksei Podgaev, 2018-09-28
@alexiusp

Two relatively expensive operations that are often overlooked - console.log (and generally outputting somewhere) and JSON.parse/stringify - see if you don't use them often. Especially JSON parsing can be well optimized if you think about where and how the result is used.

A
Andrey, 2018-09-24
@VELIK505

First of all, run the node in the cluster.
Node.js 100% cpu 1st core 3400MHZ at 5000 connections. What's wrong? - Read what might help. and so it is necessary to look at the logic of what the script does and what is used.

R
Roman Mirilaczvili, 2018-09-24
@2ord

Can be observed by calling the strace utility .
See also www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
There's also an example for Node.js profiling.
dtrace.org/blogs/dap/2012/01/05/where-does-your-no...

D
Dmitry Makarov, 2018-09-27
@MDiMaI666

Learn how to use the debugger or visual studio profiler

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question