Asynchronous Programming with Node.js
Published by O'Reilly Media, Inc.
Core Node features that enable high-volume, scalable applications
The asynchronous execution model is at the heart of Node.js’s internal architecture, enabling it to handle thousands of concurrent requests with a single CPU core and process gigabytes of data with a tiny amount of RAM. Node.js developers have to embrace asynchronous programming to build modern large-scale applications on this platform. However, the steep learning curve and related pitfalls often intimidate and trip them up, causing applications to crash because of unhandled errors or difficult-to-detect memory leaks.
Expert Chetan Karande demystifies the asynchronous programming constructs offered by JavaScript and Node.js APIs, including callbacks, Promises, async and await, async iterators, async generators, and streams. By the time you’re done, you’ll have learned the practical skills you need to be an effective Node.js developer.
What you’ll learn and how you can apply it
By the end of this live, hands-on, online course, you’ll understand:
- The pitfalls of memory leaks associated with asynchronous code
- Relatively new JavaScript language features such as the async iterator and async generator
And you’ll be able to:
- Write asynchronous programs in a maintainable and comprehensible way
- Handle runtime errors
- Use powerful Node.js streams to process large amounts of data effectively
This live event is for you because...
- You’re a web developer with proficiency in JavaScript who wants to expand your knowledge of Node.js beyond the basics.
- You already work with Node.js but need to understand the newer asynchronous APIs.
Prerequisites
- A working understanding of JavaScript
- Experience developing Node.js applications
Recommended preparation:
- A machine with the latest LTS version of Node.js, Git, and Visual Studio Code or the IDE of your choice installed
Recommended follow-up:
- Read You Don't Know JS: ES6 & Beyond (book)
- Read Node Cookbook, Third Edition (book)
Schedule
The time frames are only estimates and may vary according to how the class is progressing.
Introduction (10 minutes)
Presentation: Relationship between asynchronous programming and building scalable applications
Asynchronous programming features in JavaScript (45 minutes)
Presentation: Promises, async/await; how they address evils of the callback hell; associated common programming mistakes
Exercise: Spot coding issues related to broken promise chain and unhandled promise rejections.
Q&A
Break (5 minutes)
Node.js asynchronous event-driven execution model (40 minutes)
Presentation: Event loop execution phases and queues; order of execution among Node.js timer APIs, Promises, and process.nextTick(); pitfalls related to resource starvation
Exercise: Identify order of execution of asynchronous functions
Q&A
Mechanisms for handling I/O operations (15 minutes)
Presentation: Node.js event loop and I/O execution mechanism using native OS async features and libuv thread pool; best practices to prevent blocking event loop and worker threads
Q&A
Break (5 minutes)
Mechanisms for handling memory-intensive operations (40 minutes)
Presentation: Node.js stream types and controls that allow limiting memory usage while data is processing; using streams with async generator and async iterator
Exercise: Use stream API to optimize memory use
Mechanisms for handling-CPU intensive operations (15 minutes)
Presentation: Executing CPU heavy tasks in parallel with child_process and worker thread APIs
Q&A
Wrap-up (5 minutes)
Your Instructor
Chetan Karande
Chetan Karande is a full stack web developer, security researcher, author, and trainer. He’s the author of Securing Node Applications (O’Reilly). He’s also the project leader for the OWASP NodeGoat project, an open source platform to learn about Node.js security, and a contributor to multiple open source projects.