Akashdeep Saluja
Akashdeep Saluja

Reputation: 3089

Node JS Express Thread clarification

I am relatively new to node js, and have read some of the texts of its architecture.

I understand about about the event loop, the main thread(V8 engine thread) and the rest as libuv threads. As soon as a main thread needs to do async processing it hands it over to libuv threads, and in return they add the result in event loop.

My concern is over express. So who is inserting the http requests into the event loop. Is there a separate dedicated thread for it or is it one of the libuv thread?

Upvotes: 1

Views: 1345

Answers (1)

sinbar
sinbar

Reputation: 1063

Actually,express is just use the nodejs's http API. Whatever it is express or hapi or some other nodejs's framework,they just use the nodejs's http/https api as basis. And the concept of event loop does not come from nodejs, that is originated from javascript, js use that to handle async function and so does nodejs.Then for the http request, that's same with other async function, the V8 entrust the request to nodejs's relative module and in turn be entrusted to the OS, when the response is received or a http request is received on the port and thereby to the the V8 thread, the V8 pushes a callback into queue and wait to be invoke after the sysn thread.

Upvotes: 4

Related Questions