Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Thomas Hunter II

Rating No ratings yet

Many companies, from startups to Fortune 500 companies alike, use Node.js to build performant backend services. And engineers love Node.js for its approachable API and familiar syntax. Backed by the world's largest package repository, Node's enterprise foothold is only expected to grow. In this hands-on guide, author Thomas Hunter II proves 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 will find themselves integrating application code with a breadth of tooling from each layer of a modern service stack. • Learn why running redundant copies of the same Node.js service is necessary • Know which protocol to choose, depending on the situation • Fine-tune your application containers for use in production • Track down errors in a distributed setting to determine which service is at fault • Simplify app code and increase performance by offloading work to a reverse proxy • Build dashboards to monitor service health and throughput • Find out why so many different tools are required when operating in an enterprise environment

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on guide that proves Node.js can power enterprise-grade backend services, showing intermediate-to-advanced developers how to make distributed systems observable, scalable, and resilient using real tooling from every layer of the modern service stack. 【Book Arc】 - **Opening (~0%–15%)**: Frames why Node.js belongs in enterprise backends and why redundant service copies matter, then grounds readers in Node's single-threaded nature, the event loop, and libuv's thread pool before any distributed concerns appear. - **Early (~15%–35%)**: Moves into inter-service communication—choosing protocols, HTTP request/response, compression trade-offs, TLS key management, and higher-level options like GraphQL and gRPC with Protocol Buffers. - **Middle (~35%–55%)**: Tackles scaling: the cluster module versus multiple processes, load testing with Autocannon, and offloading work to a reverse proxy like HAProxy for health checks, compression, and backpressure. - **Late (~55%–80%)**: Builds the observability layer—logging with ELK, metrics via Graphite/StatsD/Grafana, health indicators, and distributed request tracing with Zipkin. - **Ending (~80%–100%)**: Consolidates container tuning and operational practice for production, tying the tooling together into an enterprise-ready workflow (excerpts do not cover the final chapters in detail). 【Key Takeaways】 - **Redundant service copies are a requirement, not a luxury** (Opening): running multiple instances is the baseline for resilience, and the book explains why before diving into tooling. - **Don't starve the event loop** (Early): CPU-heavy work blocks all callbacks; break it into batches with `setImmediate()`, never `process.nextTick()`, which can trap the app in a zombie microtask loop. - **Protocol choice is a design decision** (Early): prefer industry standards over custom protocols, and standardize on a small set of inter-service protocols to cut implementation and documentation effort. - **Offload compression and CPU-heavy work to a reverse proxy** (Middle): in-process gzip works but is inefficient; HAProxy handles compression, health checks, and backpressure better than Node itself. - **Cluster concurrency is often a distraction in distributed systems** (Middle): instance-level concurrency rarely pays off when you're already running redundant services—benchmarks show modest gains versus the complexity. - **Observability needs three distinct pillars** (Late): logs (ELK), metrics (Graphite/StatsD/Grafana), and distributed traces (Zipkin) each answer different questions about service health and faults. - **Health checks drive routing decisions** (Middle): HAProxy's L7 checks automatically remove failing instances and restore them, which is how resilience becomes operational rather than theoretical. - **Enterprise environments demand many tools** (Late): the breadth of tooling isn't accidental—each layer of the stack solves a problem the others can't. 【Reading Tips】 - Skim the Node.js internals section if you already understand the event loop and libuv; the author explicitly says you can jump to "Sample Applications." - Deep-read the scaling and reverse proxy chapters—the Autocannon benchmarks and HAProxy health-check walkthroughs are the most concrete, transferable material. - Treat the observability chapter as a reference: run the Docker-based ELK, Grafana, and Zipkin setups yourself rather than just reading them. - Pay attention to the protocol comparison (HTTP/JSON vs GraphQL vs gRPC) and pick the one that fits your actual service boundaries. - Don't skip the load-testing and SLO discussion—it's what turns "it works" into "it's production-ready." 【Coverage Limits】 The excerpts cover the book's structure, early fundamentals, protocol selection, scaling, and observability in reasonable depth, but the final production/container-tuning chapters are only partially represented. Specific code details and later chapters should be verified against the full text.
Excerpt 1
45 gRPC Producer 48 gRPC Consumer 50 3. Scaling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
View in text
Excerpt 2
w err; console.log(data); setImmediate( 2 “Userland” is a term borrowed from operating systems, meaning the space outside of the kernel where a user’s applic...
View in text
Excerpt 3
f HTTP requests and responses hasn’t really been exam‐ ined. This is because the HTTP standard doesn’t dictate quite as much what goes in the body of an HTTP...
View in text
Excerpt 4
is is because HAProxy has started performing health checks. Open up the HAProxy statistics page again4 by visiting http://localhost:3000/admin? stats. You sh...
View in text
Excerpt 5
her platforms. This consistency will prevent many headaches. If one team refers to an environment as staging and the other as preprod, querying logs for rela...
View in text
Excerpt 6
nnotations bar displays a timeline for the span you clicked. Depending on the speed of the request, you will see between two and four dots. The furthest left...
View in text
Excerpt 7
run --rm -p 8080:80 \ -v $PWD:/usr/share/nginx/html nginx Both the volume and publish flags have a verbose syntax for configuring the way the mapping between...
View in text
Excerpt 8
e; server.listen(PORT, HOST, (err, host) => { console.log(`Server running at ${host}`); Also, create another file named distnode-deploy/recipe.js. This file...
View in text
Tags
AI categories
BackendNode.jsDistributed Systems
ISBN: 1492077291
Publisher: O'Reilly Media
Publish Year: 2021
Language: English
Pages: 390
File Format: PDF
File Size: 7.9 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…