JavaScript runs in a single threaded event-loop. Node.js is a runtime platform built for evented I/O where multiple execution flows are processed concurrently, but not in parallel. An example of this could be an HTTP server, tens of thousands of requests can be processed per second, but only one instruction is being executed at any given time.
The performance of our application is tied to how fast we can process an individual execution flow prior to performing the next I/O operation.
Through several recipes, this chapter demonstrates the Optimization Workflow, as shown in the following figure:
We'll be referencing this workflow throughout this chapter.
This chapter is about making our JavaScript code as fast as possible in order to increase I/O handling capacity, thus decreasing costs and improving user experience.