I'm learning NodeJS and just wanted to clarify something. In several introductory tutorials and books so far, very early on they've described Node's "non-blocking" architecture - or rather that it's possible (and recommended, the entire point) to code in a non-blocking manner.
So for example, this example was given in a book I'm reading of an asynchronous way to get data from a database.
http.createServer(function (req, res) {
database.getInformation(function (data) {
res.writeHead(200);
res.end(data);
});
});
What happens (as I understand it) is Node makes the call to the database, then continues processing whatever may be next on the call stack. When the database request is complete, the data variable in the anonymous callback function will be populated and that function added to the call stack (and subsequently executed when Node gets to it).
My question is, what exactly is processing the database request? Surely Node has to block whilst it does that? What is taking care of the database request? Or if Node is waiting on an asynchronous HTTP GET request to an external resource, what is taking care of that request that allows Node to continue processing the call stack and be "non-blocking"?