I am re-writing a c# server, and I would like to use an event driven model. My server needs to make complex database queries that may take some time to complete. How does this fit in with the event-driven model where I would have a single event loop processing all requests? I don't want to freeze the loop as I am waiting for a DB response.
I assume since you know about the event loop, you know how it works, but just in case, I'll leave this here.
When you send a query to the database, node.js will do so either over http, or some other protocol, this connection is usually handled on a separate thread. Once the request is sent, the code continues on and the callstack gets cleared, allowing the event loop to continue. Once a response is received, a function is injected into the callback queue, which gets processed when it's next in line and the event loop runs (and the event loop only runs when the call stack is empty, see video.)
As long as everything you do is asynchronous, you won't freeze the event loop.