On this page

Technology

Node.js

Node.js runs JavaScript and TypeScript on the server. I use it for APIs, background workers and real-time servers, including an authoritative game server that keeps one shared state for a whole room of players

Type
Technology
Official site
nodejs.org
In my work
Projects 1 · Tools 1 · Services 3
Published

What is Node.js and what do I build on it?

Node.js handles many open connections with little overhead, which is exactly what real-time products need. It also lets the server and the interface share one language and one set of types

Key facts

Type
JavaScript runtime for servers, built on the V8 engine ·
Model
asynchronous and event-driven ·

How I use Node.js

  • An authoritative game server. In my multiplayer platform, Node.js with Express and Socket.IO is the single source of truth: phones send inputs, the server applies them up to 60 times per second and sends the state to the big screen. A phone cannot decide on its own that it scored. Read the case study.
  • APIs and workers. The back ends of my products: sign-in, payments, notifications, analytics and scheduled jobs, such as a weekly report sent to Telegram.
  • Operations. On my own server the Node.js processes run under PM2, and a new release has to pass its health checks before it takes traffic.

When I choose Node.js and its limits

Node.js is my default for APIs and real-time servers: it is quick to build with, it handles many idle connections well and it shares types with the front end.

Heavy computation is its weak spot: a long calculation blocks every other request on the same process. Such work goes to a separate worker or to a service in another language. For machine-learning code I use Python, where the libraries are.

Used together with

Sources

  1. About Node.js — OpenJS Foundation ·

Contact

Have an idea? Let’s make it work