Ahot's weblog

Wednesday Sep 03, 2008

Want your own super-computer? Want to predict weather? Don't have $1 000 000 000?

How about using of web-surfers' resources?

When user enter your site some little script would be included into the page. While client read the page this script could work and send calculated data to the server and receive new tasks (scripts to run) etc.

You can read this entry in my new blog


All we need is just appropriated task. The task have to be easy divided in short scripts. And those scripts have to produce limited output.
Let me show an example. How about Calculating Pi using the Monte Carlo method? Here is JavaScript program:
var pass = 0;
var fail = 0;
for (var i=0; i<100000; i++) {
   var x = Math.random();
   var y = Math.random();
   if ( x*x+y*y < 1 ) pass++; else fail++;
}
document.write('I think Pi = '+pass/(pass+fail)*4);
What is good here? Each step doesn't need any input data. Output data is very short: it can be number of passes and fails. How to adopt this script for our CLOUD IDEA? Simple:
var pass = 0;
var fail = 0;
for (var i=0; i<1000; i++) {
   var x = Math.random();
   var y = Math.random();
   if ( x*x+y*y < 1 ) pass++; else fail++;
}
$.post("/datareciever.cgi", {PASS:pass,FAIL:fail});
Nothing was changed. We just reduce number of steps. And add some AJAX request for sending calculated data.
Now our server can add this statistic to some file and use data collected from all your visitors for getting Pi with better precision.

Of couse it just an example. Here we will have some problems with JavaScript float type. Exactly this example can't calculate Pi with great precision. However it's the way to your own super computer :).
Comments:

Interesting. Some surfers may wish to contribute their resources this way - an simpler SETI@home kind of example.

Do you know of a way to turn this off at the user's end?

Posted by Mike on September 03, 2008 at 06:38 PM GMT+03:00 #

Brilliant!

Posted by Anthony Damasco on September 03, 2008 at 08:02 PM GMT+03:00 #

Post a Comment:
  • HTML Syntax: NOT allowed

FEEDS:

BOOKMARKS:

This blog copyright 2009 by ahot