No commit activity in last 3 years
No release in over 3 years
DistributedRails enables the server to use the clients (browsers) to execute javascript tasks and return the results. Think SETI@home or folding@home
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 3.2.8
 Project Readme

DistributedRails

Distributes tasks to multiple browsers

Inspired by projects like folding@home and SETI@home, this is a plugin for Rails that allows the server to distribute tasks to its clients (browsers). This is best suited for highly parallelizeable tasks such as monte-carlo simulations or other embarassingly parallel problems.

Original (read: deprecated) project: ciniglio/distributed

Usage

Install with bundler

`gem 'distributed_rails'

Then in your routes.rb:

mount DistributedRails::Engine, :at => '/tasks'

Finally, in whichever template you'd like this to run from

e.g. layouts/application.html.erb

Add the line <%= javascript_include_tag "distributed_rails/application" %>

Now we're ready to get cooking!

  • Provide tasks.js files in app/tasks
  • task*.js must define var nextTask = main_function_name
  • The result of main_function_name will be saved in the db

Notes

Verification

Already completed tasks will run again on a new machine and the results will be compared (about 10% of the time). This gives some additional confidence in the results, but is by no means a security guarantee.

Some tasks (e.g. random generations) are not well suited for verification. For these tasks, the rake tasksjs:repeated command takes an additional argument to omit verification.

Rakefile

A Rakefile has been provided to make some common tasks easier. The namespace is tasksjs.

Note: For rake operations that add tasks to the database, rake will also look for a parameters file parameters_task*.txt in the same location, and will use parameters on a single line. See more at parameters

  • rake tasksjs:init will clear all tasks from the database, then go through all the tasks in app/tasks and add them to the database
  • rake tasksjs:repeated will take an argument num and add all the tasks in app/tasks num times.
  • as noted above rake tasksjs:repeated will take an additional argument to disable verification. If you want verification to be disabled, you should pass "true".

Parameters

The parameters_task*.txt file is expected to have all the needed comma separated parameters on one line. This will then be applied to the function in task*.txt, once for every line.

A parameters_task*.txt like the following:

0, "james", "sally"
5, "john", "jerry"

will result in two tasks being added to the queue:

  • task*.js with args 0, "james", "sally"
  • task*.js with args 5, "john", "jerry"

Initial Goals

  • browsers execute arbitrary tasks and return results to browser
  • server manages queue from db
  • things are added to queue only by the server (clients adding tasks is a non-goal for now)