Asynchronous vs Multithreading and Multiprocessing Programming (The Main Difference)

2020 ж. 16 Сәу.
151 165 Рет қаралды

In this video, I explain the main difference between asynchronous execution, multithreading and multiprocessing programming. There are advantages and disadvantages of each approach.
* Synchronous 0:30
* Multithreading a process have many threads shared resources 3:20
* Async io single thread 6:00
* Multiprocessing 11:00
Threads are evil
web.stanford.edu/~ouster/cgi-...
🏭 Software Architecture Videos
• Software Architecture
💾 Database Engineering Videos
• Database Engineering
🛰 Network Engineering Videos
• Network Engineering
🏰 Load Balancing and Proxies Videos
• Proxies
🐘 Postgres Videos
• PostgresSQL
🚢Docker
• Docker
🧮 Programming Pattern Videos
• Programming Patterns
🛡 Web Security Videos
• Web Security
🦠 HTTP Videos
• HTTP
🐍 Python Videos
• Python by Example
🔆 Javascript Videos
• Javascript by Example
👾Discord Server / discord
Support me on PayPal
bit.ly/33ENps4
Become a Patreon
/ hnasr
Stay Awesome,
Hussein

Пікірлер
  • Get my Fundamentals of Networking for Effective Backends udemy course Head to network.husseinnasser.com for a discount coupon (link redirects to udemy with coupon applied)

    @hnasr@hnasr2 жыл бұрын
    • Man you should start a podcast for this stuff, just put some of it on spotify for us to listen to it in the background. You are so good at explaining these things in such a casual way that you are kinda having a conversation rather then just explaining, thats a real skill. Would love some of this on spotify to listen to while just cleaning up and stuff.

      @LordErnie@LordErnie2 жыл бұрын
  • Him: does anyone even print stuff these days The books behind him: ...

    @venkyman4985@venkyman49852 жыл бұрын
    • You got me

      @hnasr@hnasr2 жыл бұрын
    • You probably dont care at all but does anyone know of a trick to get back into an Instagram account..? I was dumb forgot the password. I would appreciate any assistance you can give me!

      @ahmedmalakai9753@ahmedmalakai97532 жыл бұрын
    • @@ahmedmalakai9753 If u still did not get back to ur account, it is as simple as clicking forget the password and that will send an email to ur gmail and then create new one for that instagram account !

      @hacker64xfn99@hacker64xfn992 жыл бұрын
    • @@hacker64xfn99 dude probably forgot his youtube account as well lol

      @emonymph6911@emonymph69112 жыл бұрын
  • This is what they always told me at work, understand the basics, understand the basic.. and here I am always ended up getting confused in basic. And back to ur channel to relearn all those things

    @aadityarane3464@aadityarane34643 жыл бұрын
  • I loved this explanation! You might consider doing a podcast when you just chill by yourself or with a guest and start off from some technical subject but treat it casually and with lots of everyday examples, just like you did in this clip. New sub from me and keep it up! :D

    @yaBoyDreamer@yaBoyDreamer3 жыл бұрын
    • dreamer ❤️ thank you for the suggestion ! Appreciate it and welcome to the channel!

      @hnasr@hnasr3 жыл бұрын
    • @@hnasr Glad to be a member of this community!

      @yaBoyDreamer@yaBoyDreamer3 жыл бұрын
    • @Hussein Nasser I would love to know your opinion about goroutines (Golang) and erlang process

      @rouabahoussama@rouabahoussama2 жыл бұрын
  • I don't think anybody can explain it in a more better way . Thank you

    @_0_o_924@_0_o_924 Жыл бұрын
  • I clicked the thumb up button after I watched the whole video, and I ended up given all video I've been watched a thumb up in this channel, thank you Hussein!

    @goregeway8287@goregeway82873 жыл бұрын
    • jiaojie wei thumbs up to you dear 👍 and much love ❤️ thanks for your comments glad you enjoyed the content

      @hnasr@hnasr3 жыл бұрын
  • I love your explanations and as someone who is trying to become a backend engineer, I think your channel is a gold mine of useful information. Keep up with awesome videos!

    @th3h0tpegla35@th3h0tpegla352 жыл бұрын
  • I just realized you've got a ps2 on the background, so many good memories of that console

    @centurion3708@centurion37083 жыл бұрын
  • Clear and concise explanation, proof that we don't need beautiful architecture drawings when concepts are clear.

    @avalon2199@avalon21992 жыл бұрын
  • Loved this video, the last half of this video could definitely make a great series on ways to use multiprocessing!

    @tljstewart@tljstewart2 жыл бұрын
  • First time I felt myself laughing at a programming tutorial/explanation. Thank you for this video!

    @ravisomvanshi1072@ravisomvanshi10722 жыл бұрын
  • Thanks to the geniuses who made coding so easier for us newbies in the 21st century. Imagine, having to code back in the 70's or 80's, with no software like VS Code that can color code your text, auto complete lines of code, spin up the compiler/interpreter with just a click of a button, handles the communication with the OS, does syntax error check, etc. All we have to do is just know how to and what to code.

    @BangMaster96@BangMaster962 жыл бұрын
    • The systems we build now are much more complex 😉

      @hellowill@hellowill2 жыл бұрын
    • @@hellowill aah yes the code monkeys making another useles webapp

      @avg_user-ty2eg@avg_user-ty2eg Жыл бұрын
  • Love all your videos, specially about soft skills and motivation one. There are times when I get lost and watching these videos again put me on track and keep going.

    @simplefinance5165@simplefinance51652 жыл бұрын
  • This is great man, I like your style of teaching! I kind of revise this topic once in a while and I'm going to bookmark this video so I revisit it later on.

    @hassanhammoud754@hassanhammoud7542 жыл бұрын
  • Hussein the way you express yourself echoing in my mind. I like your passion and professional attitude which are seen rarely together man. True engineer

    @mustafayldrm285@mustafayldrm2852 жыл бұрын
    • Thank you Mustafa for the kind words dear ❤️

      @hnasr@hnasr2 жыл бұрын
  • You're a really good teacher. I admire your talent sir!

    @anthonypark9158@anthonypark91582 жыл бұрын
  • The most amazing, funny, useful. programming information video without coding I have ever seen until now. Amazing brother.

    @hasanweb@hasanweb7 ай бұрын
  • Great video, as usual. To summarize: if your app is "i/o bound" (e.g. reading data from a db, and sending it back) then use the asynchronous model (like NodeJS). If you are doing something "cpu bound" (e.g. video processing or cracking passwords) then use something supports subprocesses and channels (like golang).

    @icbm7@icbm72 жыл бұрын
    • What do you mean by "and sending it back"? Unlike in real life, data can be in two places at once, so there's no need to send anything back

      @thatoneuser8600@thatoneuser86002 жыл бұрын
  • Hey Hussain, Thanks for clearing all the doubts and great explanation, absolutely loved it♥️ especially the event loop 🙂

    @rohanmainali9040@rohanmainali9040 Жыл бұрын
  • Like to see u have very less subscriber, but still u r no bother about it.. u just share very unique knowledge on this channel. Which i have never find on other channel. Thank You, keep continue. sharing is caring.

    @sundaramjha1776@sundaramjha17764 жыл бұрын
  • multithreading languages tend to solve the problem by introducing reactive programming, Java did this after the community introduced some technologies like RxJava. and it is very power to combine both in the language echo system. however hard to perceive from the first glance. Great video buddy, all my wishes to you.. keep up bro

    @ahmeddaraz8494@ahmeddaraz84944 жыл бұрын
    • Ahmed Daraz thanks Ahmed for the insights! Well said

      @hnasr@hnasr4 жыл бұрын
  • This was really helpful, informative and to the point. Thanks !

    @shahbazzaidi650@shahbazzaidi6503 жыл бұрын
  • excellent approach & good humor to explain complex topics in a simpler way.

    @sjitghosh@sjitghoshАй бұрын
  • Man, I love the enthusiasm you bring to the field!

    @liquidpebbles@liquidpebbles3 жыл бұрын
  • This dude rocks. He talks in a way I can understand, and he's not boring.

    @anzwertree@anzwertree Жыл бұрын
  • Very informative and intuitive explanation! Thanks so much

    @raivatshah7781@raivatshah77813 жыл бұрын
  • This was a good watch. I think I see single-threaded async behavior differently now. I am now also very interested in process interop now. Most of all, I have a weird urge to try working with multiple asynchronous single-threads at the same time.....

    @KeplerEmeritus@KeplerEmeritus2 жыл бұрын
  • Amazing explanation. Really cleared a lot of doubts.

    @amankapoor7665@amankapoor76652 жыл бұрын
  • I just can't stop watching your videos man .... Keep them coming !

    @siddheshswnt@siddheshswnt2 жыл бұрын
    • Thanks! Enjoy 😊

      @hnasr@hnasr2 жыл бұрын
  • Thanks Hussein for this content. Keep the good work going.....

    @dharshan117@dharshan117 Жыл бұрын
  • i'm thankful to the people who suffered through callback hell

    @kez99@kez993 жыл бұрын
  • loved the explanation - simple and concise

    @tahirraza2590@tahirraza25902 жыл бұрын
  • You are such an amazing teacher!!!! I actually kind of understand this now, thanks so much!😍

    @minkymoo5773@minkymoo57732 жыл бұрын
  • جزاك الله خيرا ❤️ Thanks

    @ahmedghallab5342@ahmedghallab53427 ай бұрын
  • Well, The best explanation I see in my whole life, till today

    @jaswalankit5494@jaswalankit54943 жыл бұрын
  • Amazing video, finally i learned this topic.

    @sajad2126@sajad2126 Жыл бұрын
  • This explanation was something else..... Thanks man!!!!!

    @naimulmushfiq1390@naimulmushfiq1390 Жыл бұрын
  • Thank you very much Hussein, that was a clear explanation.

    @maedehshahabi4744@maedehshahabi4744 Жыл бұрын
  • This is hilarious! Please make a podcast - i'd love to wake up to you talking about any programming related topic haha XD

    @leoniemargetich3062@leoniemargetich30623 жыл бұрын
    • ❤️ anchor.fm/hnasr

      @hnasr@hnasr3 жыл бұрын
  • I love your explanations! Excellent food for thoughts.

    @QVL75@QVL75Ай бұрын
  • Keep up the great work, man!

    @IvanStipic_Stiiv@IvanStipic_Stiiv3 жыл бұрын
  • I guess proxies interest you more than anything (They come up at least once in every video of yours) !!!..Btw, I am a fan, and Thank you for the great content

    @swathidesai@swathidesai3 жыл бұрын
  • I agree, multithreading is hard to code but it's worth doing especially if you combine it with asynchronous execution you will have the most responsive, memory-efficient application I'll go with multiprocessing only when execute a rarely use case with heavy logic

    @Abdullah-zc1uy@Abdullah-zc1uy3 жыл бұрын
  • Very nice explanation! Thank you for this video!

    @joepreludian@joepreludian5 ай бұрын
  • Good Explanation!Finally understand these concept quick and good.

    @user-jf3gr2ht3s@user-jf3gr2ht3s2 жыл бұрын
  • Excellant explanation, very engaging and concise!

    @jrdtechnologies@jrdtechnologies Жыл бұрын
  • Fantastic explanation. I sense some nginx prior tinkering which got you into this stuff. If you take a deep dive on the read modes async io, direct-io your audience will get much more value. Bravo and keep them coming.

    @oah8465@oah84653 жыл бұрын
  • this is the first time I smiled the whole way through a technical video :)

    @joshuahampl@joshuahampl6 ай бұрын
  • Great intuitive explanation !

    @kevon217@kevon2176 ай бұрын
  • Nice explanation man, You have 1 new subscriber 👍👍👍

    @christianorlandoibarragarc3904@christianorlandoibarragarc39042 жыл бұрын
  • Best explanations ever.

    @azizulhakim1534@azizulhakim15342 жыл бұрын
  • Wow, buddy, it is an amazing explanation. You are awesome!

    @pikachuverun2062@pikachuverun2062 Жыл бұрын
  • Thanks so much for this video tutorial.

    @romantsyupryk3009@romantsyupryk30093 жыл бұрын
  • As usual fantastic video Hussein but in multi-processing we have to go with IPCs and the like and we will lose the shared memory space (which exists in multi-threading) among the threads. That is one key need in problems that involve high real-time update-rate. I see what you are saying about the locks and all the headache that comes with them and you nailed it there.

    @osamaa.h.altameemi5592@osamaa.h.altameemi55923 жыл бұрын
    • Well said Thanks Osama, good points, one slight addition; you can have shared memory between different processes (postgres is an example) of course you have the same trouble of managing the shared memory

      @hnasr@hnasr3 жыл бұрын
    • @@hnasr you got it right Mr. I usually go with Redis for more or less and have all my global "shared" variables there. If you are aware of faster alternatives, I am all in. Thx again.

      @osamaa.h.altameemi5592@osamaa.h.altameemi55923 жыл бұрын
    • @@hnasr what do you think of green-threads used in Go and all the collaborative scheduling that comes with them. I am planning on taking a deep dive there once we deliver the current project.

      @osamaa.h.altameemi5592@osamaa.h.altameemi55923 жыл бұрын
    • Not familiar with Go but heard really good things how Go was built for networking and threading in mind to make it really easy

      @hnasr@hnasr3 жыл бұрын
    • @@hnasr There is one fantastic talk i recall watching I guess in 2018, it is called the "way of Go" or the "why of Go", highly recommended.

      @osamaa.h.altameemi5592@osamaa.h.altameemi55923 жыл бұрын
  • Thanks Nasser. Just getting my feet wet with programming, python, turbo_flask, and threading. I appreciate your explanation.

    @socksincrocks4421@socksincrocks44212 жыл бұрын
  • Amazing as always ❤

    @abdelrhmanahmed1378@abdelrhmanahmed13783 жыл бұрын
  • Thank you for this video!

    @AlvaroALorite@AlvaroALorite2 жыл бұрын
  • welp i just got addicted to this channel i guess

    @wafleez0r@wafleez0r3 жыл бұрын
  • Amazing explanation !!!

    @newtonsarr1234@newtonsarr12343 жыл бұрын
  • Awesome video, thanks man.

    @sfsf285@sfsf2852 жыл бұрын
  • Best teacher.

    @nishatnasir7991@nishatnasir79913 жыл бұрын
  • thank you so much for this good explanation

    @mostafaelgablawy164@mostafaelgablawy1642 жыл бұрын
  • Very very good explanation, congratulations!

    @mariometushev4563@mariometushev4563 Жыл бұрын
  • Thanks for creating amazing content..✨

    @vanshthukral5477@vanshthukral5477 Жыл бұрын
  • I think you can mix asynchronous and multiprocessing. I did something like that with fastapi using asynchronous functions and a Procfile with different microservices running on different ports

    @neuro5261@neuro52612 жыл бұрын
  • عظمة كل عام وانتم بخير يا هندسة

    @ahmedembaby8230@ahmedembaby82302 жыл бұрын
  • Great explanation 👌🏼

    @dorbenmoyal7639@dorbenmoyal76392 жыл бұрын
  • Nice explanation !!

    @mohitdahiya3102@mohitdahiya31022 жыл бұрын
  • GREAT TUTORIAL! thank you

    @jojojawjaw@jojojawjaw3 жыл бұрын
  • I love to watch your videos, they are very informative. You could start a facebook group or slack group and ask people to join it.

    @masibhai339@masibhai3393 жыл бұрын
  • Good video, I've a question about processing. let's say I've a node js code that sends some processing intensive calculation to another language for example python, will it run on another thread?

    @dayvidkelly7683@dayvidkelly76832 жыл бұрын
  • So good explaination ❤️

    @Rezthm@Rezthm2 жыл бұрын
  • Very good explanation.. Don't know why so less thumbs-up

    @bhavyaagrawal4050@bhavyaagrawal40503 жыл бұрын
  • smooth explanation .. 5 star

    @girishfury2630@girishfury26303 ай бұрын
  • Great explanation sir. I like the idea of multiprocessing !!! though never used :p

    @parasarora5869@parasarora58693 жыл бұрын
  • A technical Craig Ferguson! Loved it.

    @sauravdeb7412@sauravdeb74122 жыл бұрын
  • best explanation!

    @chafzal8929@chafzal8929 Жыл бұрын
  • One of the best explanations i have ever seen on these concepts... I have a doubt sir, sorry this seems like a silly question but how does Node.js use multicores in CPU as it is single threaded? ...does it use only one core 😅?

    @urounofficial1232@urounofficial1232 Жыл бұрын
  • Your videos are super great! But I prefer the one with graphics and drawings, because I can understand and memorize better informations

    @UpupaAfricana@UpupaAfricana4 жыл бұрын
    • Lahdili Zuhir thanks! I agree with you too. I am experimenting with different formats. And i want mix both drawing and talking head 🗣👍

      @hnasr@hnasr4 жыл бұрын
    • Yes exactly

      @livesamarth@livesamarth3 жыл бұрын
    • @@hnasr Even Khan Academy style drawings are good or even basic white board. I feel when things are explained with visuals and the key points are written down then it's easier to absorb the information

      @The8merp@The8merp3 жыл бұрын
  • Hey Hussein, great talk! and thank you for the detailed basics which actually I missed learning (I guess I was on leave on those classes :D) Is multiprocessing possible in NodeJS ? and how?

    @deeepzzz@deeepzzz2 жыл бұрын
    • cluster i guess

      @amananurag07@amananurag072 жыл бұрын
  • @Hussein Nasser I would love to know your opinion about Golang (goroutines) and Erlang ( process ), and about node I think that it is a master - workers model the master is the app thread and workers are those who do the job behind the scenes. Thank u for the video

    @rouabahoussama@rouabahoussama2 жыл бұрын
  • Super explanation!

    @davida.7586@davida.75863 жыл бұрын
    • David A.

      @hnasr@hnasr3 жыл бұрын
  • Imagine him being your mentor! Freakn amazing,

    @yashgaur9619@yashgaur96193 жыл бұрын
  • Hey Bro. I've been following your videos to understand the basic concepts of Infrastructure and your explanation is amazing, and I have a couple of questions for you if you would like it to clarify for me. In synchronous communication, you mention that when a single process starts, it has a single thread that it uses to trigger the instructions and just wait there for the data but the same thread can be used to spin up multiple threads to execute other processes and get the results but at the backend, they use the same threaded. So it's like a highway tunnel for all other shortcuts and every thread is getting different results and passing back the result in the highway to the processes. Our main thread is not blocked as multiple results are coming back and we are executing the multiple processes over a single thread. I think it's not as evil as you think it is as it is also a form of asynchronous transmission. We are not letting our thread sit idle but rather triggering multiple processes over a single channel and waiting for the callback and the thread is busy working for other processes. Isn't this the same idea behind asynchronicity? if yes, then how we do differentiate between asynchronous and a multi-threaded process as both use the same single thread? Of-course the method is different for both but at the core, isn't both are using the same principles? I would really love your feedback over this and correct me if I am wrong about it as this is how I understood your multi-threading explanation.

    @faadi4536@faadi45362 жыл бұрын
    • He sort of explains that the motivation for async in a language like JavaScript is to provide similar functionality to multi-threading without forcing the coder to be responsible for ensuring the resources that the multi-threaded process share are used correctly. This makes developing responsive UIs much easier as developers don't have to think about multiple threads, just the single thread and managing async calls. I think there are some helpful illustrations in this video kzhead.info/sun/otCSlMZoe5Z9p4U/bejne.html&pp=gAQBiAQB If you read through the comments there's a great explanation on multiple threads trying to access the same memory that is allocated to the parent process. It essentially says that a process is allocated a set amount of memory (in simple terms basically think of it as an array). If multiple threads happen to try to write data to the same index in that 'array' of memory (because the programmer was not clever enough to avoid this) you now have unpredictable/unsafe behavior for the rest of the execution of the process because one thread is expecting one value and the other is expecting a different value. There are certainly other real-world use cases for multi-threaded applications, they seem to be related to much lower-level programming (lower meaning closer to the hardware)

      @RyanFriedman36@RyanFriedman369 күн бұрын
  • i suspect that some implementations of async & await use multithreading. nice video

    @xybersurfer@xybersurfer Жыл бұрын
  • Wow amazing content and very entertainment. Thank you very much

    @nachoeigu@nachoeigu2 жыл бұрын
  • Nice video! Greeting from Costa Rica

    @miltonbaltodano7931@miltonbaltodano79312 жыл бұрын
  • amazing yar...

    @in4osports481@in4osports4813 жыл бұрын
  • Amazing stuff

    @codeaddicted5602@codeaddicted5602 Жыл бұрын
  • Sir you are amazing...

    @pprathameshmore@pprathameshmore2 жыл бұрын
  • Any recommendation for good resources about the operating systems.

    @mhmdshaaban@mhmdshaaban3 жыл бұрын
  • Hahaha the asynchronous unordered list on the 15 first seconds, nice touch 😂

    @rodrigolabrador2745@rodrigolabrador27453 жыл бұрын
  • So... going with your recommendation of multiprocessing... how do you accomplish that in C#? do you have a video on that?

    @RobertTheUser@RobertTheUser2 жыл бұрын
  • Thanks!

    @ehza@ehza9 ай бұрын
  • Use mixing of Multiprocessing and Async. It will be useful

    @upendrad6081@upendrad60817 ай бұрын
  • Now I understand clearly why we use async and await thanks :) but i am using python instead of javascript and the technology is FastAPI it is pretty fast closer to Node js :D

    @ahtisham6597@ahtisham65973 жыл бұрын
  • Great content! However, not sure if we could say event loop > multi threading. Is it possible to have the performance advantage of multi threading (parallel processing) in event loop based approach? Golang is known for its multi threading.

    @adityanagesh4922@adityanagesh49223 жыл бұрын
    • I think with Nodejs clustering you could achieve this. run an event loop on each thread of the CPU as a child node

      @RationalDissonances@RationalDissonances3 жыл бұрын
  • Salam, i think mixing both is good. I like both multi threaded + asynchronous.. i dont like big event loops or when language doesn't really support await thingy you have to invent your own or bring some library which im not fan of doing so

    @electronlabs2802@electronlabs280211 ай бұрын
  • I did it.... Syntactical sugar😂😂... I love your explanation man.... We are the new generation where we don't write multithreading or async code, we IMPORT libraries to do it for us😂✌️

    @igbana@igbana Жыл бұрын
  • so can we make any code asynchronus or mulithreading or it depends on the language or i did not understand whatever u said?

    @rohitsagar9011@rohitsagar90113 жыл бұрын
KZhead