1. Concept library
  2. Backend with Node.js
  3. Module 10: Caching and performance

Concept

Profiling

Profiling shows where a Node process spends CPU time and memory under real load. The built-in inspector and --cpu-prof produce profiles you can read in Chrome DevTools.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain what a CPU profile shows and what memory profiling adds
  2. Record a profile under load with --cpu-prof and read it in DevTools
  3. Spot the profile of an idle server

In practice

A few lines that show Profiling doing its job.

Bash
# CPU profile of a load test
node --cpu-prof --cpu-prof-dir=./profiles src/server.js &
npx autocannon -c 50 -d 20 http://localhost:3000/api/v1/orders
kill %1
# open profiles/*.cpuprofile in Chrome DevTools > Performance

# a heap snapshot for a suspected leak
node --heapsnapshot-signal=SIGUSR2 src/server.js

The common mistake

Watch for

Profiling without load. A profile of an idle server shows nothing; generate realistic traffic and profile while it runs.

What to know first

Your roadmap puts these before Profiling, unless you already know them.

How it stays learned

Once a session shows you understand Profiling, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled
Previous in the module← In-memory caches