QA
Senior LevelNode JS

How do you debug production Node.js CPU spikes and kernel hangs using eBPF, Linux perf, and 0x flamegraphs?

❓ Interview Prompt: Explain production CPU profiling, V8 `--perf-basic-prof`, Linux `perf record`, and generating 0x flamegraphs.

Diagnosing production Node.js CPU spikes without stopping processes uses Linux 'perf' and 0x Flamegraphs:

Profiling Workflow:

1
Start Node with '--perf-basic-prof' to output V8 JIT symbols to '/tmp/perf-PID.map'.
2
Sample CPU stacks: 'perf record -F 99 -p <PID> -g -- sleep 30'.
3
Render SVG Flamegraph mapping CPU time spent in JS code vs V8 C++ bindings vs Linux kernel syscalls!

Code Implementation Example

bash
# Profile Node.js CPU spikes and generate Flamegraph
npx 0x --node-options="--perf-basic-prof" server.js
💡Profiling production Node.js CPU spikes using 0x flamegraph generator.
🎯 Interview Key Takeaway

Use Linux perf and 0x flamegraphs to pinpoint CPU-bound V8 functions and kernel bottlenecks in production.

#perf#Flamegraphs#0x#Profiling#Senior
Back to all Node JS Questions→

More Node JS Interview Questions

Beginner LevelNode JS

How does the Node.js Event Loop work? Explain the 6 execution phases (Timers, Pending, Poll, Check, Close).

Beginner LevelNode JS

What does 'Single-Threaded, Event-Driven, Non-Blocking I/O' mean in Node.js?

Beginner LevelNode JS

What is the difference between process.nextTick() and setImmediate()?