📜 ⬆️ ⬇️

Kaylee: distributed computing in the browser

In 1999, the SETI @ home project invited users to provide the resources of their personal computers for analyzing radio signals from space in order to search for extraterrestrial intelligence. As part of this project, a BOINC (Berkeley Open Infrastructure for Network Computing) platform was developed at Berkley University, on the basis of which the already mentioned SETI @ home, ABC @ home (proof of abc-hypothesis), Climateprediction.net (improvement of climate models) , LHC @ home (simulation of collisions of high-energy particles) and others.

And everything would be fine, but for the work of BOINC, one mandatory condition is required: the user needs to download, configure and run the client part. What to do if for some reason it is impossible to do? And how great it would be just to click on the link in the browser and instantly turn the computer into a link in a large computer network!

With these thoughts in mind, I started writing Kaylee .
')


How did it all begin


The idea to write my BOINC with browsers and calculations came about 5 years ago, when in 2007, thanks to Vova Casanova, my wonderful roommate in the university hostel, I met Ubuntu and moved to C # in Python. The project “Distributed JavaScript Computing” was planned as a pilot project. But neither knowledge, nor experience, nor perseverance was enough then.

It has been a little over 4 years. The desire to write your own framework is not lost, but the possibilities have become much more! In the HTML5 standard, Web Workers appeared, allowing javascript code to be executed in parallel with the main browser JS stream. Compared with its predecessors, V8, SpiderMonkey, Carakan have achieved impressive speeds. CoffeeScript allows you to write clean and readable code. And finally, I fell in love with Python so much that I wanted to write on it a full-fledged framework with all the accompanying attributes (documentation, packages on PyPI, etc.).

What tasks were set


From the user's point of view

From the user's point of view, everything should look very simple: “Would you like to click on this link and leave the computer on for the night in order to help scientists in search of a cure for <here is the name of a terrible disease>?”

A more audacious option: the user visits a favorite site, and here in the invisible iframe, without asking anything, not offering, and without ceremony at all, bitcoin mining begins.

More time-consuming option: the user has to participate in the calculations personally, for example, a picture is displayed that needs to be described by words.

From the point of view of the programmer

From the programmer’s point of view, everything looks a little less rosy: you need to write the server part of the distributed application (in terms of Kaylee - Project ) in Python, which will be Tasks and the client part of the application in JavaScript / CoffeeScript, which will solve these tasks.
In the first case, everything is solved by inheriting and extending an abstract class, in the second - by implementing two functions. All communication between the server and the client occurs in JSON. Adherents of node.js will forgive me, but programming from JavaScript and even CoffeeScript I do not get even a bit of the pleasure that comes from programming in Python.

And what happened?


And it turned out Kaylee (in honor of the heroine of the TV series "Firefly").
Kaylee takes care of the communication between the server and the nodes (user browsers) of the computer network and the storage of intermediate and final results, allowing the programmer to concentrate on the application itself.

Kaylee can work with almost any Python web framework as a frontend (Django and Flask is supported out of the box).

As a test bench, the problems of calculating the value of Pi using the Monte-Carlo method and “hacking” salted md5 hash were used. With both tasks, it seems to me, the framework handled it with a bang!

Comrades!


The project is at an early stage of development and Khabrovchans are the first to whom I decided to tell about it. If you are interested, if you have questions, suggestions, comments, criticism and of course the desire to participate, all this is warmly welcomed!

Source: https://habr.com/ru/post/151801/


All Articles