Non-blocking I/O and how Node uses it, in friendly terms: blocking vs async IO, CPU vs IO
Вставка
- Опубліковано 11 чер 2024
- 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
This is easily the best programming video I've ever seen. You took a subtle and tricky concept (one which I suspect most software engineers don't actually understand), and explained it simply enough that a child could understand. Not to mention excellent production values. Super excited to have found this channel, and I can't wait to see what you make next!
No need for me to leave a comment, then. You've said it perfectly my friend 👍😁
10000%. Honestly great video - thank you
Great job
One suggestion: try a background video with less volume, no lyrics (human sound), and slower beats. That music is not just supposed to make the viewer excited or attracted, just makes it a lill colorful. Thanks
Thought you did a fantastic job explaining Non-blocking I/O. I was super bummed when I saw you only had two other videos. Makes some more vids!!!
I will :)
This is absolutely the best explanation video about async I've ever seen. Amazing work!
Great video. Cleared up a lot of confusion regarding how javascript works as a single threaded server. 👍🏼
Glad you liked it!
Great explanation , finally I understood what is non blocking I/O .
🙌
Thank you very much no one explains this topic well, or they don't explain it at all!
Loved the analogies and animations!
Dude amazing video and excellent job on explaining this topic because it was true hassle for me too understand. Just a couple of tips for in the future:
1: Choose a different music with lower BPM and lower it by 20%
2: A better microfoon or remove static noise in post production
For the rest killer video!!!
Just found this video, great work man.
My 2 cents: I think the conversation about asynchronousity is incomplete without thinking about how threads and context switching are handled at the OS level. Without the concepts of yielding, interrupts and a priority queue for threads, I was confused for the longest on time on how the computer just magically knows when to switch from one task to another and when it knows that an IO task is complete. I feel like the next step after this video would be to tackle scheduling in OSes because I feel like a lot of programmers on the internet find it to be impenetrable when it's really not that hard!
I agree. I watched the video expecting a more advanced explanation. I'm currently amateurly designing the scheduler of a multi-tasking processor and wanted to learn of current solutions.
Man that's HUGE, i finally understand this heavy topic as if it was a piece of cake, you're the GOAT ♥♥ Thanks for your effort ♥
This was super well presented and produced. Keep up the good work!!
Seriously, this video should be the must for every beginner learning nodejs. Super important concept, but in super easy words and animations.
Thank you! Really glad I landed on this video, I don't remember the last time someone explained things as simply and effectively as this. Keep up the good work! Will regularly check your channel for any doubts.
You're great at explaining things. It's much clearer to me now. Thanks.
Excellent Video! best explanation so far with visual representation.
This is how the knowledge should be taught. Thanks for sharing
This is the best video I watched regarding the I/O and CPU tasks. The code example cleared many things for me. Thanks a lot man. Please keep making videos on software engineering topics.
This is one of the best explanations of this concept I've ever seen. Well done!
This was super helpful, thank you!
wow, each of these is better than the last. Your hard work really shows!!!
Great work. This is easily the best, clearest explanation of the subject I've seen in a video.
Best explanation I have come accross, on this topic.
This is the most crisp and clear explanation for non blocking I/O in layman terms, thanks a lot
This very well explained the concept with animations and examples. Thanks for the great work
Absolutely mind-blowing video, hats off to you sir
i think this is the best computer science video ive ever watched with regards to visually understanding due to the graphics
Great explanation. Simple and precise. Exactly what I needed. Thanks.
Great video! The explanation was on-point and easy to understand, and the animations made it easy to follow.
I was struggling with this concept for months. you cleared my doubt. thanks man
One of the best videos for the concept!!!
Great explanation saw couple of your videos and both are awesome keep up the good work
You just explain it so well !
This is exactly the video I need.
Fantastic video, Alex. Your channel is VERY underrated.
By far the best explanation! Keep up the fine work
I HAVE NEVER SEEN A BETTER TUTORIAL THAN THIS ONE DUUUUUDDDEEEE, YOU ARE AMAZING!!!
Very well presented. Waiting for more of such content 😊
What a wonderful lecture on blocking!!
top notch content. i can already envision this being a big education channel. Keep it up !
you make great content, don't stop until the top
Great explaination , one of the best videos
Thank you so much for this video. Best explanation ever !
This is a treasure! Such a great and simple explanation! Thank you
I usually don't comment. but you really make things very simple to understand. Thank you!
very decently explained. now i understand when to pick a (non-)blocking io framework
Beautifully explained 👌
Keep on doing such kind of videos. That really helped.
dude, make more videos! Such high quality stuff 👏
Thanks for making this video, it's easy to understand
Good work, hope you have more similar video.
Found this on Reddit. This was really helpful. Thanks 👍
Wow! Explanation is so good with the graph.
BEST EXPLANATION OF THE YEAR
Thanks for making it simple and more understandable
I just wanted to break the like button by clicking on it many times.
What a great explaination sir
Thanks so much
Very top notch quality!
BROTHER, YOU ARE THE BEST!!! You oooh really helped me!! THANK YOU VERY MUCH!This is cool, well done!
Best explanation, Thanks for the video
Great video I hope you keep them coming
Fantastic video! Thank you Alex
Bravo!!! Excellent explanation!! 👏👏👏
Wow this video was amazing, thank you so much
Wow you did very good on this video! well explained! hope you make many more on all topics lol
Great video because it explains a hard thing simple
Great one! Keep it up Alex.
Thanks so much, this was super helpful!
Great video and animations, very explicative, thank you
Your voice is perfect for these videos! You've come so far in the last decade, awesome stuff! Works like clockwork...wink wink nudge nudge. Anyway, I enjoyed this. I'm subscribing and hitting the bell!
It was super helpful. Thanks much for clarifying.
Thanks you so much for the wonderful explanation It really helped me clearing the concept
Great video Alex thanks!
Excellent explanation!
amazing explanation, I learned redis uses similar model as nodejs, would love your video on that!
Thanks, all of your video are easily digested! Maybe you can decrease the background music volume to 10% or 20%.
nice explanation! Thank you! Alex!
Really great video!
thank you soo much for this video brother . love from INDIA
That's huge, great job, u saved my life.
Great explanation!
Incredible video!
Super helpful. Thanks
Great video!!!!! i loved it so much
Great explanation! Thank you.
This is the best explanation I've seen on non-blocking I/O. Thank you SOOOO much for this video! It clarified so many questions I had.
@4:20 of your video, you listed three examples of I/O (inactive time):
- reading from filesystem
- making network requests
- waiting for time to pass
Would executing a long-running database query qualify as a I/O or CPU? The database would be doing all the heavy compute. Would NodeJS be able to move onto other active tasks while the database query is running? Or will a thread be tied to the database query?
This is wonderful!
Thank you so much for this video.
awesome explanation!
Great video man
Great explanation.
Amazing video !
Thanks for the video ❤
awesome video bro!
Awesome Video Bro❤️❤️
Great video, Thanks
great explanation...
Well explained.
awesome, well done!
Nice explaination
too good, I am subscribing
that's a nice one mate thank you!