Node.js interview questions: HTTP and networking

HTTP interviews reward engineers who can cross abstraction layers without losing the request. A prompt about keep-alive may turn into socket reuse, parser framing, proxy headers, timeouts, or a slow client that never finishes a body. The opening answer usually describes endpoints and status codes. Deeper rounds ask what bytes arrive, who owns each timeout, which hop terminates TLS, and how backpressure travels when a server streams a response through a proxy to a client.

These questions use that path as the spine. The follow-up trees move from Node's request objects to connection pools, intermediaries, protocol boundaries, and failure timing. Practice drawing the hops before choosing a fix. State which component observes the failure, whether the request can be retried, and what resource remains allocated while everyone waits. The unlocked sample shows how a precise network model produces better application decisions. By the end, you should be able to defend limits, forwarding rules, shutdown behavior, and streaming semantics without treating the network as a transparent pipe.

Covered in Volume 3: HTTP internals and networking
Question 01Answers in Raw Mode

So a client opens a TCP connection to your Node server. Walk me through what actually happens between that moment and your request handler running.

A strong answer follows one request from the accepted socket through llhttp parsing into the JS handler and can say which layer owns what.

Senior

The whole handoff chain, kernel accept queue to libuv to a C parser firing callbacks mid-buffer, and why req is a stream your handler gets before the body finishes.

Staff

Where this pipeline actually stalls under load, accept backlog, parser pauses, header timeouts, and which counters tell you which stage is the problem.

Follow-up chain

  1. So where does backpressure kick in on this path if a client's uploading a big body faster than your handler reads it?
  2. And what's actually happening to the TCP connection while you're not reading req?
  3. Okay, keep-alive means a second request comes down that same socket. What has to get reset between the two?
  4. Say latency is creeping in somewhere. How do you prove it's the parser adding it and not your handler?
Question 02Answers in Raw Mode

Say your service makes a ton of outbound HTTP calls to the same few downstreams. How does Node actually reuse those connections, and what goes wrong if you get that part wrong?

Strong candidates get concrete about connection reuse, agents, socket pools, keep-alive, and know exactly how undici differs from the old http.Agent.

Senior

What an agent really holds, those free and in-use socket lists keyed by host, and why undici's pipelined connection pool acts so differently under concurrency than http.Agent.

Staff

The failures that actually show up at scale, maxSockets queueing and head-of-line stalls on a pooled connection, and how to read the socket counters that give them away.

Follow-up chain

  1. So with the default agent, is there anything capping how many sockets you open to one host? And what happens once you hit that cap?
  2. And how does that queue play with your request timeout?
  3. Node's global fetch doesn't go through http.Agent at all. So what's actually behind it, and how would you tune that pool?
  4. Why does one slow response on a keep-alive connection hold up the others, and when does that actually bite you?
Question 03Answers in Raw Mode

A Node HTTP server ships with a handful of server-side timeouts. What are they, and which attack is each one actually there to stop?

The strong answer names all three server-side timeouts and ties each one to the specific slow-client attack or leak it exists to bound.

Senior

The three separate clocks, headersTimeout, requestTimeout, and keepAliveTimeout, what each one actually measures, the real default values, and how they stack.

Staff

Why bumping a timeout to paper over a proxy quirk quietly reopens slowloris, and how your own metrics can tell a slow legitimate upload from an attack.

Follow-up chain

  1. Say a legitimate upload takes four minutes and suddenly it's coming back 408. Which timeout fired, and how do you fix that without turning the protection off?
  2. What's keepAliveTimeout actually protecting you from, and why does it start to matter once there's a load balancer in front of you?
  3. And how does that turn into random 502s at the load balancer?
  4. Slowloris dribbles headers one byte at a time. Which timeout actually catches that, and why isn't server.timeout the answer?
Question 04Answers in Raw Mode

If you moved a Node service from HTTP/1.1 to HTTP/2, when would that actually buy you something, and where would it not?

A good answer keeps application-layer multiplexing separate from transport-level head-of-line blocking, and knows which one HTTP/2 fixes and which stays.

Senior

The two layers where head-of-line blocking lives, why HTTP/2 kills one and leaves the other alone, and how per-stream flow control changes what you tune.

Staff

Where HTTP/2 actually pays off in real deployments and where it's neutral or worse, plus the failure a single lossy connection creates that HTTP/1.1 pooling dodges.

Follow-up chain

  1. Okay, so HTTP/2 puts all these streams on one connection. When a packet gets lost, what's still blocking every single one of them?
  2. So on a lossy network, could plain HTTP/1.1 with six connections actually beat HTTP/2 on one?
  3. Say you terminate HTTP/2 at a proxy and it speaks HTTP/1.1 to Node behind it. What did you actually get out of that?
  4. What's HTTP/2 flow control doing, and how is that different from the windowing TCP already does?
Question 05Answers in Raw Mode

For a Node service, where would you terminate TLS, and what does that handshake actually cost you?

Strong answers place TLS termination from real constraints and can put numbers on what a handshake costs in round trips and CPU.

Senior

The handshake taken apart, its round trips and its asymmetric-crypto cost, why 1.3 gets it done in one RTT, and what session resumption really reuses.

Staff

How to pick termination placement from real constraints, internal encryption, cert management, CPU headroom, and why handshake cost gets measured apart from throughput.

