Node.js interview questions: Performance and observability

Performance interviews are tests of experimental discipline. The prompt may claim that Node.js is slow, memory is high, or one endpoint regressed after a deploy. Weak answers immediately prescribe caching, workers, or a larger machine. Strong answers define the symptom, choose a measurement that can separate competing explanations, and preserve enough context to connect a runtime signal to user-visible latency. Staff-level reasoning also accounts for coordinated omission, cardinality, sampling, and the cost of the instrumentation itself.

This question set is built around evidence chains. Opening answers mention profilers and metrics; follow-ups ask which metric, at what aggregation, under what workload, and what result would change the proposed fix. Practice moving from RED-style service signals to event-loop delay, CPU profiles, allocation data, and trace boundaries without collecting everything by default. The unlocked sample shows how capacity math and targeted instrumentation make an answer credible. You should finish each chain with a reproducible experiment, a bounded change, and a before-and-after number rather than a performance story that cannot be falsified.

Covered in Volume 5: Profiling and observability
Question 01Answers in Raw Mode

Say you've got a Node service that's slow and CPU is pegged. Walk me through how you'd actually find the bottleneck instead of guessing at it.

A strong answer reaches for a CPU profile and a flame graph to see where the time really goes, instead of guessing and optimizing on gut feel

Senior

How you grab a CPU profile without taking the process down, what width and depth in a flame graph really tell you, and how to spot event-loop starvation hiding behind on-CPU work.

Staff

Profiling safely in production, why an I/O-wait problem won't even show up in the profile, and how you back the fix with a proper before-and-after measurement.

Follow-up chain

  1. Okay, you've got a CPU profile open. When you look at the flame graph, what's the width of a frame actually telling you, and what about the stacking?
  2. Say the flame graph shows your handler is cheap, but requests are still slow. Where's that time hiding?
  3. How would you pull a CPU profile off a live production process without taking it down?
  4. So you found the hot function and optimized it. How do you prove that actually helped?
Question 02Answers in Raw Mode

If you could only watch one metric to catch a Node process going bad before users notice, what would it be? And how do you measure it properly?

A strong answer picks event-loop delay as the metric that moves first when a Node process goes bad, and measures it as a histogram instead of an average

Senior

Why event-loop delay beats CPU at predicting the latency users feel, how `monitorEventLoopDelay` builds its histogram, and what it means when p99 lag starts climbing.

Staff

How to pick a threshold that catches real stalls without crying wolf, tying lag spikes back to the synchronous code behind them, and why 'add more CPU' almost never fixes it.

Follow-up chain

  1. How is it that CPU can look totally healthy while the event loop is stalled and requests are piling up?
  2. Okay, so what kind of code actually causes a lag spike like that, and how do you track down which handler it was?
  3. Why bother with a histogram for event-loop delay? What's wrong with just reporting the average?
  4. Where would you actually set the alert threshold for lag? And what's the danger in picking one fixed number?
Question 03Answers in Raw Mode

Say memory on one of your Node services just keeps climbing in production. How would you dig into that without bouncing the process?

A strong answer keeps RSS, heapUsed, and external memory straight, and can chase a production leak without ever bouncing the process

Senior

What RSS, heapUsed, and external each actually measure, why a Buffer leak will never show up in heapUsed, and how you tell a growing retained set from normal churn.

Staff

How to capture comparable heap snapshots off a live process, read the diff for the retaining path, and tell a real leak apart from GC that just hasn't run yet.

Follow-up chain

  1. Say heapUsed is flat but RSS just keeps growing. What's leaking there, and where do you go looking?
  2. How would you confirm that's Buffers or native memory and not just heap fragmentation?
  3. How do you actually take a heap snapshot on a production process? And what's the cost you have to plan around?
  4. Memory climbed for an hour and then dropped off sharply. Was that a leak? How would you tell?
Question 04Answers in Raw Mode

Suppose your p99 shows these periodic spikes and they line up with garbage collection. How do you think about that, and what would you actually change?

A strong answer ties GC pauses to the latency-tail spikes and reaches for allocation rate as the first lever, long before any GC tuning flag

Senior

Why the generational design keeps minor GC cheap while major GC is the pause that hurts, how that pause turns into tail latency, and why allocation rate drives all of it.

Staff

How to measure GC pause time against your SLO, cut allocation pressure before you touch a single flag, and tell when a heap-size change helps and when it just hides the problem.

Follow-up chain

  1. So why is it the major GCs that hurt your latency tail, when the minor ones mostly don't?
  2. And what is it in your code that decides how often a major GC has to run?
  3. Say a teammate wants to bump --max-old-space-size to fix the spikes. When does that actually help, and when are you just trading up to a bigger pause later?
  4. How would you actually put a number on GC's share of your latency instead of guessing at it?
Question 05Answers in Raw Mode

You'll notice experienced engineers basically refuse to look at average latency. Why is that, and what do they look at instead?

A strong answer thinks in percentiles and histograms instead of averages, and can explain why the tail is what users actually feel

Senior

What an average quietly erases, why a high-fan-out request lives in the tail, and why you can't just average percentiles across your hosts.

Staff

How histograms let you aggregate latency correctly, why one slow dependency ends up dominating a fanned-out request, and which percentile you actually hold yourself to.

