When is NodeJS Single Threaded and when is it multi-Threaded?

The Backend Engineering Show with Hussein Nasser

Episode | Podcast

Date: Wed, 24 Mar 2021 03:08:00 GMT

<p>Node JS Is single-threaded asynchronous non-blocking javascript runtime, but it's not always single-threaded there are occasions where nodejs uses multi-threading, so the questions we will try to answer in this video, when is nodejs single-threaded and when does it use multi-threading and how will that affect my app?</p> <ul> <li>Event Loop single thread, that really just loops for callbacks 0:00</li> <li>Threading in Node jS (libuv) 4:00 <ul> <li>used for</li> <li>IO/intensive <ul> <li>DNS queries</li> <li>file system reads</li> </ul> </li> <li>CPU intensive <ul> <li>crypto</li> <li>compression</li> </ul> </li> <li>process.env.UV_THREADPOOL_SIZE=1</li> </ul> </li> </ul> <p>Examples 8:00</p> <p>Cluster Nodejs 16:00</p> <p>Example 1</p> <p>HTTP server return 1</p> <p>HTTP server while 1</p> <p>HTTP server with file system read async</p> <p>HTTP server with file system read sync</p> <p>HTTP server with fetch call to server (dns)</p> <p><br /></p> <p>Support my work on PayPal</p> <p><a href="https://bit.ly/33ENps4">https://bit.ly/33ENps4</a></p> <p>Become a Member on YouTube</p> <p><a href="https://www.youtube.com/channel/UC_ML5xP23TOWKUcc-oAE_Eg/join">https://www.youtube.com/channel/UC_ML5xP23TOWKUcc-oAE_Eg/join</a></p> <p><a href="https://emojipedia.org/teacher/">🧑‍🏫</a><strong> </strong>Courses I Teach</p> <p>https://husseinnasser.com/courses</p>