📜 ⬆️ ⬇️

Javascript distributed computing

The other day I discovered Life with Playstation, but the essence is not in it, but in the background process Folding @ home . Distributed computing project for computer simulation of the coagulation of protein molecules. While we are reading the news, we see the weather, our PS3 does calculations for Folding @ home.

And then I got the idea, and why not make calculations in the browser while the user is working on our site, because the load on the processor when viewing the site is minimal.

I couldn’t think for a long time what could be calculated distributedly in order to materialize an idea ... Rendering a 3D scene is not justified for a test and is expensive for the transmitted data. I remembered a simple laboratory work from the student's years on CMPP - visualization of the potential of a field with several charges. Extremely simple, you can calculate distributed.

')

Example to calculate


We have 5 positive and 5 negative charges, randomly scattered in a cube 5.12 by 5.12 by 5.12 meters. It is necessary to calculate the potential of the field in every centimeter of the cube. Everything is simple - for each centimeter we go over all charges and sum up the potential for that centimeter.

We have 512 layers of 512x512 cells. It took me 6 seconds to calculate one layer. On the whole field will take about an hour.

The size of the data

Let us need such an accuracy of calculations that as a result, every centimeter will be 4 bytes of data, the entire cube will occupy 512MB.

Visualization of the 300th layer

image

How can it work


The client loads a script containing the calculation module (model) and the I / O module, which in turn requests the state of the model and the task from the server.
The state of the model: the coordinates of all points and charges, the amount of space to calculate. Task: interval for calculation, for example, from 512 to 1024 cells (one row of a layer).
The client calculates 512 cells and sends this data to the server (2Kb of data). In response, he comes to a new task for the calculation. And so on.

To control, there must be a server issuing tasks for clients and receiving the results of calculations. The server has a queue of tasks for the calculation. Each task has a timeout after which it returns to the queue. The server saves data to the repository (file).
In total there will be 262,144 tasks for 512 cells - 262,144 data blocks of 2 KB each.

image

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


All Articles