Follow-up chain

  1. Say a request fans out to 20 backends and has to wait for all of them. Why does one backend's p99 end up being the typical experience for the whole request?
  2. Okay, so how do you cut down that tail amplification without going and making every backend faster?
  3. Why can't you just take the p99 from each of your ten instances and average them?
  4. So which percentile do you actually put the SLO on, and how do you defend that choice?
Question 06Answers in Raw Mode

When you load test a Node service, how do you make sure the numbers aren't lying to you?

A strong answer knows the ways a load test lies, skipped warmup, coordinated omission, closed-model backpressure, and designs the test around all three

Senior

Why warmup, connection reuse, and your choice of load model all bend the numbers, and what coordinated omission quietly does to the tail latency you report.

Staff

How to build a test that actually reproduces production, open model, realistic connection reuse, corrected latency, then find the knee where the service really falls over.

Follow-up chain

  1. So what exactly is coordinated omission, and which way does it skew your latency numbers?
  2. And how do you run a load test that doesn't fall into that trap?
  3. Walk me through open model versus closed model. How does that choice change what an overload test even measures?
  4. Why is skipping warmup such a problem for a Node service in particular? What does it do to the test?
Question 07Answers in Raw Mode

Let's say you're adding a cache in front of a hot read path. What are the decisions that actually determine whether it helps or blows up on you?

A strong answer picks the cache layer by its consistency and invalidation behavior, and knows a stampede can make a cache hurt more than it helps

Senior

The three axes that actually matter, placement, consistency, and invalidation, plus why an in-process cache drifts per instance and how a hot key's expiry turns into a stampede.

Staff

How you stop stampedes with a lock or early recompute, pick a placement that fits your consistency needs, and why hit rate and origin load only make sense measured together.

Follow-up chain

  1. So an in-process cache and a shared Redis behave differently on consistency. What actually breaks with the in-process one once you're running a fleet?
  2. Given all that, when would you still pick a per-instance in-process cache?
  3. Say a really popular key expires and every instance goes to recompute it at the same time. What's that called, and how do you stop it?
  4. Everyone says invalidation is the hard part. What makes it harder than just setting a TTL and moving on?
Question 08Answers in Raw Mode

In Node, how does distributed tracing actually follow a request across all those async boundaries? And what does that machinery cost you at runtime?

A strong answer explains how `AsyncLocalStorage` carries context across async boundaries and what that machinery actually costs at runtime

Senior

How `AsyncLocalStorage` gets context across awaits with zero manual threading, the `async_hooks` machinery underneath, and where that per-operation cost really comes from.

Staff

How to decide what's worth tracing and at what sampling rate once you know the runtime cost, carry context across service boundaries, and measure the overhead you actually added.

Follow-up chain

  1. So without threading a trace ID through every function signature, how does AsyncLocalStorage get the context to code way down in an async call chain?
  2. And where does the runtime overhead of that mechanism actually come from?
  3. Now the trace has to cross a network call into another service. What actually travels across, and how?
  4. You can't afford to trace everything. So how do you sample without throwing away the traces you actually need?
Question 09Answers in Raw Mode

Logging feels like the most boring part of the stack, right up until it's your bottleneck. What makes logging hard at scale in Node, and why is pino designed the way it is?

A strong answer treats logging as a performance surface, structured output, async transport, sampling, and can say why pino is fast where a naive logger isn't

Senior

Why unstructured logs stop being queryable at volume, what synchronous logging does to your event loop, and the design choices that keep pino cheap on the hot path.

Staff

How to keep logging off the hot path, sample high-volume logs without losing the ones you'll need, and the ugly failure where a slow log destination stalls the whole process.

Follow-up chain

  1. Once you've got real volume, why is a structured JSON log line worth so much more than a nicely formatted human string?
  2. And what does pino actually do to keep the cost of producing that line off the request path?
  3. console.log can write synchronously in some cases, right? How does that end up stalling your event loop?
  4. Say you're logging way too much to store it all. How do you sample without throwing away the logs you actually need?
Question 10Answers in Raw Mode

How would you figure out how many instances a Node service actually needs? And when do you add instances versus just making the code faster?

A strong answer builds capacity from measured per-core throughput and makes the scale-out versus optimize call from where the bottleneck actually sits

Senior

Why one Node process means one core for your JavaScript, how you actually measure requests-per-core, and what really caps a single instance's throughput.

Staff

How to plan capacity from measured headroom plus a safety margin, decide scale-out versus optimize by where the bottleneck lives, and spot the case where more instances make it worse.

Follow-up chain

  1. So one Node process runs your JavaScript on one core. What does that actually mean for how you use a multi-core machine?
  2. And how do you go about measuring that requests-per-core number the whole capacity plan hangs on?
  3. Say the event loop is the bottleneck on one instance. Why might adding instances do nothing for you, or even make things worse?
  4. You've got the option to either optimize the code or just add instances. How do you make that call?

EVERY ANSWER IS PART OF RAW MODE.

Raw Mode trains the follow-ups.

Unlock every first, Senior, and Staff answer, every tree answer, the debug repos, hallucination drills, design scenarios, and the framework capstone.Get NodeBook Raw Mode