Introduction to Node.js: History, Core Features, and Ecosystem
This article introduces Node.js by recounting its creator Ryan Dahl's background, explaining its core characteristics of single‑threaded, event‑driven, non‑blocking I/O architecture, describing suitable use cases, and reviewing basic code examples and popular frameworks such as Express, Koa, Nest, and Egg.
The article begins with a brief biography of Node.js founder Ryan Dahl, noting his academic work in New York, his move to Chile, and his evolution into a high‑performance web specialist who identified event‑driven, asynchronous I/O as key to solving performance problems.
It explains that after the V8 JavaScript engine proved powerful, Dahl embedded it into a backend runtime, naming the project Node in February 2009 and releasing it publicly in May of the same year.
Node.js Overview
Node.js is not a language but a JavaScript runtime built on V8. Unlike PHP or JSP, it does not require an external web server such as Apache or Nginx; it can serve HTTP requests directly.
The platform’s three defining ideas are:
Single‑threaded execution
Event‑driven architecture (event loop)
Non‑blocking (asynchronous) I/O
These concepts allow a single process to handle tens of thousands of concurrent connections, because the thread never blocks on I/O and the event loop continuously dispatches callbacks.
Single Thread
Traditional servers create a new thread per client, consuming significant memory (e.g., each PHP‑FPM thread may use ~20 MB). Node.js maintains only one thread, eliminating thread‑creation overhead and achieving high concurrency on modest hardware.
Non‑Blocking I/O
In blocking I/O, the program pauses until data is read or written, reducing throughput. Node.js immediately continues execution after initiating an I/O operation, handling the result later via a callback, which keeps the CPU fully utilized.
Event‑Driven Model
All actions—requests, data submissions, etc.—emit events. While only one event callback runs at a time, the loop can switch to other pending events, enabling responsive handling of new connections while previous callbacks are awaiting I/O.
Typical Use Cases
Node.js excels at I/O‑heavy workloads such as real‑time applications, websockets, crawlers, form collection, exam systems, live streaming, chat rooms, and API services, but is less suited for CPU‑intensive tasks.
Basic Example from the Official Docs
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});This snippet demonstrates Node.js’s ability to create a simple HTTP server, but it lacks robustness and maintainability for larger projects.
Framework Evolution
With the rise of npm, many libraries and frameworks emerged. Early popular choices include Express, which simplifies routing and response handling:
const express = require('express');
const app = express();
app.get('/', function (req, res) {
res.send('Hello World');
});
app.listen(3000);Later frameworks such as Koa introduced an onion‑style middleware model, while Nest.js (TypeScript‑first) and Egg.js (Koa‑based) provide more opinionated, enterprise‑grade structures.
The author notes that moving from plain Node.js to these frameworks greatly improves code readability, stability, and development efficiency.
Conclusion
Node.js’s three core traits—single thread, non‑blocking I/O, and event‑driven execution—are interrelated mechanisms that together deliver high concurrency. When combined with modern frameworks and TypeScript, Node.js becomes a powerful platform for building scalable, real‑time backend services.
New Oriental Technology
Practical internet development experience, tech sharing, knowledge consolidation, and forward-thinking insights.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.