Node.js Event Loop Explained

Поділитися
Вставка
  • Опубліковано 10 гру 2024
  • How does the event loop in Node.js work, what are the phases of the event loop and what is the precedence? What is process.nextTick(), what are microtasks and microtasks in Node.js?
    ======⚡⚡⚡======
    Consider becoming a member of the channel by joining me ❤️
    / @softwaredeveloperdiaries
    ☕ Buy me a coffee: www.buymeacoff...
    🙌 Become my Patreon and get exclusive perks: / softdevdiaries
    💼 Follow me on LinkedIn and drop me a message if you'd like: / gadirovgs
    💻 Also, let's connect on GitHub: github.com/gusgad
    📚 Resources:
    nodejs.org/en/...
    dev.to/jeetvor...
    And don't forget to subscribe for more videos like this 😊

КОМЕНТАРІ • 17

  • @GoRannization
    @GoRannization День тому

    This is kind of tutorial I am looking for. Subscribed for more.

  • @rushingwp
    @rushingwp 3 місяці тому +2

    wow. I read the official doc and was perplexing for an hour straight. and you smashed it in 10 mins. just wow. you've earn 1 more sub.

  • @tigranbalayan6521
    @tigranbalayan6521 2 місяці тому

    The most important discovery for me is the following:
    When we think about event loop, we are trying to define one point of view and order things depending on that, but in fact, this diagram shows, that there are at least two of them.
    Let me explain what I mean:
    So from the application point of view, your loop starts from TIMERS step, it executes Timers, Pending callbacks, idle + prepare, and only after that your app is ready for POLL
    But when we think on request processing level, our event loop first step is POLL and moves forward to check and close callbacks, then loops back to timers.
    That's why we think that timers are under prioritized by the system, because our point of view in most cases stands on poll stage. And from that point of view that's correct, your set timeout will be handled later.
    Close callbacks, per my understanding needs more examples. Because how the regular http request works? We open connection, and then we close the http connection, not only socket connection. So by keeping that in mind, we can understand that our timers will execute when we already sent response and closed the connection.
    P.S. Guys, this is how I understand this, and my thoughts can be mistaken, so please improve me if I'm wrong.

  • @olehmikadze3653
    @olehmikadze3653 4 місяці тому +3

    every time I look such videos, I discover more and more, and understanding it better and better. so thanks a lot for your work!!! really best explanation maybe "on the market"

  • @ehSamurai3483
    @ehSamurai3483 13 днів тому

    setTimeout 1
    nextTick 1
    Promise 1
    Promise 2
    queueMT 1
    setTimeout 2
    setTimeout 3

  • @vinayakporwal9885
    @vinayakporwal9885 4 місяці тому

    Great explaining try to make a video on worker threads and clusters too that can help to understand use of multi core for optimization

  • @prashlovessamosa
    @prashlovessamosa 4 місяці тому

    When you dropped a video on Event Driven Architecture I asked for implementation some of its parts please do consider my request make something on implementation of EDA

  • @spartondon3591
    @spartondon3591 2 місяці тому

    Bruh your voice 😮‍💨🔥

  • @MusaAytmamatov
    @MusaAytmamatov 3 місяці тому

    So cool!

  • @NguyenNgoc-b3e
    @NguyenNgoc-b3e 4 місяці тому

    great content

  • @julio3592
    @julio3592 3 місяці тому

    Thank you!

  • @yadneshkhode3091
    @yadneshkhode3091 4 місяці тому

    Thanks❤

  • @TheAbiGeorge
    @TheAbiGeorge 4 місяці тому

    Thank you

  • @axel_huth
    @axel_huth 4 місяці тому

    Under the Huth 😁