ARGENTOP2P

Soporte, Ayuda y Consultas => Programación en General => Mensaje publicado por: snoop en Noviembre 18, 2005, 17:44:11

Título: Procesamiento en paralelo via web browser
Publicado por: snoop en Noviembre 18, 2005, 17:44:11
Hoy leí esta nota en el blog de los admins de mininova.org

CitarMininova, the javascript cluster (http://blog.mininova.org/articles/2005/11/17/mininova-the-javascript-cluster)

Posted by Erik about one day ago

This one time I was thinking of what would be possible with Mininova and all its visitors. The first think I thought about was a hidden IFRAME DDOS, but this wouldn’t be cool (but maybe I’ll talk about this later). The second thing that came to my mind was a little more complicated but also more fun. Why not use the visitor’s browser to do some calculations. When a page is loaded and the visitor is reading the page the browser does (almost) nothing, so why not use this time. My Idea was to send some javascript with the page and execute it when the page is loaded. The results could be posted back with a XMLHTTPRequest. This request could even be used to fetch another script to execute next for if the user keeps the page open for some time. So let’s calculate how fast this would be.

Mininova has 3,770,305 page views per day. 99.27% of the Mininova visitors have Javascript enabled. So this is 3,742,782 page views per day with Javascript enabled. This is 155,949 page views with javascript enabled per hour, 2,599 per minute or 43 per second. The average time spend on a page is about 10 seconds. This is really a guess (maybe someone knows a better guess?). Using this data we can say that at any time 43 * 10 = 430 people will have a Mininova page open (in a browser with javascript enabled).

On my machine (FireFox 1.5 Beta 2, AMD Athlon 64 3000+ ~2GHz CPU) Javascript can execute 2,000,000 IPS. With IE this is even more, 2,500,000 IPS. check on your machine Because 60.32% of the Mininova visitors uses IE but not everyone has a fast CPU I’ll use an average of 2,250,000 IPS.

So using this data we can calculate that with this cluster we can do 430 * 2,250,000 = 967,500,000 IPS. Which is 967.5 MIPS.

Now let’s compare this to some CPU’s.
486   20 MIPS   
Pentium   60 MIPS   
Pentium Pro   200 MIPS   
Pentium 2   333 MIPS   
Pentium 3   500 MIPS   
Mininova cluster   967 MIPS   
Pentium 3 (1Ghz)   1000 MIPS   
Pentium 4   1500 MIPS   
Itanium   +2500 MIPS   

data from here

So the Mininova javascript cluster is almost as fast as a 1Ghz Pentium 3. Not as fast as I thought when I started writing this but still not slow.

I have never tested this for real because of 3 things: 1) I don’t know if the Mininova visitors would like it if their browser uses all their CPU power when visiting Mininova. 2) Measuring this isn’t easy. 3) Because almost every page views would result in a request to post back the data it would double the requests which the Mininova web server won’t like.

I think testing it for real would result in a somewhat slower speed. One of the things that I haven’t taken into my calculations it the time it takes to post back the data with a XMLHTTPRequest. Also one of the problems would be people closing the page before the request is done.

I think I will never find out if it really works and what the real speed would be. But it was fun calculating this stuff and thinking about it. Hope you enjoyed reading this,

Erik.

More fun can be found at the Mininova labs.
Codigo: http://labs.mininova.org/ips.html  para calcular las instrucciones java script por segundo.
<a href="http://labs.mininova.org">Back to mininova labs</a>
<script language="javascript">
var start = new Date().getTime();
var count = 0;
var i;
for (i = 0; i < 500000; i++) {
 count += 3;
}
var milisecs  = new Date().getTime() - start;
var persecond = (count / milisecs) * 1000;
alert('javascript instructions per second: ' + Math.round(persecond));
</script>


A mi se me habia pasado por la cabeza algo de esto.. pero bueno, nunca tube la oportunidad.. es que no me imagino para que se puede utilizar..
Es como el SETI@home, pero sin necesidad de instalar nada.. solamente navegando.. muy interesante...
El resultado se puede pasar mediante cookies o con algo como:
<img src="pagina.php?resultado=valor">
Claro esta "valor" es el resultado.