Raw HTTP Server: A Minimal API Without Frameworks
On this page
HTTP Server as a Runtime Boundary
The http module is not a framework. It is a thin abstraction over TCP sockets that exposes request and response streams. In production systems, this boundary defines latency, throughput, and resource consumption.
Server Lifecycle
An HTTP server must handle connection setup, request parsing, response streaming, and graceful shutdown. Production systems must handle SIGTERM correctly and stop accepting new connections before shutting down.
import http from 'http';
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('OK');
});
server.listen(3000);
Production Considerations
Always monitor open connections, memory usage per request, and avoid synchronous work inside request handlers. HTTP is the concurrency gateway of your system.