As I wanted to find good reasons to use Javascript as a language to do image processing, I thought of distributed computing that would be extremely easy to do. Users have nothing to install, they just have to visit a webpage. And since we want many users to participate we could embed it into a popular webpage.

There are many issues using browsers as distributed computing nodes:

  • User approbation: Will they allow you to run random script on their machine as they just wanted to visit a site.
  • Liability of the Data: Since process is being done on untrusted people, we must find ways to verify it.
  • User disconnection: We are going to compute the data while they are browsing the web, if they change of URL, reload the page or close their browser we wont get any result.

User Disconnection Over Time

In order to test the last point, I added a small Javascript program on the popular website MMO-Champion.com. Every one minute, it will send the time spent on the page to my server. I ran it for about 2 hours (then it DDOS'ed my server :( ). I aggregated the results in the following chart.

We can extract 3 phases from this graph.

  • Under 5 minutes the user is really likely to disconnect.
  • Between 5 and 15 minutes, the chance of disconnection is reducing
  • After 15 minutes, really few users are disconnecting.

You can see it in another way:

  • 50% of the users that have stayed 10 minutes are staying 1 hour.
  • 10% of the users that have stayed 1 minutes are staying 1 hour.

Chance of Script Completion

What we really want to know is either or not our script will complete. In order to test that I took the data we gather and computed the percentage of users that would still be there X minutes later.

After 15 minutes, a script that takes 1-10 minutes to complete has 95% chance of finishing without being interrupted.

Conclusion

The user disconnection is not really an issue. If do the computation on users that are staying more than 15 minutes, we have a 95% rate of completion for a 10 minutes script.

If you liked this article, you might be interested in my Twitter feed as well.
 
  • http://bateru.com/ Larry Battle

    Isn't this proposal also assuming that the computations don't affect the browser's performance?
    I'm not sure about others but if I run a web-page that slows download my browser or starts the fan running then I exit the site immediately.
    But I guess you could easily fix the issue by using setInterval and computing small amounts of data with each loop.

    Nice Article.

  • http://vjeux.com vjeux

    This is indeed an issue. I don't exactly believe that this could be done on behalf of the user.

    I just have the thought of the web as a massively distributed environment. I just wanted to know if technically it would be possible.

    Now, this is an ethical complex subject and this is not the goal of the article :)

 

Random Posts

  • October 30, 2009 -- Javascript – Dynamic Query Throttling (1)
    Working on the World of Raids Recruitment Tool we wanted automatic saving while editing. There are basically two ways of handling the problem. Send update everytime something changes. The main advantage of this technique is that you are always up to date. However, it is spamming the server on field...
  • December 7, 2011 -- Automatic Links with Trie (0)
    On MMO-Champion, we often paste World of Warcraft patch notes taken from Blizzard. The main problem is that it's plain text. We want to be able to add links to all the spells, quests, zones ... This way people can mouseover and see the description. It helps figuring out what changed. We create a ...
  • January 8, 2010 -- Javascript – Sorting Table (4)
    For my new project on World of Raids I have to implement a table sorting. The browser not stable sorting and the faster sorting trick add difficulty to the task. String Comparison As mentionned in the Speed Up Javascript Sort() article, using a string as a key to represent each element is faster...
  • March 22, 2010 -- Project – SC2Mapster (0)
    [caption id="attachment_1060" align="alignright" width="200" caption="SC2Mapster"][/caption] Let's get back three months before the beginning of my internship. Blizzard just released the private beta of the long waited real-time strategy (RTS) game Starcraft 2, a remake of their first extreme...
  • November 20, 2009 -- Makefile – Automatic Dependencies with makedepend (0)
    Having to deal with dependencies in Makefile is a real pain, there are a lot of examples of way to deal with it on the web but none of them is satisfying. For example using gcc -MM does not work with subfolders, a depend rule requires the user to use it everytimes he adds new files ... Here is...