MENU

Fun & Interesting

Non-blocking I/O and how Node uses it, in friendly terms: blocking vs async IO, CPU vs IO

Studying With Alex 81,059 lượt xem 3 years ago
Video Not Working? Fix It Now

The work of fulfilling a request can be split into two pieces: CPU work, which is actively running code and performing calculations, and I/O work, which is waiting for something else to happen. Normally, threads performing I/O must wait until the I/O is complete to continue processing, which is called blocking or synchronous I/O. Non-blocking or asynchronous I/O is an optimization available in some technologies (NodeJS, Java NIO, and others) that allows threads to move on to other work while the I/O is happening in the background.

Feel free to ask questions in the comments below!

00:00 Intro
00:31 Servers & Threads
01:28 A Server Is Like A Restaurant
03:22 A Request Has CPU work (active time) and I/O work (inactive time)
04:27 Code Example
05:03 Nonblocking I/O Timing Diagram
05:29 Blocking I/O Timing Diagram
06:01 Why Isn't Nonblocking I/O More Common?
06:47 Downsides Of Nonblocking I/O
07:42 Recap

Comment