• Stars
    star
    190
  • Rank 203,739 (Top 5 %)
  • Language
    JavaScript
  • Created over 10 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Realtime calculation distributed system. AKA distributed lodash

What is JS-Spark

Distributed real time computation/job/work queue using JavaScript. A JavaScript reimagining of the fabulous Apache Spark and Storm projects.

If you know underscore.js or lodash.js you may use JS-Spark as a distributed version of them.

If you know Distributed-RPC systems like storm you will feel at home.

If you've ever worked with distributed work queues such as Celery, you will find JS-Spark easy to use.

main page computing que

Why

There are no JS tools that can offload your processing to 1000+ CPUs. Furthermore, existing tools in other languages, such as Seti@Home, Gearman, require time, expensive setup of server, and later setting up/supervising clients machines.

We want to do better. On JS-Spark your clients need just to click on a URL, and the server side has one line installation (less than 5 min).

Hadoop is quite slow and requires maintaining a cluster - we can to do better. Imagine that there's no need to set up expensive cluster/cloud solutions. Use web browsers! Easily scale to multiple clients. Clients do not need to install anything like Java or other plugins.

Setup in a matter of minutes and you are good to go.

The possibilities are endless:

No need to setup expensive clusters. The setup takes 5 min and you are good to go. You can do it on one machine. Even on a Raspberry Pi.

  • Use as ML tool to process in real time huge streams of data... while all clients still browse their favorite websites

  • Use for big data analytics. Connect to Hadoop HDFS and process even terabytes of data.

  • Use to safely transfer huge amount of data to remote computers.

  • Use as CDN... Today most websites runs slower when more clients use them. But using JS-Spark you can totally reverse this trend. Build websites that run FASTER the more people use them

  • Synchronize data between multiple smartphones.. even in Africa

  • No expensive cluster setup required!

  • Free to use.

How (Getting started with npm)

To add a distributed job queue to any node app run:

    npm i --save js-spark

Look for Usage with npm.

Example: running multicore jobs in JS:

Simple example with node multicore jobs

example-js-spark-usage

git clone [email protected]:syzer/example-js-spark-usage.git && cd $_
npm install

Game of life example

distributed-game-of-life

git clone https://github.com/syzer/distributed-game-of-life.git && cd $_
npm install

Example: NLP

This example shows how to use one of the Natural Language Processing tools called N-Gram in a distributed manner using JS-Spark:

Distributed-N-Gram

If you'd like to know more about N-grams please read:

http://en.wikipedia.org/wiki/N-gram

How (Getting started)

Prerequisites: install Node.js, then: install grunt and bower,

sudo npm install -g bower
sudo npm install -g grunt

Install js-spark

npm i --save js-spark
#or use:
git clone [email protected]:syzer/JS-Spark.git && cd $_
npm install

Then run:

    node index & 
    node client

Or:

    npm start        

After that you may see how the clients do the heavy lifting.

Usage with npm

var core = require('jsSpark')({workers:8});
var jsSpark = core.jsSpark;

jsSpark([20, 30, 40, 50])
    // this is executed on the client
    .map(function addOne(num) {
        return num + 1;
    })
    .reduce(function sumUp(sum, num) {
        return sum + num;
    })
    .thru(function addString(num){
        return "It was a number but I will convert it to " + num; 
    })
    .run()
    .then(function(data) {
        // this is executed on back on the server
        console.log(data);
    })

Usage (Examples)

Client side heavy CPU computation (MapReduce)

task = jsSpark([20, 30, 40, 50])
    // this is executed on client side
    .map(function addOne(num) {
        return num + 1;
    })
    .reduce(function sumUp(sum, num) {
        return sum + num;
    })
    .run();

Distributed version of lodash/underscore

jsSpark(_.range(10))
     // https://lodash.com/docs#sortBy
    .add('sortBy', function _sortBy(el) {
        return Math.sin(el);
    })
    .map(function multiplyBy2(el) {
        return el * 2;
    })
    .filter(function remove5and10(el) {
        return el % 5 !== 0;
    })
    // sum of  [ 2, 4, 6, 8, 12, 14, 16, 18 ] => 80
    .reduce(function sumUp(arr, el) {
        return arr + el;
    })
    .run();

Multiple retry and clients elections

If you run calculations via unknown clients is better to recalculate same tasks on different clients:

