Skip to content

Commit 87b2d6b

Browse files
committed
Update readme
1 parent eac7934 commit 87b2d6b

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

README.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,83 @@
11
# ring_calculator
2-
Calculator to find optimal target n-vals for different ring ring configurations
2+
3+
Calculator to find optimal target n-vals for different ring configurations
4+
5+
# Build
6+
7+
```
8+
rebar3 compile
9+
```
10+
11+
# Use
12+
13+
Calculator can either be used as plugin or from Erlang shell.
14+
The idea is that you have a number of nodes to your proposal, think VMs in the cloud, but can also be Erlang nodes on your large machine.
15+
These nodes can be at different locations, where a location is something that could potentially go down with all the nodes on it.
16+
17+
The computed target n-val provides information about fault resistance against failing nodes,
18+
whereas the location n-val provides information about resistance against failing locations.
19+
20+
21+
## Erlang Shell
22+
23+
```bash
24+
$ rebar3 shell
25+
```
26+
27+
In the Erlang shell, use the function
28+
```erlang
29+
-spec nvals(RingSize :: pos_integer(), NrNodes :: pos_integer(), NrLocations :: pos_integer()) -> ok.
30+
```
31+
Where (for riak) the ring size is a power of 2. Typically number of nodes is at least as large as the number of locations.
32+
33+
```erlang
34+
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
35+
36+
Eshell V14.2.5 (press Ctrl+G to abort, type help(). for help)
37+
1> ring_calculator:nvals(32, 8, 4).
38+
........................................................x................
39+
Best solution:
40+
Target Nval 8
41+
Location val 4
42+
Config [2,2,2,2]
43+
Ring: A1 B1 C1 D1 A2 B2 C2 D2 A1 B1 C1 D1 A2 B2 C2 D2 A1 B1 C1 D1 A2 B2 C2 D2 A1 B1 C1 D1 A2 B2 C2 D2 (0 violations)
44+
ok
45+
46+
2> ring_calculator:nvals(32, 8, 3).
47+
........................................x
48+
Best solution:
49+
Target Nval 8
50+
Location val 2
51+
Config [4,4]
52+
Ring: A1 B1 A2 B2 A3 B3 A4 B4 A1 B1 A2 B2 A3 B3 A4 B4 A1 B1 A2 B2 A3 B3 A4 B4 A1 B1 A2 B2 A3 B3 A4 B4 (0 violations)
53+
ok
54+
```
55+
56+
With 8 nodes and 4 locations at your proposal, you can get a target n-val of 8 and a location nval of 4.
57+
That means that you can configure the system in such a way that you can loose 3 locations or 3 nodes and
58+
still have one copy of all data available. Moreover, you have enough additional nodes to act take over the role of the lost nodes.
59+
60+
## Rebar3 plugin
61+
62+
Add the plugin to your rebar config:
63+
64+
```erlang
65+
{project_plugins, [{ring_calculator, {git, "[email protected]:nhs-riak/ring_calculator.git", {branch, "main"}}}]}
66+
```
67+
68+
Then just call your plugin directly in an existing application:
69+
70+
```bash
71+
$ rebar3 ring_calculator
72+
```
73+
74+
```
75+
Usage: rebar3 ring_calculator [-s <ring_size>] [-n <nodes>]
76+
[-l <locations>] [-v <verbose>]
77+
78+
-s, --ring_size size of riak ring (default 64)
79+
-n, --nodes number of available riak nodes
80+
-l, --locations number of physical locations you can run the nodes on
81+
-v, --verbose print computation details
82+
```
83+

0 commit comments

Comments
 (0)