Node.jsQuestion 03 of 26
How does Node handle many requests if it's single-threaded?
Answer out loud or in your head first, then compare.
Answer
Because most server work is I/O:
database
network
filesystem
APINode doesn't have to block the main thread while waiting for these operations to finish.
For example:
JavaScript
const data = await db.find();While it waits, the event loop can handle other requests.
That doesn't mean everything in Node runs on one physical thread, though. Node/libuv can use an extra thread pool.
How did it go? Be honest — “Not yet” puts the question on your review list.