GithubHelp home page GithubHelp logo

mostafa-samir / klyng Goto Github PK

View Code? Open in Web Editor NEW
168.0 11.0 10.0 170 KB

A message-passing distributed computing framework for node.js

License: MIT License

JavaScript 97.74% C++ 2.02% C 0.24%
distributed-computing parallel-computing message-passing nodejs javascript

klyng's Introduction

klyng

Build Status Build Status Node Version >= 4.2.3

Write and execute distributed code on any* platform that can run node.js

Distributed Hello World!

var klyng = require('klyng');

function main() {
    var size = klyng.size();
    var rank = klyng.rank();

    console.log("Hello World! I'm Process %d-%d", rank, size);

    klyng.end();
}

klyng.init(main);

Distributed Hello World

System Requirements

You can use klyng anywhere; provided that you have node.js v4.2.3 or later installed. Also, because klyng is built on node-fibers, your need to be able to run or build fibers on your system. Fibers is naturally available via npm for Linux, OS X and Windows 7 (or later), for other operating systems you will probably need to compile fibers form its C/C++ source.

Security

When it comes to running jobs on remote devices, klyng implements several measures to ensure a secure communication channel.

  1. A key-exchange algorithm (Diffie-Hellman) is used to establish a shared secret key between the two communicating devices. This key is used later to encrypt the messages carrying sensitive data (with AES-256) and stamp them with an HMAC.

  2. For now, each node (in klyng's jargon, a beacon) is protected with a password. Sending a password between two nodes for authorization is done through the secure channel established is step 1.

  3. Once a node is authorized, it can pack the job's source in one file a sends it through the secure channel for the other node to run. Any control signals is also sent through this channel. Only the messages sent between the processes during the job is not secured.

Performance

In order to evaluate klyng's performance and how well it scales with the number of processors, A benchmarking script was designed to compare klyng's performance to that of MPICH2 (with C/C++) on the same tasks. The benchmarks focused on two metrics:

  • Runner Total Execution Time (RTET): which is actual time taken by the job, form the moment the runner is executed with the job to the moment it exits.

  • Max Process CPU Time (MPCT): which is the maximum of the CPU time of all the participating processes in the job.

As the MPCT metric uses the actual time spent by an individual process on the CPU, it measure how well is the framework scaling as if each process is running on its own CPU, which is not the real case. The real case, in which there are multiple processes and a limited number of processors so processes will probably share time on a single processor, is captured with RTET metric.

Compared to MPICH2 with C/C++, the data shows that klyng and javascript scales with the number of processors just as well (and in some cases, even better).

Pi-MPCT

Primes-MPCT

Pi-RTET

Primes-RTET

The data represents how both MPICH2 and klyng scale with the number of processes on two computationally-intensive tasks:

  • Pi Approximation: which approximates the value of π with the arctan integral formula using the a Reimann sum with Δx = 2x10⁻⁹.

  • Counting Primes: which counts the number of prime numbers between 1 and 10⁷ using the naive primality test of trial division.

These data were collected on a machine with an Intel Core i5 2410M CPU @ 2.30GHz (2 physical cores, with hyper-threading disabled), running node v5.4.1 on Ubuntu14.04. Each task of the two ran 100 times and the RTET and MPCT were collected for each run and averaged in the end into the data depicted in the charts. This process was repeated for each framework (MPICH2 and klyng) on each process count (1, 2, and 4).

To make these data reproducible, the benchmarking script along with the source code for the tasks in question are shipped with the framework. The benchmarking script is also customizable for different environment parameters and extensible for more tasks.

For more information on running the benchmarks, please refer to the documentations.

Relation to MPI Standards

The project was originally motivated by MPI, so it's greatly influenced by the MPI standards, and the standards was used more than one time as a reference in the implementations of some aspects of the project. However, the project in its current state cannot be considered as an implementation of the MPI standards; it can be considered, for now, as a weak implementation of the MPI standards.

Dive In!

  1. Getting Started
    1. Installation
    2. Program Structure
    3. Dividing the Job
    4. Sending and Receiving Messages
    5. Running Locally
    6. Configuring your Device for Remote Jobs
    7. Running on Remote Devices
  2. API Documentation
    1. Environment Methods
    2. Communication Methods
  3. CLI Documentation
  4. Tests and Benchmarks
    1. Unit and Integration Tests
    2. Benchmarks

License

MIT

klyng's People

Contributors

mostafa-samir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

klyng's Issues

UnhandledPromiseRejectionWarning

Node: v7.3.0
O/S: (Raspian) Linux computername 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux
...and also
O/S: (Mac OS X El Capitan) Darwin computername 15.6.0 Darwin Kernel Version 15.6.0: Wed Nov 2 20:30:56 PDT 2016; root:xnu-3248.60.11.1.2~2/RELEASE_X86_64 x86_64
Klyng: 1.0.2

Installed globally per instructions. Created project with npm and then did a npm install --save klyng.

Attempting to run any command beginning with klyng ... results in an UnhandledPromiseRejectionWarning.

For example, klyng --beacon-up:

(node:3339) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: ipc.of.klyng_beacon.on is not a function
(node:3339) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
/home/pi/.npm-modules/lib/node_modules/klyng/node_modules/node-ipc/dao/client.js:125
            client.trigger('error', err);
                   ^

TypeError: client.trigger is not a function
    at Socket.<anonymous> (/home/pi/.npm-modules/lib/node_modules/klyng/node_modules/node-ipc/dao/client.js:125:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1281:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Or klyng -n 1 hello.js:

(node:3357) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: ipc.of.klyng_beacon.on is not a function
(node:3357) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
/home/pi/.npm-modules/lib/node_modules/klyng/node_modules/node-ipc/dao/client.js:125
            client.trigger('error', err);
                   ^

TypeError: client.trigger is not a function
    at Socket.<anonymous> (/home/pi/.npm-modules/lib/node_modules/klyng/node_modules/node-ipc/dao/client.js:125:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1281:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

...yields the exact same error.

Trying sudo klyng --beacon-up yields sudo: klyng: command not found.
Trying sudo /home/pi/.npm-modules/bin/klyng --beacon-up yields the same result in the first two examples, so I don't think it has to do with rights.

I'd really like to use your code if I can. See e=mc2 supercomputer project.

Using with express?

AOA
Alap Arsalan maqsood here
i want to know that, how can use klyng with express framework can you help me ?
TIA

Can't find klyng in path

I took your advice in the installation instructions and created a ~/.npm-modules folder and ran the NPM_CONFIG_PREFIX=/home/pi/.npm-modules npm install -g klyng as root and edited the ~/.profile file to prepend ~/.npm-modules/bin to the PATH.

  1. echo $PATH shows that it's correctly prepending the bin folder that includes the symlink.
  2. which klyng shows /home/pi/.npm-modules/bin/klyng as expected.
  3. The klyng symlink points to ~/.npm-modules/lib/klyng/bin/main.js.
  4. There appears to be a problem when attempting to run this on OS X or any Linux-based computer in that the top line of main.js ends in a CR+LF ("\r\n") pairing rather than just the expected new line which is typical for Linux. I'm guessing that you edit your files in Windows.
  5. As a result of this, bash can't properly figure out which node command that you're trying to run from the top line of your main.js file. It sees "node\r" and looks for this throughout the PATH and doesn't see it. The end result is -bash: /usr/bin/klyng: No such file or directory.

If you use vi to edit main.js in-place and remove the "\r" at the end of the first line, it can at least attempt to proceed. Doing this will then find klyng where it lives.

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.