From the course: Advanced Node.js

Unlock the full course today

Join today to access over 23,500 courses taught by industry experts.

Backpressure

Backpressure

“

- [Instructor] Sometimes the data coming from a readable stream is too fast for a writable stream to handle. Using our water bucket example, imagine pouring water into the hose. So we're pouring water from our source bucket to our destination. Now let's say we're pouring the water too fast and the hose begins to back up, what should we do, should we keep pouring the water in? Well doing that will cause an overflow and we'll loose all of our water. Instead what we actually want to do is stop pouring water in until it's drained. So here we have the hose, it's full, our source has stopped pouring water in until all that water can make it to the destination and then we'll start pouring water in from our source again. And again once our hose has been full we'll stop pouring the water in and we'll repeat this process until all of the water pipes through the hose from our source to our destination. Whenever we actually have a full hose, this is referred to as back pressure, and how much…

Contents