Code Monkey home page Code Monkey logo

nodejs-nginx-load's Introduction

nodejs-nginx-load

Nginx as load balancer for nodejs application servers This is written in bash for the version 1. It shall be improved to Ansible, Chef variants with time.

###Goal

Write a script which will automate following tasks.

i. Start the new nginx server (listen to port 80).

ii. create node.js environment.

iv. pull git repo (nodejs hello world) and start server (it will start on 8080 port)

v. add this node.js server process to load balancer.

vi. if load balancer getting 100 requests/minute then spin up new node.js server process which will listen on next available port. add this new node server to load balancer.

vi. If number of request fall below 100 requests/minute then stop node.js server process. Server which is most recently created should stop.

###Clone and start Clone this repo in home folder.

Nodejs is installed in non sudo current user.

To install: ssh ubuntu@ip < install.sh This installs nginx, nodejs, forever, etc. as required.

To configure: ssh ubuntu@ip < config.sh

To deploy: ssh-add /path/to/privatekey_which_has_access_to_git_repo ssh -A ubuntu@ip < deploy.sh

###Approaches

  1. Nginx to do load balancing. Uses upstream. Alternatives: haproxy
  2. nodejs process run on ports 8080, 8081 during run.sh. 8080 is never killed, in this process.
  3. request per minute is calculated by parsing nginx status output every minute, finding difference in number of requests. 100 is purely for experiment. In reality, nginx handles higher number of requests.
  4. New node process is spawned or killed, based on above parameter.
  5. forever is used in running nodejs process.

nodejs-nginx-load's People

Contributors

acsrujan avatar

Watchers

James Cloos avatar

nodejs-nginx-load's Issues

nodejs install

if node, npm, forever are already present and are in desired paths, don't install them again

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.