The Event Loop You're Already Using
The Event Loop You're Already Using select, poll, epoll, and the System Calls Behind Every Async Framework Reading time: ~13 minutes You wrote await fetch(url). Your Node.js server handled ten thou...

Source: DEV Community
The Event Loop You're Already Using select, poll, epoll, and the System Calls Behind Every Async Framework Reading time: ~13 minutes You wrote await fetch(url). Your Node.js server handled ten thousand simultaneous connections while it waited. Your CPU usage barely moved. Here's what actually happened: your code called into a JavaScript engine, which called libuv, which called epoll_wait, which asked the kernel to wake it up when any of ten thousand file descriptors had data ready. The kernel said nothing for 40 milliseconds. Then it said: "three of them are ready." Your event loop woke up and processed exactly those three. The other 9,997 connections cost you nothing while they waited. That's the whole trick. One syscall. The kernel does the waiting. You do the work. Why This Matters Beyond "Async Is Fast" You've heard that async I/O is efficient. You may have accepted that on faith, or from a benchmark someone posted. But without understanding the layer underneath, you're flying on i