{"id":88116,"date":"2023-08-09T19:13:59","date_gmt":"2023-08-09T13:43:59","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=88116"},"modified":"2023-08-09T19:13:59","modified_gmt":"2023-08-09T13:43:59","slug":"scaling-application-nodejs","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/","title":{"rendered":"Scaling Application in Node.js"},"content":{"rendered":"<p>Although Node.js operates in a single-thread mode, it handles concurrency using an event-driven architecture. Additionally, it makes it easier to create child processes so that multi-core CPU-based systems can benefit from parallel processing.<\/p>\n<p>Child processes always have three stdin, stdout, and stderr streams, which can be shared with the parent process&#8217;s stdio streams.<\/p>\n<p><strong>The Node.js child process module provides three major ways to create a child process:<\/strong><\/p>\n<p><strong>1. \u2018spawn\u2019():<\/strong> Launches a new process and provides streams for communication.<\/p>\n<p><strong>2. \u2018exec\u2019():<\/strong> Executes a command in a shell, buffers the output, and provides it in a callback.<\/p>\n<p><strong>3. \u2018fork\u2019():<\/strong> Creates a child process that communicates with the parent process through IPC (inter-process communication) using message events and send function.<\/p>\n<h3>The exec() method:<\/h3>\n<p>The \u2018exec()\u2019 method in the \u2018child_process\u2019 module of Node.js has several parameters that allow you to customize the behavior of the executed command. Here are the parameters used in the \u2018exec()\u2019 method:<\/p>\n<p><strong>1. \u2018command\u2019 (string):<\/strong> The command to be executed in a shell.<\/p>\n<p><strong>2. \u2018options\u2019 (object, optional):<\/strong> An object that allows you to specify additional options for executing the command.<\/p>\n<ul>\n<li><strong>\u2018cwd\u2019 (string, optional):<\/strong> The current working directory for the command.<\/li>\n<li><strong>\u2018Env\u2019 (object, optional):<\/strong> Key-value pairs representing the environment variables.<\/li>\n<li><strong>\u2018encoding\u2019 (string, optional):<\/strong> The character encoding to use for the command&#8217;s output. Defaults to &#8216;utf8&#8217;.<\/li>\n<li><strong>\u2018shell\u2019 (string, optional):<\/strong> The shell to be used for executing the command. Defaults to &#8216;\/bin\/sh&#8217;.<\/li>\n<li><strong>\u2018timeout\u2019 (number, optional):<\/strong> The maximum amount of time in milliseconds the process is allowed to run.<\/li>\n<li><strong>\u2018maxBuffer\u2019 (number, optional):<\/strong> The largest amount of data in bytes allowed on stdout or stderr. If exceeded, an error is thrown.<\/li>\n<li><strong>\u2018killSignal\u2019 (string or integer, optional):<\/strong> The signal used to kill the process when the \u2018timeout\u2019 option is specified.<\/li>\n<li><strong>\u2018uid\u2019 (number, optional):<\/strong> Sets the user identity of the process.<\/li>\n<li><strong>\u2018gid\u2019 (number, optional):<\/strong> Sets the group identity of the process.<\/li>\n<li><strong>\u2018windowsHide\u2019 (boolean, optional):<\/strong> Hides the subprocess console window on Windows.<\/li>\n<\/ul>\n<p><strong>3. \u2018callback\u2019 (function):<\/strong> A callback function that is invoked when the command execution is complete. It receives three arguments: \u2018error\u2019, \u2018stdout\u2019, and \u2018stderr\u2019.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const { exec } = require('child_process');\n \nexec('ls -l', (error, stdout, stderr) =&gt; {\n  if (error) {\n    console.error(`Error: ${error.message}`);\n    return;\n  }\n  \n  if (stderr) {\n    console.error(`Error: ${stderr}`);\n    return;\n  }\n \n  console.log(`Output: ${stdout}`);\n});\n<\/pre>\n<p>The \u2018exec()\u2019 method executes the \u2018ls -l\u2019 command, and the callback function handles the results, including any errors, stdout, and stderr.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>total 20<br \/>\ndrwxr-xr-x 2 user staff 64 May 20 10:15 directory1<br \/>\n-rw-r&#8211;r&#8211; 1 user staff 116 May 20 10:15 file1.txt<br \/>\n-rw-r&#8211;r&#8211; 1 user staff 120 May 20 10:15 file2.txt<\/p>\n<p><strong>Another Example:-<\/strong><\/p>\n<p>Support.js<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">console.log(\"Child Process \" + process.argv[2] + \" executed.\" );\n<\/pre>\n<p>Master.js<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const fs = require('fs');\nconst child_process = require('child_process');\n\nfor(var i=0; i&lt;3; i++) {\n   var workerProcess = child_process.exec('node support.js '+i,function \n      (error, stdout, stderr) {\n      \n      if (error) {\n         console.log(error.stack);\n         console.log('Error code: '+error.code);\n         console.log('Signal received: '+error.signal);\n      }\n      console.log('stdout: ' + stdout);\n      console.log('stderr: ' + stderr);\n   });\n\n   workerProcess.on('exit', function (code) {\n      console.log('Child process exited with exit code '+code);\n   });\n}\n\n<\/pre>\n<p><strong>execute the master code and the output will be [node master.js]:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Child process exited with exit code 0\nstdout: Child Process 1 executed.\n\nstderr:\nChild process exited with exit code 0\nstdout: Child Process 0 executed.\n\nstderr:\nChild process exited with exit code 0\nstdout: Child Process 2 executed.\n<\/pre>\n<h3>The spawn() Method:<\/h3>\n<p>The \u2018spawn()\u2019 method in the \u2018child_process\u2019 module of Node.js provides several parameters to customize the behavior of the spawned child process. Here are the parameters used in the \u2018spawn()\u2019 method:<\/p>\n<p><strong>1. \u2018command\u2019 (string):<\/strong> The command to be executed. It should be the name or path of the executable.<\/p>\n<p><strong>2. \u2018args\u2019 (array, optional):<\/strong> An array of command-line arguments to be passed to the command.<\/p>\n<p><strong>3. \u2018options\u2019 (object, optional):<\/strong> An object that allows you to specify additional options for spawning the child process.<\/p>\n<ul>\n<li><strong>\u2018cwd\u2019 (string, optional):<\/strong> The current working directory for the child process.<\/li>\n<li><strong>\u2018env\u2019 (object, optional):<\/strong> Key-value pairs representing the environment variables for the child process.<\/li>\n<li><strong>\u2018stdio\u2019 (string, array, or object, optional):<\/strong> The standard input\/output\/error configuration for the child process.<\/li>\n<li><strong>\u2018detached\u2019 (boolean, optional):<\/strong> Specifies if the child process should be detached from the parent.<\/li>\n<li><strong>\u2018uid\u2019 (number, optional):<\/strong> Sets the user identity of the child process.<\/li>\n<li><strong>\u2018gid\u2019 (number, optional):<\/strong> Sets the group identity of the child process.<\/li>\n<li><strong>\u2018shell\u2019 (boolean or string, optional):<\/strong> Specifies whether to execute the command through the system shell.<\/li>\n<li><strong>\u2018windowsVerbatimArguments\u2019 (boolean, optional):<\/strong> Specifies whether to quote the arguments on Windows systems.<\/li>\n<li><strong>\u2018windowsHide\u2019 (boolean, optional):<\/strong> Hides the subprocess console window on Windows.<\/li>\n<li><strong>\u2018timeout\u2019 (number, optional):<\/strong> The maximum amount of time in milliseconds the process is allowed to run.<\/li>\n<li><strong>\u2018killSignal\u2019 (string or integer, optional):<\/strong> The signal used to kill the process when the \u2018timeout\u2019 option is specified.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const { spawn } = require('child_process');\n \nconst child = spawn('ls', ['-l']);\n \nchild.stdout.on('data', (data) =&gt; {\n  console.log(`Output: ${data}`);\n});\n \nchild.stderr.on('data', (data) =&gt; {\n  console.error(`Error: ${data}`);\n});\n \nchild.on('close', (code) =&gt; {\n  console.log(`Child process exited with code ${code}`);\n});\n<\/pre>\n<p>The \u2018spawn()\u2019 method spawns a child process with the command &#8216;ls&#8217; and the argument [&#8216;-l&#8217;]. The child process&#8217;s output is captured through \u2018stdout\u2019 and \u2018stderr\u2019 events, and the \u2018close\u2019 event is triggered when the child process exits.<\/p>\n<p><strong>Another Example:-<\/strong><\/p>\n<p>Support.js<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">console.log(\"Child Process \" + process.argv[2] + \" executed.\" );\n<\/pre>\n<p>Master.js<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const fs = require('fs');\nconst child_process = require('child_process');\n \nfor(var i = 0; i&lt;3; i++) {\n   var workerProcess = child_process.spawn('node', ['support.js', i]);\n\n   workerProcess.stdout.on('data', function (data) {\n      console.log('stdout: ' + data);\n   });\n\n   workerProcess.stderr.on('data', function (data) {\n      console.log('stderr: ' + data);\n   });\n\n   workerProcess.on('close', function (code) {\n      console.log('child process exited with code ' + code);\n   });\n}\n<\/pre>\n<p><strong>execute the master code and the output will be [node master.js]:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">stdout: Child Process 0 executed.\n\nchild process exited with code 0\nstdout: Child Process 1 executed.\n\nstdout: Child Process 2 executed.\n\nchild process exited with code 0\nchild process exited with code 0\n<\/pre>\n<h3>The fork() Method:<\/h3>\n<p>The \u2018fork()\u2019 method in the \u2018child_process\u2019 module of Node.js has several parameters that allow you to configure the behavior of the forked child process. Here are the parameters used in the \u2018fork()\u2019 method:<\/p>\n<p><strong>1. \u2018modulePath\u2019 (string):<\/strong> The path to the module file that will be executed as the child process.<\/p>\n<p><strong>2. \u2018args\u2019 (array, optional):<\/strong> An array of command-line arguments to be passed to the module.<\/p>\n<p><strong>3. \u2018options\u2019 (object, optional):<\/strong> An object that allows you to specify additional options for forking the child process.<\/p>\n<ul>\n<li><strong>\u2018cwd\u2019 (string, optional):<\/strong> The current working directory for the child process.<\/li>\n<li><strong>\u2018env\u2019 (object, optional):<\/strong> Key-value pairs representing the environment variables for the child process.<\/li>\n<li><strong>\u2018execPath\u2019 (string, optional):<\/strong> The path to the Node.js executable to be used for the child process.<\/li>\n<li><strong>\u2018execArgv\u2019 (array, optional):<\/strong> An array of Node.js command-line arguments to be passed to the child process.<\/li>\n<li><strong>\u2018stdio\u2019 (string, array, or object, optional):<\/strong> The standard input\/output\/error configuration for the child process.<\/li>\n<li><strong>\u2018uid\u2019 (number, optional):<\/strong> Sets the user identity of the child process.<\/li>\n<li><strong>\u2018gid\u2019 (number, optional):<\/strong> Sets the group identity of the child process.<\/li>\n<li><strong>\u2018silent\u2019 (boolean, optional):<\/strong> If \u2018true\u2019, disables the IPC channel between the parent and child process.<\/li>\n<li><strong>\u2018serialization\u2019 (string, optional):<\/strong> Specifies the type of serialization used for sending messages between the parent and child processes.<\/li>\n<li><strong>\u2018stdioStream\u2019 (boolean, optional):<\/strong> If true, creates a separate stream for each stdio channel.<\/li>\n<li><strong>\u2018windowsVerbatimArguments\u2019 (boolean, optional):<\/strong> Specifies whether to quote the arguments on Windows systems.<\/li>\n<li><strong>\u2018windowsHide\u2019 (boolean, optional):<\/strong> Hides the subprocess console window on Windows.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const { fork } = require('child_process');\n \nconst child = fork('child.js');\n \nchild.on('message', (message) =&gt; {\n  console.log(`Received message from child process: ${message}`);\n});\n \nchild.send('Hello, child process!');\n<\/pre>\n<p>In this example, the \u2018fork()\u2019 method creates a child process that executes the \u2018child.js\u2019 module. The parent process communicates with the child process using the \u2018message\u2019 event and the \u2018send()\u2019 function.<\/p>\n<p><strong>Another Example:-<\/strong><\/p>\n<p>Support.js<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">console.log(\"Child Process \" + process.argv[2] + \" executed.\" );\n<\/pre>\n<p>Master.js<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const fs = require('fs');\nconst child_process = require('child_process');\n \nfor(var i=0; i&lt;3; i++) {\n   var worker_process = child_process.fork(\"support.js\", [i]);\t\n\n   worker_process.on('close', function (code) {\n      console.log('child process exited with code ' + code);\n   });\n}\n<\/pre>\n<p><strong>execute the master code, and the output will be [node master.js]:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Child Process 0 executed.\nChild Process 1 executed.\nChild Process 2 executed.\nchild process exited with code 0\nchild process exited with code 0\nchild process exited with code 0\n<\/pre>\n<h3>Setting Up The Project Directory [Setup]<\/h3>\n<p>We will create the directory for the project and download the dependencies for the application which we will be creating here:<\/p>\n<p>Make a directory first to start. You can give the directory any name you like, such as the cluster_demo:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mkdir cluster_demo\n<\/pre>\n<p>Enter the directory after that:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cd cluster_demo\n<\/pre>\n<p>The project must then be initialised in order to produce a package.the json file<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">npm init -y\n<\/pre>\n<p>NPM is instructed to accept all default options by the -y option.<\/p>\n<p>The command will produce output that complies with the following when it runs:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Output\nWrote to \/home\/sammy\/cluster_demo\/package.json:\n\n{\n  \"name\": \"cluster_demo\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\"\n}\n<\/pre>\n<p><strong>Take note of the following characteristics that relate to your particular project:<\/strong><\/p>\n<p><strong>name:<\/strong> The npm package&#8217;s name.<\/p>\n<p><strong>version:<\/strong> The version of your package.<\/p>\n<p><strong>main:<\/strong> the point at which your project begins.<\/p>\n<p>Next, launch your preferred editor (nano will be used in this tutorial) and open the package.json file:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">nano package.json,\n<\/pre>\n<p>Add the italicised text to your package.json file to enable support for ES modules when importing packages:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">{\n  ...\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"type\": \"module\"\n}\n<\/pre>\n<p>Save and close the file<\/p>\n<p>You will then download the following files:<\/p>\n<p>express is a Node.js framework for creating web applications.js.<\/p>\n<p>An app&#8217;s performance can be evaluated by creating traffic with the help of the loadtest tool.<\/p>\n<p>PM2 is a programme that scales apps to use multiple CPUs automatically.<\/p>\n<p>For the Express package to download, enter the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">npm install express\n<\/pre>\n<p>Run the following command to download PM2 and loadtest globally next:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">npm install -g loadtest pm2\n<\/pre>\n<p>After setting up the required dependencies, you will now create an application without using clustering.<\/p>\n<h3>Strategies of Scalability<\/h3>\n<p>There are several strategies that can be employed to effectively handle increasing workloads and user demands. Here, I&#8217;ll explain three strategies: cloning, decomposing, and splitting.<\/p>\n<p><strong>1. Cloning:-<\/strong> Cloning is the process of making exact replicas of a service or application in order to handle the increased load. Because the load is shared equally among the clones, capacity is increased, and performance is improved. Cloning can be done by creating duplicate instances of an application using containerization technologies like Docker or by replicating entire servers or virtual machines. Incoming requests can then be split among these clones by load balancers, ensuring optimum resource use.<\/p>\n<p><strong>2. Decomposing:-<\/strong> Another technique for scalability is to decompose, or break down, an application into smaller, independent components or services. Using this strategy, which is frequently used in conjunction with a microservices architecture, a monolithic application is divided into modular services that can be created, deployed, and scaled independently. Each service specialises in a particular functionality or industry, allowing teams to work on them independently. Microservices enable more effective scaling because they can each be scaled independently based on their unique demand, optimising resource allocation and enhancing overall performance.<\/p>\n<p><strong>3. Splitting:-<\/strong> Splitting is the process of distributing the workload among various systems or resources. It entails segmenting various components of an application or its data in order to spread the load and improve scalability. For instance, splitting can take the form of sharding in the context of a database, where data is horizontally divided across several database instances or servers based on particular criteria (such as user ID or geographic region). The ability of each shard to handle a portion of the total data enables parallel processing and enhances performance. In a similar vein, splitting can also entail dividing up functionality or tasks across several servers or services to prevent bottlenecks and allow for independent scaling of different components.<\/p>\n<p>Based on the unique needs and architectural design of an application, these cloning, decomposing, and splitting strategies offer various ways to achieve scalability. They enable flexible system scaling both horizontally and vertically, maximise resource efficiency, and guarantee effective management of growing workloads. The best strategy to use, or a combination of strategies, will depend on a number of variables, including the application&#8217;s nature, expected growth, performance requirements, and available resources.<\/p>\n<h3>Cluster Module<\/h3>\n<p>A cluster of child processes also referred to as worker processes, can be created and managed using the cluster module, a built-in module in Node.js. It offers a simple method to take advantage of multiple CPU cores, enhancing the performance and scalability of Node.js applications.<\/p>\n<p>The cluster module&#8217;s primary function is to make it possible to distribute incoming network connections and requests among several workers, enabling the application to support more concurrent connections. This is accomplished by setting up a group of child processes that share a server port. Each child process functions as a separate instance of the application, able to respond to requests and execute parallel programs.<\/p>\n<p><strong>Here are the key features and components of the cluster module:<\/strong><\/p>\n<p><strong>1. Master Process:<\/strong> Initiating and overseeing worker processes is the responsibility of the master process. It keeps an ear out for network connections and divides them up between the workers using different algorithms, like round-robin or the least-connection technique.<\/p>\n<p><strong>2. Worker Processes:<\/strong> The master process generates worker processes. With its own event loop and memory space, each worker runs as a distinct instance of the application. They can each manage incoming requests independently while sharing the same server port.<\/p>\n<p><strong>3. Load Balancing:<\/strong> To fairly distribute network connections across the available worker processes, the cluster module employs an internal load balancing mechanism. This aids in making the most of multi-core systems&#8217; capabilities and handling heavier concurrent loads.<\/p>\n<p><strong>4.Inter-Process Communication (IPC):<\/strong> IPC channels are used by the master and worker processes to communicate. By enabling message transfer between the master and workers, the IPC facilitates data sharing, action coordination, and operation synchronisation.<\/p>\n<p>You may extend your application horizontally and utilise all of the CPU cores available by using the cluster module to handle additional traffic and boost performance. The module offers a simple and effective approach to constructing a clustered Node.js application by abstracting away the complexities of maintaining many processes, load balancing, and inter-process communication.<\/p>\n<p><strong>Here&#8217;s a simple example demonstrating the usage of the cluster module:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const cluster = require('cluster');\nconst http = require('http');\nconst numCPUs = require('os').cpus().length;\n\nif (cluster.isMaster) {\n  console.log(`Master ${process.pid} is running`);\n\n  \/\/ Fork workers\n  for (let i = 0; i &lt; numCPUs; i++) {\n    cluster.fork();\n  }\n\n  \/\/ Handle worker events\n  cluster.on('exit', (worker, code, signal) =&gt; {\n    console.log(`Worker ${worker.process.pid} died`);\n    \/\/ Replace the dead worker\n    cluster.fork();\n  });\n} else {\n  \/\/ Worker process - create an HTTP server\n  http.createServer((req, res) =&gt; {\n    res.writeHead(200);\n    res.end('Hello, World!');\n  }).listen(8000);\n\n  console.log(`Worker ${process.pid} started`);\n}\n<\/pre>\n<p>In this case, the master process uses a cluster. fork() to establish numerous worker processes, each of which manages incoming HTTP requests individually. When a worker process terminates, the master process forks a new worker to take its place. The cluster module automatically manages the load balancing, enabling the application to effectively handle more concurrent requests.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/08\/Scaling-Application.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-88276 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/08\/Scaling-Application.webp\" alt=\"Scaling Application\" width=\"671\" height=\"437\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Although Node.js operates in a single-thread mode, it handles concurrency using an event-driven architecture. Additionally, it makes it easier to create child processes so that multi-core CPU-based systems can benefit from parallel processing. Child&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":88119,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4984],"tags":[5110,5134,5135,5136],"class_list":["post-88116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-node-js-tutorials","tag-nodejs","tag-nodejs-in-scaling-application","tag-scaling-application","tag-scaling-application-in-nodejs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Scaling Application in Node.js - TechVidvan<\/title>\n<meta name=\"description\" content=\"Scaling Application makes it easier to create child processes so that multi-core CPU-based systems can benefit from parallel processing.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scaling Application in Node.js - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Scaling Application makes it easier to create child processes so that multi-core CPU-based systems can benefit from parallel processing.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-09T13:43:59+00:00\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Scaling Application in Node.js - TechVidvan","description":"Scaling Application makes it easier to create child processes so that multi-core CPU-based systems can benefit from parallel processing.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/","og_locale":"en_US","og_type":"article","og_title":"Scaling Application in Node.js - TechVidvan","og_description":"Scaling Application makes it easier to create child processes so that multi-core CPU-based systems can benefit from parallel processing.","og_url":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2023-08-09T13:43:59+00:00","author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Scaling Application in Node.js","datePublished":"2023-08-09T13:43:59+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/"},"wordCount":2022,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/#primaryimage"},"thumbnailUrl":"","keywords":["Nodejs","NodeJS in Scaling Application","Scaling Application","Scaling Application in NodeJS"],"articleSection":["Node Js Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/","url":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/","name":"Scaling Application in Node.js - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/#primaryimage"},"thumbnailUrl":"","datePublished":"2023-08-09T13:43:59+00:00","description":"Scaling Application makes it easier to create child processes so that multi-core CPU-based systems can benefit from parallel processing.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/scaling-application-nodejs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Scaling Application in Node.js"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/88116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=88116"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/88116\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=88116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=88116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=88116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}