Distributing things

Calum caluml@REDACTED
Sat Nov 7 19:53:04 CET 2009


I'm trying to get my head around Erlang, and I've decided to try to
take an existing program, and distribute it.
I'm using code from Joe's Erlang book which generates a prime of X
digits. On my laptop, anything over 500 digits takes a while.

If you have one a single node running the code, it just loops,
calculates, tests if it's a prime, and increments the number, and
repeats if it's not a prime.
It's the "is_prime" test that seems to take the time, so that's the
part I want to distribute.
I imagine if you have more than one node, you want to kick off "n"
is_prime tests, but of different values.

What is the best way of going about this? Is it to kick off n, and
wait for all to return before kicking off another n? This isn't so
good if one of the nodes takes a very long time to return, as the rest
are doing nothing.
Or have a "global" "next value" variable, and each node just gets the
next one when it's finished its current one?
What would be the best way of maintaining this "next value" variable?

How can I handle additional nodes "coming on line" as it's running?
How can I handle a node going offline in the middle of this?
Would you all just use the existing nodes() nodelist to do this, or
would you need to extend that in some way?

Is there a good tried and tested method of deciding how to break down
a large job of 1000000 small jobs into batches for n nodes?

Hope these questions makes sense to you,


More information about the erlang-questions mailing list