Distributed Systems with Node.js

Building Enterprise-Ready Backend Services

Distributed Systems with Node.js, a book I wrote through O'Reilly, has been published!

Distributed Systems with Node.js hard copies
Distributed Systems with Node.js hard copies

In this hands-on guide I prove that Node.js is just as capable as traditional enterprise platforms for building services that are observable, scalable, and resilient. Intermediate to advanced Node.js developers find themselves integrating application code with a breadth of tooling from each layer of a modern service stack.

Target Audience

This book won't teach you how to use Node.js, and to benefit the most from it, you should have already written several Node.js applications and have a concrete understanding of JavaScript. That said, this book does cover some advanced and lesser-known concepts about Node.js and JavaScript, such as "The Single-Threaded Nature of JavaScript" and "The Node.js Event Loop". You should also be familiar with the basics of HTTP, have used at least one database for persisting state, and know how easy and dangerous it is to maintain state within a running Node.js process.

Perhaps you already work at a company that has infrastructure for running backend services and you're eager to learn how it works and how your Node.js applications can benefit from it. Or maybe you've got a Node.js application that you're running as a side project and you're tired of it crashing. You might even be the CTO of a young startup and are determined to meet the demands of your growing userbase. If any of these situations sound familiar, then this book is for you.

Table of Contents

  • Why Distributed?
    • Single-Threaded Nature of JavaScript
    • Quick Node.js Overview
    • The Node.js Event Loop
    • Sample Applications
  • Protocols
    • Request and Response with HTTP
    • API Facade with GraphQL
    • RPC with gRPC
  • Scaling
    • The Cluster Module
    • Reverse proxies with HAProxy
    • SLA and Load Testing
  • Observability
    • Environments
    • Logging with ELK
    • Metrics with Graphite, StatsD, and Grafana
    • Distributed Request Tracing with Zipkin
    • Health Checks
    • Alerting with Cabot
  • Containers
    • Introduction to Docker
    • Containerizing a Node.js Service
    • Basic Orchestration with Docker Compose
    • Internal Docker Registry
  • Deployments
    • Build Pipeline with Travis CI
    • Automated Testing
    • Deploying to Heroku
    • Modules, Packages, and SemVer
    • Internal npm Registry
  • Container Orchestration
    • Introduction to Kubernetes
    • Getting Started
    • Deploying an Application
    • Service Discovery
    • Modifying Deployments
  • Resilience
    • The Death of a Node.js Process
    • Building Stateless Services
    • External Caching with Memcached
    • Database Connection Resilience
    • Schema Migrations with Knex
    • Idempotency and Messaging Resilience
    • Resilience Testing
  • Distributed Primitives
    • The ID Generation Problem
    • Introduction to Redis
    • Redis Operations
    • Seeking Atomicity
    • Transactions
    • Lua Scripting
  • Security
    • Wrangling Repositories
    • Recognizing Attack Surface
    • Application Configuration
    • Upgrading Dependencies
    • Upgrading Node.js
Thomas Hunter II Avatar

Thomas has contributed to dozens of enterprise Node.js services and has worked for a company dedicated to securing Node.js. He has spoken at several conferences on Node.js and JavaScript and is an O'Reilly published author.