Example Without Clustering
Example : Write the following code in App.js file
Javascript
// App.js const http = require( 'http' ); const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Type' : 'text/plain' }); res.end( 'Hello Geeks\n' ); }); const PORT = 3000; server.listen(PORT, () => { console.log(`Server Established at -> ${PORT}`); }); |
Output:
How to Enhance Node JS Performance through Clustering?
In this article, we are going to learn about clustering through Node.js. Clustering is a process through which we can use multiple cores of a computer simultaneously. Like JavaScript, which is a single-threaded language, the code of JavaScript will run only on a single core if you have more than one core installed on your machine. So clustering is the process through which we can enhance the performance of our software using multiple cores of the machine at the same time.
Table of Content
- Understand Clustering
- Benefits of Clustering
- Example Without Clustering
- Example with Clustering
- Comparing Performance of with & without Clustering
- Clustering
Contact Us