All Projects → realabbas → scaling-nodejs

realabbas / scaling-nodejs

Licence: other
📈 Scaling Node.js on each X, Y and Z axis using Node.js Native Modules, PM2, AWS , Load Balancers, AutoScaling, Nginx, AWS Cloudfront

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to scaling-nodejs

sensu-plugins-aws
This plugin provides native AWS instrumentation for monitoring and metrics collection, including: health and metrics for various AWS services, such as EC2, RDS, ELB, and more, as well as handlers for EC2, SES, and SNS.
Stars: ✭ 79 (+8.22%)
Mutual labels:  load-balancer, cloudfront, autoscaling
magento-cluster
Highly Available and Auto-scalable Magento Cluster
Stars: ✭ 21 (-71.23%)
Mutual labels:  load-balancer, scaling, autoscaling
Gobetween
☁️ Modern & minimalistic load balancer for the Сloud era
Stars: ✭ 1,631 (+2134.25%)
Mutual labels:  backend, load-balancer
Escalator
Escalator is a batch or job optimized horizontal autoscaler for Kubernetes
Stars: ✭ 539 (+638.36%)
Mutual labels:  scaling, autoscaling
Replicator
Automated Cluster and Job Scaling For HashiCorp Nomad
Stars: ✭ 166 (+127.4%)
Mutual labels:  scaling, autoscaling
Pm2 Slack
A PM2 module to emit events to Slack
Stars: ✭ 124 (+69.86%)
Mutual labels:  pm2, nodejs-modules
Custom Pod Autoscaler
Custom Pod Autoscaler base, allows creation of Custom Pod Autoscalers
Stars: ✭ 148 (+102.74%)
Mutual labels:  scaling, autoscaling
Pm2
Node.js Production Process Manager with a built-in Load Balancer.
Stars: ✭ 36,126 (+49387.67%)
Mutual labels:  pm2, load-balancer
Koa Vue Notes Api
🤓 This is a simple SPA built using Koa as the backend, Vue as the first frontend, and React as the second frontend. Features MySQL integration, user authentication, CRUD note actions, and async/await.
Stars: ✭ 342 (+368.49%)
Mutual labels:  backend, pm2
Proxy
The type-safe REST library for .NET Standard 2.0 (NetCoreStack Flying Proxy)
Stars: ✭ 40 (-45.21%)
Mutual labels:  backend, load-balancer
safe-transaction-service
Keeps track of transactions sent via Gnosis Safe contacts and confirmed transactions. It also keeps track of Ether and ERC20 token transfers to Safe contracts.
Stars: ✭ 72 (-1.37%)
Mutual labels:  backend
cart
Simple Symfony 4 shopping cart application. App boilerplate
Stars: ✭ 18 (-75.34%)
Mutual labels:  backend
vos whatsapp
vangav open source - whatsapp; generated using vangav backend:
Stars: ✭ 14 (-80.82%)
Mutual labels:  backend
Wedge
可配置的小说下载及电子书生成工具
Stars: ✭ 62 (-15.07%)
Mutual labels:  nodejs-modules
paperclip
A DSL for web UI builders
Stars: ✭ 197 (+169.86%)
Mutual labels:  backend
portal
An api-driven, in-kernel layer 2/3 load balancer.
Stars: ✭ 101 (+38.36%)
Mutual labels:  load-balancer
skenario
A simulator toolkit for Knative
Stars: ✭ 26 (-64.38%)
Mutual labels:  autoscaling
media manager plus
Ermöglicht das Gruppieren von Media-Manager-Typen und stellt eine Frontend-API (PictureTag) bereit.
Stars: ✭ 21 (-71.23%)
Mutual labels:  backend
mojo.js
🦄 The Mojolicious real-time web framework for Node.js
Stars: ✭ 145 (+98.63%)
Mutual labels:  backend
dshackle
Fault Tolerant Load Balancer for Ethereum and Bitcoin APIs
Stars: ✭ 133 (+82.19%)
Mutual labels:  load-balancer

Scaling Node.js Guide Github Ali Abbas @realabbas

Visitors

Scaling Types

  • X Axis
  • Y Axis
  • Z Axis

Node.js Native Modules

  • cluster
  • os
  • spawn

Resources and techniques

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

Blogs

Videos

Example Code

Cluster

Check number of CPUs
const cluster = require("cluster"); // Cluster Native Module
const cpus = require("os").cpus().length; // Number of CPUs

console.log("Number of CPUs available - ", cpus)

Full Clustering Example
const http = require("http");
const cluster = require("cluster"); // Cluster Native Module
const cpus = require("os").cpus().length; // Number of CPUs
const port = process.env.PORT || 3000;

if (cluster.isMaster) {
  // Checking whether the current cluser is master or not.Boolean value is returned
  console.log("Master CPU - ", process.pid);

  for (var i = 0; i < cpus; i++) {
    cluster.fork(); // Forking a new process from the cluster
  }

  cluster.on("exit", (worker) => {
    console.log("Worker Process has died - " + process.pid); // Process that exited/died.
    console.log("Process Remaining - " + Object.keys(cluster.workers).length); // Prints the number of running workers at any instance
    console.log("Starting New Working");
    console.log("Process Remaining - " + Object.keys(cluster.workers).length);
  });
} else {
  http
    .createServer((req, res) => {
      message = `Running Process: ${process.pid}`;
      res.end(message);

      // For Testing Purpose. Uncomment the following code to kill process by sending GET request to '/kill'

      //   if (req.url === "/kill") {
      //     process.exit();
      //   } else {
      //     console.log(process.pid);
      //   }
    })
    .listen(port);
}
Zero - Downtime Example
const http = require("http");
const cluster = require("cluster"); // Cluster Native Module
const cpus = require("os").cpus().length; // Number of CPUs
const port = process.env.PORT || 3000;

if (cluster.isMaster) {
  // Checking whether the current cluser is master or not.Boolean value is returned
  console.log("Master CPU - ", process.pid);

  for (var i = 0; i < cpus; i++) {
    cluster.fork(); // Forking a new process from the cluster
  }

  cluster.on("exit", (worker) => {
    console.log("Worker Process has died - " + process.pid); // Process that exited/died.
    console.log("Process Remaining - " + Object.keys(cluster.workers).length); // Prints the number of running workers at any instance
    console.log("Starting New Working");
    cluster.fork(); // Creating a new process again after the previous process exited so that max number of cpus are utilised.
    console.log("Process Remaining - " + Object.keys(cluster.workers).length);
  });
} else {
  http
    .createServer((req, res) => {
      message = `Running Process: ${process.pid}`;
      res.end(message);

      // For Testing Purpose. Uncomment the following code to kill process by sending GET request to '/kill'

      //   if (req.url === "/kill") {
      //     process.exit();
      //   } else {
      //     console.log(process.pid);
      //   }
    })
    .listen(port);
}

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].