jsSpark(_.range(10))
    .reduce(function sumUp(sum, num) {
        return sum + num;
    })
    // how many times to repeat calculations
    .run({times: 6})
    .then(function whenClientsFinished(data) {
        // may also get 2 most relevant answers
        console.log('Most clients believe that:');
        console.log('Total sum of numbers from 1 to 10 is:', data);
    })
    .catch(function whenClientsArgue(reason) {
        console.log('Most clients could not agree, ', + reason.toString());
    });

Combined usage with server side processing

task3 = task
    .then(function serverSideComputingOfData(data) {
        var basesNumber = data + 21;
        // All your 101 base are belong to us
        console.log('All your ' + basesNumber + ' base are belong to us');
        return basesNumber;
    })
    .catch(function (reason) {
        console.log('Task could not compute ' + reason.toString());
    });

More references

This project involves reimplementing some nice things from the world of big data, so there are of course some nice resources you can use to dive into the topic:

Running with UI

Normally you do not need to start UI server. But if you want to build an application on top on the js-spark UI server. Feel free to do so.

    git clone [email protected]:syzer/JS-Spark.git && cd $_
    npm install
    grunt build
    grunt serve

To spam more light-weight (headless) clients:

    node client

Required to run UI

  • mongoDB default connection parameters:

  • mongodb://localhost/jssparkui-dev user: 'js-spark', pass: 'js-spark1' install mongo, make sure mongod(mongo service) is running run mongo shell with command:

mongo
use jssparkui-dev
db.createUser({ 
  user: "js-spark",
  pwd: "js-spark1",
  roles: [
    { role: "readWrite", db: "jssparkui-dev" }
  ]
})
  • old mongodb engines can use db.addUser() with same API

  • to run without UI db code is not required!

  • on first run you need to seed the db: change option seedDB: false => seedDB: true on ./private/srv/server/config/environment/development.js

Tests

npm test

TODO

  • service/file -> removed for other module
  • di -> separate module
  • [!] bower for js-spark client
  • config-> merge different config files
  • [!] server/auth -> split to js-spark-ui module
  • [!] server/api/jobs -> split to js-spark-ui module
  • split ui
  • more examples
  • example with cli usage (not daemon)
  • example with using thu
  • [?] .add() is might be broken... maybe fix or remove

More Repositories

1

sentiment-analyser

ML that can extract german and english sentiment
JavaScript
36
star
2

img2ascii

Convert image url to ascii art
JavaScript
20
star
3

game-recruitment

Game to play during recruitment process, based on how you play we can say how strong are your problem solving skills
JavaScript
11
star
4

distributed-game-of-life

GOL done in distributed manner
JavaScript
8
star
5

distributedNgram

distributed word prediction using Js-Spark AKA TypeAhead
JavaScript
8
star
6

hackaton-holochain-2019-barcelona

TODO
HTML
6
star
7

twitter-marketing-bot

Marketing tool for twitter
JavaScript
6
star
8

sbb-blog-legal-hack-2017

Figure out important law compliance updates in a Jungle of data
JavaScript
5
star
9

F21

Catch 21, F10 hacaton app ... banking.. banking.. finance.. blockchain
Python
4
star
10

hackaton-2018-london-eos

EOS shizzle for all ppl loving cpp on the browser
JavaScript
4
star
11

JS-Spark-Ui

Client - side code for JS-Spark
JavaScript
4
star
12

2018-hack-n-lead

Verify your news / pictures with blockchain
HTML
4
star
13

git-soccer

Git ball game you play with fellow programmers
JavaScript
4
star
14

hackaton-2018-open-food-ch

Sub Zero squad, for smart fridge
JavaScript
3
star
15

snappy-cli

Snappy executable... ultra fast compresion algorithm
JavaScript
3
star
16

heroku-logger

Fast message/log server made for bot competition
JavaScript
3
star
17

euler-problem72-benchmark

Benchmarking different languages on euler project , problem 72
Java
3
star
18

benchmark-browsers

Benchamark different CPU using webbrowser
JavaScript
2
star
19

rapmed-cms

JavaScript
2
star
20

participatory-budgeting

participatory budgeting for Colombia made @peachHack Zurich 2016
JavaScript
2
star
21

function-tools

Small (hopefully) lib for operating with files in functional programming style
JavaScript
2
star
22

example-js-spark-usage

