- Mastering Node.js
- Sandro Pasquali
- 317字
- 2021-07-21 18:17:10
Preface
The Internet is no longer a collection of static websites to be passively consumed. The browser user has come to expect a much richer, interactive experience. Over the last decade or so, network applications have come to resemble desktop applications. Also, recognition of the social characteristics of information has inspired the development of new kinds of interfaces and visualizations modeling dynamic network states, where the user is viewing change over real time rather than fading snapshots trapped in the past.
Even though our expectations for software have changed, the tools available to us as software developers developers have not changed much. Computers are faster, and multicore chip architectures are common. Data storage is cheaper, as is bandwidth. Yet we continue to develop with tools designed before billion-user websites and push-button management of cloud-based clusters of virtual machines.
The development of network applications remains an overly expensive and slow process because of this. Developers use different languages, programming styles, complicating code maintenance, debugging, and more. Too regularly, scaling issues arrive too early, overwhelming the ability of what is often a small and inexperienced team. Popular modern software features, such as real-time data, multiplayer games, and collaborative editing spaces, demand systems capable of carrying thousands of simultaneous connections without bending. Yet we remain restricted to frameworks designed to assist us in building CRUD applications binding a single relational database on a single server to a single user running a multipage website in a browser on a desktop computer.
Node helps developers build more resilient network applications at scale. Built on C++ and bundled with Google's V8 engine, Node is fast, and it understands JavaScript. Node has brought together the most popular programming language in the world and the fastest JavaScript compiler around, and has given that team easy access to an operating system through C++ bindings. Node represents a change in how network software is designed and built.
What this book covers
Chapter 1, Understanding the Node Environment, gives a brief description of the particular problems Node attempts to solve, with a focus on how its single-threaded event-loop is designed, implemented, and used. We will also learn about how Google's V8 engine can be configured and managed, as well as best practices when building Node programs.
Chapter 2, Understanding Asynchronous Event-Driven Programming, digs deep into the fundamental characteristic of Node's design: event-driven, asynchronous programming. By the end of this chapter you will understand how events, callbacks, and timers are used in Node, as well as how the event loop works to enable high-speed I/O across filesystems, networks, and processes.
Chapter 3, Streaming Data Across Nodes and Clients, describes how streams of I/O data are knitted through most network software, emitted by file servers or broadcast in response to an HTTP GET request. Here we learn how Node facilitates the design, implementation, and composition of network software, using examples of HTTP servers, readable and writable file streams, and other I/O focused Node modules and patterns.
Chapter 4, Using Node to Access the Filesystem, lays out what you need to know when accessing the filesystem with Node, along with techniques for handling file uploads and other networked file operations.
Chapter 5, Managing Many Simultaneous Client Connections, shows you how Node helps in solving problems accompanying the high volume, high concurrency environments that contemporary, collaborative web applications demand. Through examples, learn how to efficiently track user state, route HTTP requests, handle sessions, and authenticate requests using the Redis database and Express web application framework.
Chapter 6, Creating Real-Time Applications, explores AJAX, Server-Sent-Events, and the WebSocket protocol, discussing their pros and cons, and how to implement each using Node. We finish the chapter by building a collaborative document editing application.
Chapter 7, Utilizing Multiple Processes, teaches how to distribute clusters of Node processes across multi-core processors, and other techniques for scaling Node applications. An investigation of the differences between programming in single and multithreaded environments leads to a discussion of how to spawn, fork, and communicate with child processes in Node, and we build an analytics tool that records, and displays, the mouse actions of multiple, simultaneous clients connected through a cluster of web sockets.
Chapter 8, Scaling Your Application, outlines some techniques for detecting when to scale, deciding how to scale, and scaling Node applications across multiple servers and cloud services, with examples including: how to use RabbitMQ as a message queue, using NGINX to proxy Node servers, and using Amazon Web Services in your application.
Chapter 9, Testing Your Application, explains how to implement unit, functional, and integration tests with Node. We will explore several testing libraries, including native Node assertion, sandboxing, and debugging modules. Examples using Grunt, Mocha, PhantomJS, and other build and testing tools accompany the discussion.
Appendix A, Organizing Your Work, gives tips on using the npm package management system. Learn how create packages, publish packages, and manage packages.
Appendix B, Introducing the Path Framework, demonstrates how to use this powerful full-stack application framework to build your next web application using only JavaScript, thanks to Node and its ability to handle thousands of simultaneously connected clients.
Appendix C, Creating Your Own C++ Add-ons, provides a brief introduction on how to build your own C++ add-ons, and how to use them from within Node.
- Getting started with Google Guava
- Python數(shù)據(jù)分析基礎(chǔ)
- C語言程序設(shè)計基礎(chǔ)與實驗指導(dǎo)
- Java游戲服務(wù)器架構(gòu)實戰(zhàn)
- 網(wǎng)頁設(shè)計與制作教程(HTML+CSS+JavaScript)(第2版)
- Java設(shè)計模式及實踐
- 正則表達(dá)式經(jīng)典實例(第2版)
- SAP BusinessObjects Dashboards 4.1 Cookbook
- Android應(yīng)用案例開發(fā)大全(第二版)
- 第一行代碼 C語言(視頻講解版)
- ASP.NET開發(fā)與應(yīng)用教程
- Python+Tableau數(shù)據(jù)可視化之美
- Maker基地嘉年華:玩轉(zhuǎn)樂動魔盒學(xué)Scratch
- Building Slack Bots
- Mastering HTML5 Forms