FoundationsBeginner3h

How servers work.

Processes, ports, requests, and the request lifecycle.

What is a server?

A server is just a program that waits for requests and sends back responses. It runs on a machine, listens on a port, and stays alive between requests. The same laptop you code on can be a server — "server" is a role, not special hardware. Everything else in this track sits on top of this one idea.

Why it matters

Every backend bug eventually comes back to the request lifecycle: a request came in, your code ran, a response went out — or didn't. If you can picture that loop clearly, logs, timeouts, and crashes stop being mysterious. Hiring teams expect you to explain what happens between "user clicks" and "data returns" without hand-waving.

What to learn

  • Process vs thread vs the event loop, at a high level
  • Ports, sockets, and what "listening on :3000" actually means
  • The request/response lifecycle from accept to close
  • Blocking vs non-blocking work and why it matters for throughput
  • Environment variables and how a process reads its config
  • Graceful startup and shutdown
  • The difference between your dev server and a production process manager

Common pitfall

Treating the server as a fresh start on every request, like a script. It isn't — the process stays alive and shares memory between requests. Global state you mutate in one request is visible to the next one, which is how "works on my machine" bugs and data leaks between users happen.

Resources

Primary (free):

Practice

Write the smallest possible HTTP server in Node with no framework, using only the built-in http module. Make it listen on a port, log every incoming request method and URL, and return a plain text response. Start it, hit it from your browser and from the terminal, then stop it cleanly with Ctrl+C. Done when you can explain every line out loud.

Outcomes

  • Describe the request/response lifecycle from accept to response.
  • Explain what a port is and why two programs can't share one.
  • Start and stop a bare Node HTTP server without a framework.
  • Spot why shared process state can leak between requests.
Back to Backend roadmap