example of using multicore javascript execution using js-spark
JavaScript
2
star
23

mr-t

Cli tool that translates to english
JavaScript
2
star
24

mac-ram-drive

running your intelij on ram drsk
Shell
2
star
25

hackaton-peacehack-rumor-tracking

hackaton-peacehack-rumor-tracking
JavaScript
2
star
26

ts-jest-example

Example jest with ts
TypeScript
2
star
27

algo-course-2016

Algorithmic course 2016
Python
2
star
28

deployments

comparision of different deployments platforms
JavaScript
2
star
29

md2slides

markdown to html slides converter with syntax hilighting
HTML
2
star
30

scraping-courses

Scraping courses, scraper with Chrome
HTML
2
star
31

which-db-we-using-this-week

Text based game about working in startup
JavaScript
2
star
32

compliment-as-a-service

How to praise ppl for their efforts
JavaScript
2
star
33

dictionary-react-native

Dictionary react native app, from tutorial
Objective-C
2
star
34

go-revel-hello

assessment of golang revel framework
HTML
2
star
35

webrtc-experiment

this is webRTC peer to peer chat client
JavaScript
2
star
36

flying-doge

Small phaser demo of game about `doge that can fly`
JavaScript
2
star
37

flappy-bird

flappy bird implemented for mobile and web
JavaScript
1
star
38

MyTree

Automatically find a pictures of trees and post them on instagram.
1
star
39

type-safety

type safety for express.js
JavaScript
1
star
40

whatsMyIp

Show ip adresses and qr codes and in terminal (local/public)
JavaScript
1
star
41

2018-fintech-games-regex-solver

its for regex sudoku
JavaScript
1
star
42

FitnessDataPrediction

prediction using r
R
1
star
43

space-hipster-game

tutorial game of space hipster
JavaScript
1
star
44

open-data-management

open data management and sharing of csv, json, merging
JavaScript
1
star
45

find-job

find jobs like a pro
HTML
1
star
46

bash-game-of-life-2017

bash game of life
Shell
1
star
47

unl-svg-animation

example of UML animation
HTML
1
star
48

test-syzer

1
star
49

distributed-calc-system

Distributed calculation system using JS-Spark, from AngelHack (hackaton)
JavaScript
1
star
50

co-routine

golang like concureny pattern for java script
JavaScript
1
star
51

syzer.github.io

github pages for benchmark project
1
star
52

mac-reconect-preffered-network

mac-reconect-preffered-network is self expanatory
Shell
1
star
53

transfrom-stream-such

such transfrom for streams in node 5
JavaScript
1
star
54

HackZurich2019

Helsana health prediction app
Vue
1
star
55

devices-management

remote devices managmenet using ssh
JavaScript
1
star
56

angular-qAll

Que all promises with progress bar
JavaScript
1
star
57

evolver

Go implementation of evolver.
Go
1
star
58

angular-decorators

colelction of (hopefully) usefull decorators AKA Aspect Objected Programming AKA FP
JavaScript
1
star
59

euler-problem-92

square digit chains
JavaScript
1
star
60

repo

Opens git internal repository if exists... and notify you when you forgot vpn
Go
1
star
61

recompile-example

How to recompile server for different platforms
JavaScript
1
star
62

basel-js-es6

basel js es6 talk, a code to workshop i gave in 2015
JavaScript
1
star
63

z-time-right-prompt

if command runs longer than 3 sec put on time on execution on the right prompt
Shell
1
star
64

js-spark-flappy-bird

soft shake conference demo
JavaScript
1
star
65

test-ciapek

1
star
66

forecastOfStock

Resltime prediction of stock price with R
R
1
star
67

reactiveStock

Reactive R stock market visualization
R
1
star
68

who-dat

Face detection in realtimne
1
star
69

cosmos-blockchain-app

Name service app based on https://cosmos.network/docs/tutorial/
Go
1
star
70

eureka-js-connection

Example using netflix eureka
HTML
1
star
71

graphql-server-postgre

GraphQL Schema Server with PosgreSQL db in backend
JavaScript
1
star
72

speech-recognition

Uses speech recognition to play BS bingo for you.
JavaScript
1
star
73

hackZurich2017-banking-app

Virtual asistant for banking and insurances connected with talking ABB robot
Java
1
star
74

recommendation-music

Music recommender using spotify db.
JavaScript
1
star