blob: 7b06f3438708f17ffdd6c2803a2b07c49e7a239b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
h1. erlbal
erlbal is an erlang load balancer.
h2. Balancer calls:
* start_bal/0 spawns a balancer.
* stop_bal/1 takes a balancer kills the balancer.
* list_servers/1 takes a balancer and returns a list of the servers it balances over.
h2. Server calls:
* start_server/2 takes a balancer, a node and a function and spawns a server on the node to serve the function.
* stop_server/2 takes a balancer and a server PID and stops the server and removes it from the balancer.
h2. Request calls:
* make_request/1 takes a balancer and returns the response from the server.
* make_request/2 takes a balancer and an argument and returns the response from the server.
h2. The function:
p. The function must take two lists, some arguments and some state.
p. It must return a tuple of {Return value, new state}.
h2. Info
p. The balancer round robins requests between erlang processes.
When it receives a request, it forwards it on to the next server in the round robin.
The server then runs the function with the argument passed to it and returns a response to the balancer.
The balancer forwards the response back to the requestor.
p. The function arg could be anything, so you can pass multiple args in a tuple or list, etc.
|