npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

beehive-mpp

v0.0.7

Published

a basic massively parallel processing module that works with websites and uses client side processing power to complete tasks

Downloads

1

Readme

Beehive Massive Parallel Processing (beehive-mpp)

combine the processing power of your website's visitors' computers to create a one large network of processors that's capable of solving large complex problems without overburdening your server

How it works

the module transfers the load of processing large repetitive tasks from server side to client side computers, as it divides large repetitive tasks to smaller ones, the smaller tasks is then to be sent and processed on client side , the result will be sent back to the server and -optionally- checked by a different client visiting the site. it's more handy in tasks that require doing a repetitive task with large amount of data such as training a neural network in machine learning.

Getting Started

Installing

install and save module

npm install beehive-mpp -s

then require it in the route file

var Hive = require('beehive-mpp').Hive(options);


// set up route 
app.use('/Hive', function (req, res, next) {
  Hive.request(req, res);
  res.end();
});

and in client side hmtl pages add this js file to them

<script src="dist/bee.js"></script>
<script> 
 var bee = new Bee('/Hive');
     bee.initialize()
</script>

options available for Hive object :

  • beeTimeout :(time in ms) time it should wait before considering the bee expired (client side disconnected), default ->20000 which is 20 seconds
  • checkPercent : (number from 0 to 100) it means there's X (X: X<=100 & X>=0) chance that the data from client side is to be checked
  • logging : boolean determines whether or not it should display log in the console , default -> true

Usage

Setting up route and processing requests ( Hive.request(req,res) )

app.use('/Hive', function (req, res, next) {
  Hive.request(req, res);
  res.end();
});

Adding tasks to the hive ( Hive.addTask(options,callback) )

Used to assign the function and dataset to the hive ,the dataset will be later broken into smaller batches and added to the process queue to be processed by the clientside then to be checked by another pc

Hive.addTask(options,callback)
The options object:
  • fn: -required- the function that will process data ,you can pass either the name of the function on the front side as a string value or you can write and pass the js function itself.
  • dataSet: -required- (2D array) the data which will be processed , it takes the form of a 2d array [[arg1,arg2],[arg3,arg4], .... ] if the function takes 2 parameters as input, note that the number of iterations will be dependant on the dataset length.
  • batchSize:(Number) the whole task will be split into smaller process each with a fixed batch size , ie: if there are 1 million test case and the batch size is 10000 that means there would be a hundred process in the process queue , defaults to 1% from the whole dataset if not assigned.
  • name: (String) assign a name to the task so you would be able to recognize it from other tasks.
  • timePerIteration: (time in ms) should be assigned if the function takes too long to process one iteration , helpful to estimate the time require for task and it's expiration date , defaults to 1 ms if not assigned.

Examples on different ways for adding tasks

//backend 
Hive.addTask({
    fn: 'sum' , dataSet : [[1,2] , [3,5]] , batchSize:1 
},function (data){
    console.log(data)
})

//frontend
function task(a,b){
    return a+b ;
}
var bee = new Bee('/Hive');
    bee.initialize()

or

//backend 
Hive.addTask({
    fn: function task(a,b){
        return a+b ;
        } , dataSet : [[1,2] , [3,5]] , batchSize:1 
    },function (data){
        console.log(data)
})

//frontend
var bee = new Bee('/Hive');
     bee.initialize()

the result in both cases would be the same object { '0-0':[3] , '1-1':[8] }

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Hat tip to anyone who's code was used