Node.js Use Cases
This doc is intended to capture the key uses cases for Node.js. These use cases will then be used to guide what we develop/run as part of the community benchmarking effort.
Main Use Case Categories
The following categories have been identifed:
Node.js as a component in a web stack
- Back-end API services
- Service oriented architectures (SOA)
- Microservice-based applications
- Generating/serving dynamic web page content
- SPA applications with bidirectional communication over WebSockets and/or HTTP/2
Node.js outside of the web stack
- Scripting and automation
- Agents and Data Collectors
- Developer tooling
- Desktop applications
- Systems software
- Embedded software
Here are metrics that should be considered for each use case. Some metrics are more relevant in one context than another.
- consistent low latency
- ability to support high concurrency
- fast startup/restart/shutdown
- low resource usage (memory/cpu)
- good performance with a mix of compute and I/O async work
Description of the use cases
Back-end API services
Applications that provide APIs including REST and REST-like interfaces exposing data, computation or other resources which are usually public facing. The focus is largely on interface style and they are usually both implemented using HTTP and public facing. They are commonly the foundation for mobile back-ends with public network latency and bandwidth concerns.
Service oriented architectures (SOA)
Applications that primarily provide private APIs with more extreme latency concerns for private networks. They often involving layering and overlapping of service segments and a need for management and aggregation of heterogeneous dependency service calls.
These applications consist of a number of nimble, low resource, quick startup mini-applications. They often use novel networking approaches including lightweight message protocols and UDP. Key elements are how well multiple small services can be run concurrently(low memory/cpu) and the speed/latency with which requests can be exchanged between the main applicaitons and APIs/microservices.
Generating/serving dynamic web page content
SPA applications with bidirectional communication over WebSockets and/or HTTP/2
Node.js make it easy to build SPA applications where the GUI for an application is delivered through an initial http request and then subsequent updates are managed through bidirectional messages between the client and the server using WebSockets or HTTP/2. Key elements are the speed and latency with which messages can be sent back and forth between client and server.
SPAs differ from Desktop Applications. An SPA relies heavily on network communication. A Desktop Application does not.
Scripting and automation
Node.js is often used to script small tasks. A key element for this use case is fast start/stop time. Another concern is low resource (memory/cpu) usage, as many scripts may potentially be running at the same time.
This use case is differentiated from "Developer Tooling" because of the relative size of the scripts. Small scripts spend a lot of time starting and stopping, while developing tooling spends more time doing I/O and computation.
Agents and Data Collectors
Application running on a system in order monitor and or manage the system or the applications running in it as directed by an external monitoring/management system. The ability to be updated remotely is often a key requirement.
Node.js is extensively used in all kinds of tools commonly used to build modern web pages, including but not limited to projects like TypeScript, webpack, Babel, ESLint, and the Chai Assertion Library. All these tools are built on top of Node.js and are crucial for the success of the modern web platform.
Developers also rely on Node.js-based tools for general Node.js software development. The most prominent example of such a tool is the npm cli. Accelerating tools like this would save a lot of resources in CI and micro-service deployments.
These applications differ from SPAs in that their functionality is not heavily dependent on the network. They share a similar stack with web app development for portability reasons.
Like client-side web applications, applications for this use case are concerned with responsiveness. Applications in this space likely have long running times and significant resource footprints (memory, I/O, CPU).
Node.js can be used to develop full-fledged systems software. Examples include torrenting software (e.g. webtorrent) , databases (e.g. LokiJS, NeDB, and HarperDB) , other storage systems (e.g. whatever scality is building) , and other systems software (e.g. NodeOS).
This use case is concerned with maximizing throughput and minimizing latency. Applications in this space likely have long running times and significant resource footprints (memory, I/O, CPU).
Node.js can be used to develop robotics and IoT solutions. For example, look at the Johnny-Five robotics and IoT platform.
Minimizing latency is key for this use case. Minimal memory and CPU overhead from Node.js are important properties for this use case.
- The Node.js Foundation's Application Showcase plus analysis by davisjam performed in September 2018.
- RisingStack performed a survey of 539 developers who use Node.js in production.
- Table 1 from the Micro'15 paper Microarchitectural Implications of Event-driven Server-side Web Applications, by Zhu et al.