{"id":20432708,"url":"https://github.com/realabbas/scaling-nodejs","last_synced_at":"2026-03-01T20:31:33.550Z","repository":{"id":44332417,"uuid":"260026126","full_name":"realabbas/scaling-nodejs","owner":"realabbas","description":"📈 Scaling Node.js on each X, Y and Z axis using Node.js Native Modules, PM2, AWS , Load Balancers, AutoScaling, Nginx, AWS Cloudfront","archived":false,"fork":false,"pushed_at":"2020-12-05T08:46:20.000Z","size":89,"stargazers_count":122,"open_issues_count":0,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-05T11:42:32.946Z","etag":null,"topics":["autoscaling","aws","backend","cloudfront","javascript","load-balancer","loadtest","nginx","nodejs","nodejs-modules","pm2","scaling","server"],"latest_commit_sha":null,"homepage":"https://realabbas.github.io/scaling-nodejs/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/realabbas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-29T19:44:04.000Z","updated_at":"2025-05-16T21:16:58.000Z","dependencies_parsed_at":"2022-09-01T16:51:50.098Z","dependency_job_id":null,"html_url":"https://github.com/realabbas/scaling-nodejs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/realabbas/scaling-nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realabbas%2Fscaling-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realabbas%2Fscaling-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realabbas%2Fscaling-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realabbas%2Fscaling-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/realabbas","download_url":"https://codeload.github.com/realabbas/scaling-nodejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realabbas%2Fscaling-nodejs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29983141,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T16:35:47.903Z","status":"ssl_error","status_checked_at":"2026-03-01T16:35:44.899Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autoscaling","aws","backend","cloudfront","javascript","load-balancer","loadtest","nginx","nodejs","nodejs-modules","pm2","scaling","server"],"created_at":"2024-11-15T08:16:16.280Z","updated_at":"2026-03-01T20:31:28.538Z","avatar_url":"https://github.com/realabbas.png","language":"JavaScript","readme":"![Scaling Node.js Guide Github Ali Abbas @realabbas](https://raw.githubusercontent.com/realabbas/scaling-nodejs/master/demo/cover_image.png)\n\n![Visitors](https://visitor-badge.glitch.me/badge?page_id=realabbas.scaling-nodejs)\n\n## Scaling Types\n\n- X Axis\n- Y Axis\n- Z Axis\n\n## Node.js Native Modules\n\n- `cluster`\n- `os`\n- `spawn`\n\n\u003c!-- ### Cluster\n\n### Zero-Downtime\n\n### PM2\n\n### Spawn --\u003e\n\n## Resources and techniques\n\n_Some techniques are implemented using stack other than node.js, but the concept is more important to comprehend and implement for better performance of the application_\n\n### Blogs\n\n- [Scaling Node.js Applications](https://jscomplete.com/learn/node-beyond-basics/scaling-node-apps)\n- [A Beginner's Guide To Scaling To 11 Million+ Users On Amazon's AWS](http://highscalability.com/blog/2016/1/11/a-beginners-guide-to-scaling-to-11-million-users-on-amazons.html)\n- [Good practices for high-performance and scalable Node.js applications [Part 1/3]](https://medium.com/iquii/good-practices-for-high-performance-and-scalable-node-js-applications-part-1-3-bb06b6204197)\n- [Good practices for high-performance and scalable Node.js applications [Part 2/3]](https://medium.com/iquii/good-practices-for-high-performance-and-scalable-node-js-applications-part-2-3-2a68f875ce79)\n- [Good practices for high-performance and scalable Node.js applications [Part 3/3]](https://medium.com/iquii/good-practices-for-high-performance-and-scalable-node-js-applications-part-3-3-c1a3381e1382)\n- [Scaling Up to Your First 10 Million Users](https://medium.com/@evyborov/scaling-up-to-your-first-10-million-users-summary-aws-summit-sf-2017-819dcf532fb7)\n- [Scaling Machine Learning from 0 to millions of users — part 1](https://towardsdatascience.com/scaling-machine-learning-from-0-to-millions-of-users-part-1-a2d36a5e849?gi=c9cd8046a155)\n- [Scaling Machine Learning from 0 to millions of users — part 2](https://medium.com/faun/scaling-machine-learning-from-0-to-millions-of-users-part-2-80b0d1d7fc61)\n- [https://cloudifie.com/uncategorized/scaling-from-mvp-to-10-million-users/](https://cloudifie.com/uncategorized/scaling-from-mvp-to-10-million-users/)\n- [Scaling on AWS Part I: A Primer](https://aws.amazon.com/blogs/startups/scaling-on-aws-part-1-a-primer/)\n- [Scaling on AWS (Part 2): \u003e 10K Users](https://aws.amazon.com/blogs/startups/scaling-on-aws-part-2-10k-users/)\n- [Scaling on AWS (Part 3): \u003e500K Users](https://aws.amazon.com/blogs/startups/scaling-on-aws-part-3-500k-users/)\n- [Scaling on AWS (Part 4) : \u003e One Million Users](https://aws.amazon.com/blogs/startups/scaling-on-aws-part-4-one-million-users/)\n- [Deploying and scaling Node.js on Google Kubernetes Engine with Continuous Integration](https://levelup.gitconnected.com/dockerizing-deploying-and-scaling-node-js-on-google-kubernetes-engine-with-continuous-integration-f895a98bf6e3)\n- [Instagration Pt. 2: Scaling our infrastructure to multiple data centers](https://instagram-engineering.com/instagration-pt-2-scaling-our-infrastructure-to-multiple-data-centers-5745cbad7834)\n- [Using Rust to Scale Elixir for 11 Million Concurrent Users](https://blog.discord.com/using-rust-to-scale-elixir-for-11-million-concurrent-users-c6f19fc029d3)\n- [How to scale a Nodejs app based on number of users](https://adrianmejia.com/how-to-scale-a-nodejs-app-based-on-number-of-users/)\n- [Scaling Node.js Socket Server with Nginx and Redis](https://blog.jscrambler.com/scaling-node-js-socket-server-with-nginx-and-redis/)\n- [NODE.JS scalability problems and how to solve them 🚀](https://softwareontheroad.com/nodejs-scalability-issues/)\n- [Divide and conquer: Scale your Node.js app using distributed queues](https://blog.logrocket.com/divide-and-conquer-scale-your-node-js-app-using-distributed-queues-8231a9486d3a/)\n- [Serving Millions of Users in Real-Time with Node.js \u0026 Microservices [Case Study]](https://blog.risingstack.com/nodejs-microservices-scaling-case-study/)\n- [Scalability in NodeJS Creating a Zero-downtime cluster](https://itnext.io/creating-a-zero-downtime-cluster-in-nodejs-ad879ee3160)\n- [Monitoring \u0026 Vertically Scaling Node.js Applications](https://www.netguru.com/codestories/monitoring-vertically-scaling-nodejs-applications)\n- [Node.js scaling in highload](https://www.slideshare.net/tshemsedinov/nodejs-scaling-in-highload-145786324)\n- [How to Scale your Node.js app: Best Strategies and Built-in Tools for Scalability](https://medium.com/@OPTASY.com/how-to-scale-your-node-js-app-best-strategies-and-built-in-tools-for-scalability-a1725df082f5)\n- [Securing and Scaling up Node.js Applications](https://blockchain.dcwebmakers.com/blog/best-practices-for-securing-and-scaling-nodejs-applications.html)\n- [Scaling-out with Node Clusters](https://medium.com/the-andela-way/scaling-out-with-node-clusters-1dca4a39a2a)\n- [Handling blocking operations in Node](https://medium.com/the-andela-way/handling-blocking-operations-in-node-dbe8baa58ae7)\n- [Interrupts and Request Memoization](https://medium.com/the-andela-way/interrupts-and-request-memoization-23cfe925b0ec)\n\n### Videos\n\n- [Tech Talk: Server Scaling in Node.js](https://www.youtube.com/watch?v=w1IzRF6AkuI)\n- [The Art of Building Node.js Projects at Scale](https://www.youtube.com/watch?v=_H6td2GaW3I)\n- [Scaling Your Node.JS API Like a Boss (Part One)](https://www.youtube.com/watch?v=Ogjb60Fg10A)\n- [Scaling Your Node.JS API Like a Boss (Part Two)](https://www.youtube.com/watch?v=f5phsX4VUOU)\n- [Scaling NodeJS - Abhinav Rastogi, Flipkart](https://www.youtube.com/watch?v=OsHvD6EUAWM)\n- [Abhinav Rastogi: Scaling NodeJS beyond the ordinary JSConf Iceland 2018](https://www.youtube.com/watch?v=K8spO4hHMhg)\n- [Modular-services in a NodeJS monolith - Naval Saini, Flip Flop App](https://www.youtube.com/watch?v=XELSRLTk66o)\n- [Scaling Real-time Apps on Cloud Foundry Using Node.js and Redis](https://www.youtube.com/watch?v=a19OfVfqsa8)\n- [Node JS - Scaling Applications - Clusters](https://www.youtube.com/watch?v=Iz0MFOKmmDY\u0026t=600s)\n- [Node JS - Scaling Applications - Architecting Zero Downtime](https://www.youtube.com/watch?v=INM6TybFV9Q\u0026t=495s)\n- [Node JS - Scaling Applications - PM2](https://www.youtube.com/watch?v=iHzoQy1jx7M)\n- [Using Clean Architecture for Microservice APIs in Node.js with MongoDB and Express](https://www.youtube.com/watch?v=CnailTcJV_U)\n- [Scaling NodeJS apps with N-API by Ruben Harutyunyan(Arm) JSConfAM19](https://www.youtube.com/watch?v=o39BS_KzCg8)\n- [Enterprise Node.JS Apps in 2018](https://www.youtube.com/watch?v=RNGCrz5Rx14)\n- [Node JS - Scaling Applications](https://www.youtube.com/watch?v=RCyR5_9djik\u0026list=PLrwNNiB6YOA3xc1dfQpHuaU8HsKxkEgiQ)\n- [Scaling Node.js Applications with Kubernetes and Docker - Erick Wendel, EW.IT](https://www.youtube.com/watch?v=Jmf9jilQUsU)\n- [Node.js at Scale with Erik Toth](https://www.youtube.com/watch?v=bvDtEcQdGs0)\n- [Architect for Scale - My Learnings in Node.js (A case study)](https://www.youtube.com/watch?v=eFxSLn4VFRo)\n- [Node.js Performance and Highly Scalable Micro-Services - Chris Bailey, IBM](https://www.youtube.com/watch?v=Fbhhc4jtGW4)\n- [Scaling Node.js Applications with Kubernetes and Docker](https://www.youtube.com/watch?v=Pe-RaE163FE)\n- [require('lx') - Scaling Node.js to 500 million Users by João Parreira](https://www.youtube.com/watch?v=8PTlEkwOjKg)\n- [The Node.js Event Loop: Not So Single Threaded](https://www.youtube.com/watch?v=-IpkzpLuuPM)\n- [Scalable Microservices with gRPC, Kubernetes, and Docker by Sandeep Dinesh, Google](https://www.youtube.com/watch?v=xsIwYL-N4vI)\n- [Node.js at Netflix](https://www.youtube.com/watch?v=p74282nDMX8)\n- [Node.js: Deploying, Monitoring and Scaling](https://www.youtube.com/watch?v=vR6xjmfc19Q)\n- [A Million Connections...and Beyond! - Node.js at Scale](https://www.youtube.com/watch?v=AH7kw8sKefg)\n- [Load Balancing with NGINX](https://www.youtube.com/watch?v=2X4ZO5tO7Co)\n\n### Example Code\n\n#### Cluster\n\n###### Check number of CPUs\n\n```\nconst cluster = require(\"cluster\"); // Cluster Native Module\nconst cpus = require(\"os\").cpus().length; // Number of CPUs\n\nconsole.log(\"Number of CPUs available - \", cpus)\n\n```\n\n###### [Full Clustering Example](https://github.com/realabbas/scaling-nodejs/blob/master/cluster/cluster.js)\n\n```\nconst http = require(\"http\");\nconst cluster = require(\"cluster\"); // Cluster Native Module\nconst cpus = require(\"os\").cpus().length; // Number of CPUs\nconst port = process.env.PORT || 3000;\n\nif (cluster.isMaster) {\n  // Checking whether the current cluser is master or not.Boolean value is returned\n  console.log(\"Master CPU - \", process.pid);\n\n  for (var i = 0; i \u003c cpus; i++) {\n    cluster.fork(); // Forking a new process from the cluster\n  }\n\n  cluster.on(\"exit\", (worker) =\u003e {\n    console.log(\"Worker Process has died - \" + process.pid); // Process that exited/died.\n    console.log(\"Process Remaining - \" + Object.keys(cluster.workers).length); // Prints the number of running workers at any instance\n    console.log(\"Starting New Working\");\n    console.log(\"Process Remaining - \" + Object.keys(cluster.workers).length);\n  });\n} else {\n  http\n    .createServer((req, res) =\u003e {\n      message = `Running Process: ${process.pid}`;\n      res.end(message);\n\n      // For Testing Purpose. Uncomment the following code to kill process by sending GET request to '/kill'\n\n      //   if (req.url === \"/kill\") {\n      //     process.exit();\n      //   } else {\n      //     console.log(process.pid);\n      //   }\n    })\n    .listen(port);\n}\n```\n\n###### [Zero - Downtime Example](https://github.com/realabbas/scaling-nodejs/blob/master/zero-downtime/zero-downtime.js)\n\n```\nconst http = require(\"http\");\nconst cluster = require(\"cluster\"); // Cluster Native Module\nconst cpus = require(\"os\").cpus().length; // Number of CPUs\nconst port = process.env.PORT || 3000;\n\nif (cluster.isMaster) {\n  // Checking whether the current cluser is master or not.Boolean value is returned\n  console.log(\"Master CPU - \", process.pid);\n\n  for (var i = 0; i \u003c cpus; i++) {\n    cluster.fork(); // Forking a new process from the cluster\n  }\n\n  cluster.on(\"exit\", (worker) =\u003e {\n    console.log(\"Worker Process has died - \" + process.pid); // Process that exited/died.\n    console.log(\"Process Remaining - \" + Object.keys(cluster.workers).length); // Prints the number of running workers at any instance\n    console.log(\"Starting New Working\");\n    cluster.fork(); // Creating a new process again after the previous process exited so that max number of cpus are utilised.\n    console.log(\"Process Remaining - \" + Object.keys(cluster.workers).length);\n  });\n} else {\n  http\n    .createServer((req, res) =\u003e {\n      message = `Running Process: ${process.pid}`;\n      res.end(message);\n\n      // For Testing Purpose. Uncomment the following code to kill process by sending GET request to '/kill'\n\n      //   if (req.url === \"/kill\") {\n      //     process.exit();\n      //   } else {\n      //     console.log(process.pid);\n      //   }\n    })\n    .listen(port);\n}\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealabbas%2Fscaling-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealabbas%2Fscaling-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealabbas%2Fscaling-nodejs/lists"}