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

  Рет қаралды 69,204

Studying With Alex

Studying With Alex

Күн бұрын

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

Пікірлер: 163
@amstud
@amstud 3 жыл бұрын
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!
@faraitanekha2642
@faraitanekha2642 2 жыл бұрын
No need for me to leave a comment, then. You've said it perfectly my friend 👍😁
@lauraablitt6379
@lauraablitt6379 Жыл бұрын
10000%. Honestly great video - thank you
@sepg6266
@sepg6266 2 жыл бұрын
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
@fourteensierra
@fourteensierra 3 жыл бұрын
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!!!
@StudyingWithAlex
@StudyingWithAlex 3 жыл бұрын
I will :)
@julianhu
@julianhu 5 күн бұрын
This is absolutely the best explanation video about async I've ever seen. Amazing work!
@sid6576
@sid6576 11 ай бұрын
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!
@wafikiri_
@wafikiri_ 8 ай бұрын
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.
@LyadhKhorEngineer
@LyadhKhorEngineer 3 жыл бұрын
Great video. Cleared up a lot of confusion regarding how javascript works as a single threaded server. 👍🏼
@StudyingWithAlex
@StudyingWithAlex 3 жыл бұрын
Glad you liked it!
@nathanielkswas
@nathanielkswas 3 жыл бұрын
This was super well presented and produced. Keep up the good work!!
@iganic7574
@iganic7574 2 ай бұрын
Great explanation , finally I understood what is non blocking I/O . 🙌
@jordanbtucker
@jordanbtucker 3 жыл бұрын
Loved the analogies and animations!
@souravsharma6092
@souravsharma6092 6 ай бұрын
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.
@RebienKani
@RebienKani 2 жыл бұрын
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!!!
@dark_lord98
@dark_lord98 Жыл бұрын
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.
@vertikasrivastava1186
@vertikasrivastava1186 3 жыл бұрын
This was super helpful, thank you!
@ninthsun
@ninthsun Жыл бұрын
Seriously, this video should be the must for every beginner learning nodejs. Super important concept, but in super easy words and animations.
@wichaisawangpongkasame9237
@wichaisawangpongkasame9237 3 жыл бұрын
You're great at explaining things. It's much clearer to me now. Thanks.
@alaaroumeeh2752
@alaaroumeeh2752 Жыл бұрын
Thank you very much no one explains this topic well, or they don't explain it at all!
@asepulven2768
@asepulven2768 9 күн бұрын
Excellent Video! best explanation so far with visual representation.
@brandonhunter2074
@brandonhunter2074 6 ай бұрын
This is one of the best explanations of this concept I've ever seen. Well done!
@teamjupeter9451
@teamjupeter9451 2 жыл бұрын
What a wonderful lecture on blocking!!
@avgsteve
@avgsteve 3 жыл бұрын
This is how the knowledge should be taught. Thanks for sharing
@brettwines6812
@brettwines6812 3 жыл бұрын
wow, each of these is better than the last. Your hard work really shows!!!
@Y3arin
@Y3arin 2 жыл бұрын
Great work. This is easily the best, clearest explanation of the subject I've seen in a video.
@MyAminedz
@MyAminedz Жыл бұрын
Absolutely mind-blowing video, hats off to you sir
@Priyanka-hs5jk
@Priyanka-hs5jk Жыл бұрын
This is the most crisp and clear explanation for non blocking I/O in layman terms, thanks a lot
@siddharthyadav5066
@siddharthyadav5066 2 жыл бұрын
This very well explained the concept with animations and examples. Thanks for the great work
@Frozd
@Frozd Жыл бұрын
Great video! The explanation was on-point and easy to understand, and the animations made it easy to follow.
@samartajshaikh2601
@samartajshaikh2601 Жыл бұрын
Great explanation. Simple and precise. Exactly what I needed. Thanks.
@cvramankishore4u
@cvramankishore4u Жыл бұрын
Great explanation saw couple of your videos and both are awesome keep up the good work
@nicholasaine7756
@nicholasaine7756 2 жыл бұрын
Best explanation I have come accross, on this topic.
@congdao7484
@congdao7484 3 жыл бұрын
Good work, hope you have more similar video.
@morphos2
@morphos2 Жыл бұрын
Bravo!!! Excellent explanation!! 👏👏👏
@whitebeardpirates7551
@whitebeardpirates7551 Жыл бұрын
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 ♥
@vyasrajjoshi6059
@vyasrajjoshi6059 2 жыл бұрын
Very well presented. Waiting for more of such content 😊
@yashkumar-jv2cf
@yashkumar-jv2cf 2 жыл бұрын
I was struggling with this concept for months. you cleared my doubt. thanks man
@karthiks-he4wh
@karthiks-he4wh Жыл бұрын
Beautifully explained 👌
@island_rhythms
@island_rhythms 7 ай бұрын
This is a treasure! Such a great and simple explanation! Thank you
@ashishchiluka8912
@ashishchiluka8912 Жыл бұрын
Great explaination , one of the best videos
@minhtaile3572
@minhtaile3572 3 жыл бұрын
Thanks for making this video, it's easy to understand
@jokercry8132
@jokercry8132 2 жыл бұрын
Wow! Explanation is so good with the graph.
@flucksy119
@flucksy119 3 жыл бұрын
i think this is the best computer science video ive ever watched with regards to visually understanding due to the graphics
@dhruvpurwar6642
@dhruvpurwar6642 2 жыл бұрын
One of the best videos for the concept!!!
@teerapatprommarak2070
@teerapatprommarak2070 3 жыл бұрын
Fantastic video! Thank you Alex
@ckim0324
@ckim0324 2 жыл бұрын
Fantastic video, Alex. Your channel is VERY underrated.
@muhammadsalikin3886
@muhammadsalikin3886 2 жыл бұрын
Thank you so much for this video. Best explanation ever !
@ainharansubramaniam2910
@ainharansubramaniam2910 3 жыл бұрын
Great video I hope you keep them coming
@lgodlike2324
@lgodlike2324 Жыл бұрын
You just explain it so well ! This is exactly the video I need.
@utkarshtripathi2349
@utkarshtripathi2349 2 жыл бұрын
Best explanation, Thanks for the video
@lychenus
@lychenus 2 жыл бұрын
very decently explained. now i understand when to pick a (non-)blocking io framework
@Finn-jp6pn
@Finn-jp6pn 3 жыл бұрын
Found this on Reddit. This was really helpful. Thanks 👍
@mandaputtra
@mandaputtra Жыл бұрын
Thanks, all of your video are easily digested! Maybe you can decrease the background music volume to 10% or 20%.
@user-gc4xs1qy1o
@user-gc4xs1qy1o Жыл бұрын
nice explanation! Thank you! Alex!
@janetspellman3945
@janetspellman3945 Жыл бұрын
Thanks so much, this was super helpful!
@yooog
@yooog 3 жыл бұрын
Excellent explanation!
@aramaiskhachatryan553
@aramaiskhachatryan553 3 жыл бұрын
Great one! Keep it up Alex.
@fahad_hassan_92
@fahad_hassan_92 9 ай бұрын
Great video Alex thanks!
@ShaikSameer549
@ShaikSameer549 2 жыл бұрын
Thanks for making it simple and more understandable
@Karpefilm
@Karpefilm Жыл бұрын
By far the best explanation! Keep up the fine work
@cuongtrinhminh
@cuongtrinhminh 2 жыл бұрын
Great video because it explains a hard thing simple
@Juan_lauretta
@Juan_lauretta 2 жыл бұрын
Wow this video was amazing, thank you so much
@theace9562
@theace9562 3 жыл бұрын
Super helpful. Thanks
@salvadorgonzales1566
@salvadorgonzales1566 3 жыл бұрын
Wow you did very good on this video! well explained! hope you make many more on all topics lol
@jmro7
@jmro7 2 жыл бұрын
top notch content. i can already envision this being a big education channel. Keep it up !
@mars_bold
@mars_bold Жыл бұрын
BROTHER, YOU ARE THE BEST!!! You oooh really helped me!! THANK YOU VERY MUCH!This is cool, well done!
@flavioneto1081
@flavioneto1081 2 жыл бұрын
Great video and animations, very explicative, thank you
@arjunbhat6502
@arjunbhat6502 3 жыл бұрын
Keep on doing such kind of videos. That really helped.
@raimundoladrondeguevara8597
@raimundoladrondeguevara8597 Жыл бұрын
Thank you so much for this video.
@dmitry027
@dmitry027 Жыл бұрын
Great explanation!
@icns01
@icns01 2 жыл бұрын
It was super helpful. Thanks much for clarifying.
@tayyibulhassan6227
@tayyibulhassan6227 5 ай бұрын
I HAVE NEVER SEEN A BETTER TUTORIAL THAN THIS ONE DUUUUUDDDEEEE, YOU ARE AMAZING!!!
@carolinafransiscalopezpaca541
@carolinafransiscalopezpaca541 Жыл бұрын
you make great content, don't stop until the top
@saurabh95mishra
@saurabh95mishra Жыл бұрын
amazing explanation, I learned redis uses similar model as nodejs, would love your video on that!
@imaazk
@imaazk 6 ай бұрын
I usually don't comment. but you really make things very simple to understand. Thank you!
@idanqwe1
@idanqwe1 3 жыл бұрын
Great explanation! Thank you.
@ytrkptl
@ytrkptl 3 жыл бұрын
Great explanation.
@michaelciyke
@michaelciyke 2 жыл бұрын
awesome explanation!
@Belkiii88
@Belkiii88 2 жыл бұрын
Really great video!
@zlw8844
@zlw8844 2 жыл бұрын
Very top notch quality!
@vunu.
@vunu. 3 жыл бұрын
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!
@DharanAditya
@DharanAditya Жыл бұрын
Thanks for the video ❤
@arnabgoswami8971
@arnabgoswami8971 3 жыл бұрын
Thanks you so much for the wonderful explanation It really helped me clearing the concept
@oladipupooladele3647
@oladipupooladele3647 Жыл бұрын
Great video!!!!! i loved it so much
@afshinshoja2026
@afshinshoja2026 2 жыл бұрын
Great video, Thanks
@henriquesenadev2194
@henriquesenadev2194 10 ай бұрын
Incredible video!
@howards5205
@howards5205 Жыл бұрын
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?
@waniarifrasool
@waniarifrasool Жыл бұрын
This is wonderful!
@prabhat9274
@prabhat9274 3 ай бұрын
great explanation...
@saurabh0241
@saurabh0241 7 ай бұрын
thank you soo much for this video brother . love from INDIA
@mohamedchebbi1154
@mohamedchebbi1154 2 жыл бұрын
That's huge, great job, u saved my life.
@vishnuprabuselvaraj9795
@vishnuprabuselvaraj9795 Жыл бұрын
Nice explaination
@t2a392
@t2a392 Жыл бұрын
Amazing video !
@neilclay5835
@neilclay5835 Жыл бұрын
Well explained.
@randomguy59420
@randomguy59420 3 жыл бұрын
awesome, well done!
@user-nh2xc6rd5c
@user-nh2xc6rd5c 2 жыл бұрын
awesome video bro!
@ayushmanvashishtha8180
@ayushmanvashishtha8180 2 жыл бұрын
Great video man
@kuze83
@kuze83 2 жыл бұрын
Great job, thanks !
@georgemarwanqana3478
@georgemarwanqana3478 Жыл бұрын
BEST EXPLANATION OF THE YEAR
@mohamedsharkawey3847
@mohamedsharkawey3847 3 жыл бұрын
that's a nice one mate thank you!
@elliekong712
@elliekong712 2 жыл бұрын
THANK YOU SO MUCH this video helps a lot! subscribed
@dkevin1553
@dkevin1553 2 жыл бұрын
Awesome Video Bro❤️❤️
@sportscardseconomics7851
@sportscardseconomics7851 3 жыл бұрын
Well explained!
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 562 М.
Throughput vs. Latency: How To Debug A Latency Problem
9:25
Studying With Alex
Рет қаралды 15 М.
Black Magic 🪄 by Petkit Pura Max #cat #cats
00:38
Sonyakisa8 TT
Рет қаралды 17 МЛН
ДЕНЬ РОЖДЕНИЯ БАБУШКИ #shorts
00:19
Паша Осадчий
Рет қаралды 4,8 МЛН
ПЕЙ МОЛОКО КАК ФОКУСНИК
00:37
Masomka
Рет қаралды 10 МЛН
Why does node.js scale? Libuv & epoll & fcntl
16:28
Gabriel Zimmermann
Рет қаралды 8 М.
HTTP/1 to HTTP/2 to HTTP/3
4:07
ByteByteGo
Рет қаралды 639 М.
The Fetch-Execute Cycle: What's Your Computer Actually Doing?
9:04
Tom Scott
Рет қаралды 1,7 МЛН
Javascript Promises vs Async Await EXPLAINED (in 5 minutes)
5:50
Roberts Dev Talk
Рет қаралды 536 М.
7 Database Paradigms
9:53
Fireship
Рет қаралды 1,5 МЛН
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,5 МЛН
1v1 Coding Lockout Championship Finals
3:37:39
Errichto Hard Algorithms
Рет қаралды 71 М.
System Design: Why is Kafka fast?
5:02
ByteByteGo
Рет қаралды 1 МЛН
Black Magic 🪄 by Petkit Pura Max #cat #cats
00:38
Sonyakisa8 TT
Рет қаралды 17 МЛН