Follow-up chain

  1. So a full TLS 1.3 handshake fits in one round trip. What's actually happening inside it, and what does 0-RTT resumption get to skip?
  2. And what's the security catch that makes people nervous about 0-RTT?
  3. Okay, you terminate TLS at the load balancer. What does your Node app suddenly get wrong about the client, and how do you get that back?
  4. During a surge of brand-new clients your CPU spikes on handshakes. Why is it new clients specifically, and what would you tune?
Question 06Answers in Raw Mode

How does a request body actually arrive in Node, and how would you accept a really large upload without the process falling over?

A strong answer knows how a request body gets framed on the wire and streamed into Node, and why holding whole bodies in memory will eventually hurt.

Senior

How the body gets framed, Content-Length versus chunked, how req hands it to you as a readable stream, and where the parser passes off backpressure.

Staff

Streaming an upload straight into storage with the size cap enforced mid-read, plus the metrics that spot a memory blowup before it OOMs the process.

Follow-up chain

  1. With chunked transfer encoding there's no Content-Length at all. So how does the server ever know the body's finished?
  2. Say you want a 10MB cap on uploads. Where do you actually enforce that, and why isn't checking Content-Length enough?
  3. And what if a client just lies, declares one Content-Length and keeps sending bytes past it. What happens then?
  4. Piping req straight to a file works fine until the disk can't keep up with the upload. What's backpressure doing for you there?
Question 07Answers in Raw Mode

Say your Node app sits behind a proxy or a load balancer. How do you get the real client IP without getting spoofed, and how does a WebSocket upgrade survive that hop?

Good candidates treat forwarded headers as untrusted until a proxy they control rewrites them, and can walk a WebSocket upgrade through the stack.

Senior

Why X-Forwarded-For stays a client-controlled string until a trusted hop rewrites it, how the trust boundary picks which entry to believe, and what the Upgrade handshake actually does.

Staff

The spoofing and rate-limit-bypass messes you get from trusting forwarded headers the wrong way, and what kills WebSockets at a proxy that buffers or times out.

Follow-up chain

  1. So a client shows up sending its own X-Forwarded-For header. Why can it now walk straight past your rate limiter, and what's the fix?
  2. Walk me through the WebSocket upgrade itself. What HTTP actually goes back and forth before that connection turns into a raw socket?
  3. Say the proxy in front of Node keeps killing idle WebSockets after 60 seconds. Why is it doing that, and how do you keep them alive?
  4. Now put two proxy hops in front. Which X-Forwarded-For entry is the real client, and how do you pick it without getting burned?
Question 08Answers in Raw Mode

How does Node actually turn a hostname into an IP, and why might DNS be quietly capping your outbound throughput?

The strong answer keeps dns.lookup, getaddrinfo on the thread pool, apart from dns.resolve, c-ares over the network, and knows Node caches nothing by default.

Senior

The two resolution paths, getaddrinfo on the thread pool against c-ares over the network, and why the one every http request takes can starve fs and crypto.

Staff

How an uncached, thread-pool-bound lookup turns into latency your downstream gets blamed for, and where caching belongs if you don't want to break failover.

Follow-up chain

  1. So every outbound HTTP request goes through dns.lookup by default. Where does that actually run, and what else is fighting for those threads?
  2. And how would you actually prove it's DNS adding the latency and not the downstream?
  3. Node doesn't cache DNS between calls at all. What starts breaking under load, and what are your two ways out?
  4. When would you deliberately reach for dns.resolve over dns.lookup, knowing it's going to ignore /etc/hosts?
Question 09Answers in Raw Mode

Your logs are filling up with ECONNRESET. What's actually going on down at the socket, and how do you tell a real problem apart from noise?

A strong answer reads socket errors as protocol events, knows which side sent the RST, what half-open means, and treats ECONNRESET as having a cause.

Senior

What an RST really is, how a clean FIN close differs from a reset, and how a half-open connection hangs around until some write finally fails.

Staff

How to sort harmless resets from a real fault, why the listen backlog drops connections while your CPU graph looks fine, and what's worth measuring.

Follow-up chain

  1. What's actually different between a connection that closes with a FIN and one that gets reset with an RST, and which one hands you ECONNRESET?
  2. Say the client hangs up halfway through your response. What error shows up, and why do you need a handler on res and not just req?
  3. Give me your definition of a half-open connection. How does one just sit there with neither side noticing, and what finally surfaces it?
  4. Connections are getting dropped before your handler ever runs. How would the listen backlog cause that, and how do you confirm it's the culprit?
Question 10Answers in Raw Mode

Express versus Fastify versus raw http. How much is the framework layer actually costing you, and when does that cost even matter?

Strong candidates measure framework overhead against a real workload and can point at where Express and Fastify actually spend their time.

Senior

Where the framework's time really goes, route matching, the middleware chain, serialization, and why schema-compiled JSON is Fastify's actual edge over Express.

Staff

When framework overhead is a rounding error next to your real latency and when it genuinely matters, measured on your own workload instead of a hello-world.

Follow-up chain

  1. So Fastify's headline win isn't really the router, it's serialization. What's it doing there that Express doesn't bother with?
  2. And what can go wrong with schema-compiled serialization? How do you make sure you're not leaking fields?
  3. Express middleware is just a straight chain of functions. How does that cost grow, and where does it start to hurt?
  4. A hello-world benchmark says Fastify's three times faster. Why is that number close to useless for your actual API?

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