[erlang-questions] How to use "jobs": schedule tasks by core number

Michael Truog mjtruog@REDACTED
Sat Apr 14 10:20:10 CEST 2012


If you wanted to use CloudI (http://cloudi.org) for this, you would create an Erlang CloudI service, which uses the cloudi_job behavior.  The service would be started with the process count of 1.0 where 1.0 is a multiplier for the core count (really the active Erlang scheduler count) on the machine, since you seemed to imply that there were 8 cores that you wanted to utilize.  The assumption is that the tasks are event-triggered, from some event you control, otherwise, they could be manually triggered within the service's initialization.  To handle all 100 tasks, it would be simplest to send 100 separate messages to the same service name, where all 8 Erlang service processes have subscribed to a single service name.  That service name becomes the destination for all 100 asynchronous messages which just get queued up and processed.  The results can be retrieved or received (passive/active async messages are supported), or simply stored separately (such that the storage is
triggered from within the service, after the task is complete).

You might be looking for a simple example that is a minimal chunk of Erlang code, but I thought I should still suggest this as a way of benefiting off of existing code.

On 04/14/2012 12:44 AM, Max Lapshin wrote:
> Hi. I have 100 tasks to execute, each takes about 10 seconds and uses 1 core.
>
> I want them to run 8 simultaneously (by core number). What is the best way?
>
> I think that esl/jobs is right what I need: create some queue and let
> it schedule jobs. If yes, so can anyone share me a simple snippet of
> code, how to do it?
> I haven't found even any examples in google, only jobs source code,
> which is rather complicated.
>
> Next question will be: how to distribute these tasks among cluster?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>





More information about the erlang-questions mailing list