Coder Social home page Coder Social logo

cluster's Introduction

node-cluster-seed

- A simple seed project for quickly getting started with node-cluster.	

- Current version is tested with Node v0.10.21 and above.

- Presented example uses Express for the worker.

###Descrition on repo contents

  1. cluster.js - Main file which is responsible for forking worker processes and managing them. - Contains separate sections for the tasks to be done while in master process and for the tasks to be done while in worker process. - Master process forks workers equal to the number of CPUs in the running environment. - Has configuarable scheduling algorithm setting. - Contains all essential life cycle methods like fork,online,exit,etc., in the master process. - The example presented has a simple tracker module that keeps track of all the HTTP requests received by all workers.

  2. worker.js - This file contains all the chores that each worker has to perform when spawn. - In the example presented, each worker reports to master on every incoming request that it receives.

  3. enums.js - Helper to hold address type mapper and the similars.

###How to run

  • env NODE_CLUSTER_SCHED_POLICY="none" node cluster // to let operating system decide on the scheduling policy

  • env NODE_CLUSTER_SCHED_POLICY="rr" node cluster // to force round-robin manually

  • node cluster // Naa, I don't care what scheduling policy will be used. ;)

###Todo's

- Write tests
- Add code comments
- Rethink optimizations

cluster's People

Contributors

hseirafi avatar

Watchers

James Cloos avatar  avatar

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.