Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process balancing in Erlang

Does anybody knows if there is a sort of 'load-balancer' in the erlang standard library? I mean, if I have some really simple operations on a really large set of data, the overhead of constructing a process for every item will be larger than perform the operation sequentially. But if I can balance the work in the 'right number' of process, it will perform better, so I'm basically asking if there is an easy way to accomplish this task.

By the way, does anybody knows if an OTP application does some kind of balance load? I mean, in an OTP application there is the concept of a "worker process" (like a java-ish thread worker)?

like image 224
cheng81 Avatar asked Dec 03 '22 16:12

cheng81


1 Answers

See modules pg2 and pool.

pg2 implements quite simple distributed process pool. pg2:get_closest_pid/1 returns "closest" pid, i.e. random local process if available, otherwise random remote process.

pool implements load balancing between nodes started with module slave.

like image 198
gleber Avatar answered Jan 11 '23 23:01

gleber