Asynchronous Programming Performance Patterns
A key strength of JavaScript runtimes is the event loop, which couples “non-blocking input/output” within a single-threaded execution model. This means JavaScript is great for high-concurrency systems as long as they are not compute-bound systems (i.e., they’re IO-bound).
With the asynchronous and non-blocking IO, JavaScript has strong built-ins to orchestrate requests. In this chapter, we’ll cover the following topics:
- Sequential and parallel asynchronous operation patterns in JavaScript, both with Promises only and with async/await
- The cancellation and timeout of fetch requests with AbortController
- Advanced asynchronous operation patterns: throttling, debouncing, and batching
At the end of this chapter, you’ll be able to spot and remedy situations where the asynchronous operation orchestration could be improved in JavaScript.