๐ง๐ต๐ฒ ๐๐ฒ๐๐ง๐ถ๐บ๐ฒ๐ผ๐๐ ๐ฅ๐ฎ๐ฏ๐ฏ๐ถ๐ ๐๐ผ๐น๐ฒ
JS is single-threaded. It handles many tasks at once. You do this with a scheduler.
A JS scheduler uses the event loop. It pushes work to the back of the line. Your main thread stays free.
Node.js has its own scheduler. It uses libuv. Libuv manages files and networks.
Libuv talks to the OS. Linux uses epoll. Mac uses kqueue. These tools handle IO without blocking.
The OS is the final scheduler. It manages your CPU and disk.
Performance is not only about parallelism. Bad abstractions make you want more threads. A single thread often wins.
- Look at your data access.
- Use the right APIs.
- Understand your layers.
Source: https://dev.to/jeffrey_riggle_e261fba011/the-settimeout-rabbit-hole-5ff4