Node.js › Debugging & Diagnostics
How would you use the 'clinic.js' toolset (clinic doctor, clinic flame) to diagnose a Node.js performance problem?
AdvancedAnswer
clinic doctor runs an application under load and produces a diagnostic report highlighting likely categories of problems (event loop blocking, I/O bottlenecks, memory issues) based on observed metrics, pointing you toward which specific tool to use next. clinic flame generates a flame graph -- a visualization of where CPU time is actually being spent across the call stack -- making it straightforward to visually identify which specific function is consuming a disproportionate share of CPU time during a profiling run.
npm install -g clinic
clinic doctor -- node server.js
# generates a report suggesting likely problem categories
clinic flame -- node server.js
# generates an interactive flame graph after the app is exercised under loadReal-world example A team investigating unexplained latency spikes runs clinic doctor against their API under simulated load, which flags 'Event Loop' as the likely culprit; following up with clinic flame reveals a specific synchronous JSON.parse() call on very large payloads as the actual function consuming the disproportionate CPU time blocking the event loop.