1pool(3) Erlang Module Definition pool(3)
2
3
4
6 pool - Load distribution facility.
7
9 This module can be used to run a set of Erlang nodes as a pool of com‐
10 putational processors. It is organized as a master and a set of slave
11 nodes and includes the following features:
12
13 * The slave nodes send regular reports to the master about their cur‐
14 rent load.
15
16 * Queries can be sent to the master to determine which node will have
17 the least load.
18
19 The BIF statistics(run_queue) is used for estimating future loads. It
20 returns the length of the queue of ready to run processes in the Erlang
21 runtime system.
22
23 The slave nodes are started with the slave(3) module. This effects ter‐
24 minal I/O, file I/O, and code loading.
25
26 If the master node fails, the entire pool exits.
27
29 attach(Node) -> already_attached | attached
30
31 Types:
32
33 Node = node()
34
35 Ensures that a pool master is running and includes Node in the
36 pool master's pool of nodes.
37
38 get_node() -> node()
39
40 Returns the node with the expected lowest future load.
41
42 get_nodes() -> [node()]
43
44 Returns a list of the current member nodes of the pool.
45
46 pspawn(Mod, Fun, Args) -> pid()
47
48 Types:
49
50 Mod = module()
51 Fun = atom()
52 Args = [term()]
53
54 Spawns a process on the pool node that is expected to have the
55 lowest future load.
56
57 pspawn_link(Mod, Fun, Args) -> pid()
58
59 Types:
60
61 Mod = module()
62 Fun = atom()
63 Args = [term()]
64
65 Spawns and links to a process on the pool node that is expected
66 to have the lowest future load.
67
68 start(Name) -> Nodes
69
70 start(Name, Args) -> Nodes
71
72 Types:
73
74 Name = atom()
75 Args = string()
76 Nodes = [node()]
77
78 Starts a new pool. The file .hosts.erlang is read to find host
79 names where the pool nodes can be started; see section Files.
80 The startup procedure fails if the file is not found.
81
82 The slave nodes are started with slave:start/2,3, passing along
83 Name and, if provided, Args. Name is used as the first part of
84 the node names, Args is used to specify command-line arguments.
85
86 Access rights must be set so that all nodes in the pool have the
87 authority to access each other.
88
89 The function is synchronous and all the nodes, and all the sys‐
90 tem servers, are running when it returns a value.
91
92 stop() -> stopped
93
94 Stops the pool and kills all the slave nodes.
95
97 .hosts.erlang is used to pick hosts where nodes can be started. For in‐
98 formation about format and location of this file, see
99 net_adm:host_file/0.
100
101 $HOME/.erlang.slave.out.HOST is used for all extra I/O that can come
102 from the slave nodes on standard I/O. If the startup procedure does not
103 work, this file can indicate the reason.
104
105
106
107Ericsson AB stdlib 3.17.2 pool(3)