Resource optimization in Node.js

<p><strong>In this article, we explore the possibilities of maximizing Node.js&rsquo;s capabilities and understand the benefits of resource sharing, disproving the assumption that every request must be isolated. Join us as we uncover the full potential of Node.js and discover how resource optimization can enhance the performance and efficiency of your applications.</strong></p> <p>We all know Node.js is fast, single-threaded and non-blocking, but are we taking the most out of it? In the majority of cases the answer is simply, &ldquo;No.&rdquo;</p> <p>Because its single-threaded, we tend to forget that we still have several lines of execution that resemble&hellip; threads! So we can improve the way our code executes,&nbsp;<strong>making the resource obtained by a thread available to others</strong>, thus reducing the load on these precious resources.</p> <p>&nbsp;</p> <p><em>Threaded vs non-threaded processes</em></p> <p>Let&rsquo;s imagine we have an endpoint that calls an&nbsp;<a href="https://www.pipedrive.com/en/features/crm-api" rel="noopener ugc nofollow" target="_blank">API</a>, and that endpoint is called concurrently by many customers. So, when a request arrives needing data and calls that API, then a second request arrives also calling the exact same API the first request is already waiting for, why not share it?</p> <p>Developers often make the incorrect assumption that when working on Node.js servers, each request must be completely isolated from other requests and every single one needs to do its calls and database requests while isolated from the rest.</p> <p><a href="https://medium.com/pipedrive-engineering/resource-optimization-in-node-js-c90c731f9df4">Website</a></p>