in nodejs what runs on the main thread and what runs on libuv thread

Viewed 11

Nodejs is single threaded but from my understanding it uses libuv for some types of asyncronous task. By default there are only 4 libuv threads.

In the below scenario I would like to konw what gets executed in main eventloop thread and what gets executed in libuv threads.

When I call an API it calls in turn calls Elastic search, RDS database, and another api. Once data is received them all these resources it combines the information in a json format as a response.

I know that for dns resolve it uses libuv.

  1. For sending out requests does it use libuv or it is done from the main eventpool thread.
  2. When nodejs creates calls another api and it takes time to respond is there any thread involved to keep the connection open while it waits for conneciton
  3. When doing the compute to combine all this data does it run on main event loop thread for on libuv thread?
0 Answers
Related