root / hbal.1 @ b0045e4d
History | View | Annotate | Download (14.3 kB)
1 |
.TH HBAL 1 2009-03-14 htools "Ganeti H-tools" |
---|---|
2 |
.SH NAME |
3 |
hbal \- Cluster balancer for Ganeti |
4 |
|
5 |
.SH SYNOPSIS |
6 |
.B hbal |
7 |
.B "[-C]" |
8 |
.B "[-p]" |
9 |
.B "[-o]" |
10 |
.B "-l" |
11 |
.BI "[ -m " cluster "]" |
12 |
.BI "[-n " nodes-file " ]" |
13 |
.BI "[ -i " instances-file "]" |
14 |
|
15 |
.B hbal |
16 |
.B --version |
17 |
|
18 |
.SH DESCRIPTION |
19 |
hbal is a cluster balancer that looks at the current state of the |
20 |
cluster (nodes with their total and free disk, memory, etc.) and |
21 |
instance placement and computes a series of steps designed to bring |
22 |
the cluster into a better state. |
23 |
|
24 |
The algorithm to do so is designed to be stable (i.e. it will give you |
25 |
the same results when restarting it from the middle of the solution) |
26 |
and reasonably fast. It is not, however, designed to be a perfect |
27 |
algorithm - it is possible to make it go into a corner from which it |
28 |
can find no improvement, because it only look one "step" ahead. |
29 |
|
30 |
By default, the program will show the solution incrementally as it is |
31 |
computed, in a somewhat cryptic format; for getting the actual Ganeti |
32 |
command list, use the \fB-C\fR option. |
33 |
|
34 |
.SS ALGORITHM |
35 |
|
36 |
The program works in independent steps; at each step, we compute the |
37 |
best instance move that lowers the cluster score. |
38 |
|
39 |
The possible move type for an instance are combinations of |
40 |
failover/migrate and replace-disks such that we change one of the |
41 |
instance nodes, and the other one remains (but possibly with changed |
42 |
role, e.g. from primary it becomes secondary). The list is: |
43 |
- failover (f) |
44 |
- replace secondary (r) |
45 |
- replace primary, a composite move (f, r, f) |
46 |
- failover and replace secondary, also composite (f, r) |
47 |
- replace secondary and failover, also composite (r, f) |
48 |
|
49 |
We don't do the only remaining possibility of replacing both nodes |
50 |
(r,f,r,f or the equivalent f,r,f,r) since these move needs an |
51 |
exhaustive search over both candidate primary and secondary nodes, and |
52 |
is O(n*n) in the number of nodes. Furthermore, it doesn't seems to |
53 |
give better scores but will result in more disk replacements. |
54 |
|
55 |
.SS CLUSTER SCORING |
56 |
|
57 |
As said before, the algorithm tries to minimise the cluster score at |
58 |
each step. Currently this score is computed as a sum of the following |
59 |
components: |
60 |
- coefficient of variance of the percent of free memory |
61 |
- coefficient of variance of the percent of reserved memory |
62 |
- coefficient of variance of the percent of free disk |
63 |
- percentage of nodes failing N+1 check |
64 |
|
65 |
The free memory and free disk values help ensure that all nodes are |
66 |
somewhat balanced in their resource usage. The reserved memory helps |
67 |
to ensure that nodes are somewhat balanced in holding secondary |
68 |
instances, and that no node keeps too much memory reserved for |
69 |
N+1. And finally, the N+1 percentage helps guide the algorithm towards |
70 |
eliminating N+1 failures, if possible. |
71 |
|
72 |
Except for the N+1 failures, we use the coefficient of variance since |
73 |
this brings the values into the same unit so to speak, and with a |
74 |
restrict domain of values (between zero and one). The percentage of |
75 |
N+1 failures, while also in this numeric range, doesn't actually has |
76 |
the same meaning, but it has shown to work well. |
77 |
|
78 |
The other alternative, using for N+1 checks the coefficient of |
79 |
variance of (N+1 fail=1, N+1 pass=0) across nodes could hint the |
80 |
algorithm to make more N+1 failures if most nodes are N+1 fail |
81 |
already. Since this (making N+1 failures) is not allowed by other |
82 |
rules of the algorithm, so the N+1 checks would simply not work |
83 |
anymore in this case. |
84 |
|
85 |
On a perfectly balanced cluster (all nodes the same size, all |
86 |
instances the same size and spread across the nodes equally), all |
87 |
values would be zero. This doesn't happen too often in practice :) |
88 |
|
89 |
.SS OTHER POSSIBLE METRICS |
90 |
|
91 |
It would be desirable to add more metrics to the algorithm, especially |
92 |
dynamically-computed metrics, such as: |
93 |
- CPU usage of instances, combined with VCPU versus PCPU count |
94 |
- Disk IO usage |
95 |
- Network IO |
96 |
|
97 |
.SH OPTIONS |
98 |
The options that can be passed to the program are as follows: |
99 |
.TP |
100 |
.B -C, --print-commands |
101 |
Print the command list at the end of the run. Without this, the |
102 |
program will only show a shorter, but cryptic output. |
103 |
.TP |
104 |
.B -p, --print-nodes |
105 |
Prints the before and after node status, in a format designed to allow |
106 |
the user to understand the node's most important parameters. |
107 |
|
108 |
The node list will contain these informations: |
109 |
- a character denoting the N+1 status of the node, with blank |
110 |
meaning pass and an asterisk ('*') meaning fail |
111 |
- the node name |
112 |
- the total node memory |
113 |
- the free node memory |
114 |
- the reserved node memory, which is the amount of free memory |
115 |
needed for N+1 compliance |
116 |
- total disk |
117 |
- free disk |
118 |
- number of primary instances |
119 |
- number of secondary instances |
120 |
- percent of free memory |
121 |
- percent of free disk |
122 |
|
123 |
.TP |
124 |
.B -o, --oneline |
125 |
Only shows a one-line output from the program, designed for the case |
126 |
when one wants to look at multiple clusters at once and check their |
127 |
status. |
128 |
|
129 |
The line will contain four fields: |
130 |
- initial cluster score |
131 |
- number of steps in the solution |
132 |
- final cluster score |
133 |
- improvement in the cluster score |
134 |
|
135 |
.TP |
136 |
.BI "-n" nodefile ", --nodes=" nodefile |
137 |
The name of the file holding node information (if not collecting via |
138 |
RAPI), instead of the default |
139 |
.I nodes |
140 |
file. |
141 |
|
142 |
.TP |
143 |
.BI "-i" instancefile ", --instances=" instancefile |
144 |
The name of the file holding instance information (if not collecting |
145 |
via RAPI), instead of the default |
146 |
.I instances |
147 |
file. |
148 |
|
149 |
.TP |
150 |
.BI "-m" cluster |
151 |
Collect data not from files but directly from the |
152 |
.I cluster |
153 |
given as an argument via RAPI. This work for both Ganeti 1.2 and |
154 |
Ganeti 2.0. |
155 |
|
156 |
.TP |
157 |
.BI "-l" N ", --max-length=" N |
158 |
Restrict the solution to this length. This can be used for example to |
159 |
automate the execution of the balancing. |
160 |
|
161 |
.TP |
162 |
.B -v, --verbose |
163 |
Increase the output verbosity. Each usage of this option will increase |
164 |
the verbosity (currently more than 2 doesn't make sense) from the |
165 |
default of zero. |
166 |
|
167 |
.TP |
168 |
.B -V, --version |
169 |
Just show the program version and exit. |
170 |
|
171 |
.SH EXIT STATUS |
172 |
|
173 |
The exist status of the command will be zero, unless for some reason |
174 |
the algorithm fatally failed (e.g. wrong node or instance data). |
175 |
|
176 |
.SH BUGS |
177 |
|
178 |
The program does not check its input data for consistency, and aborts |
179 |
with cryptic errors messages in this case. |
180 |
|
181 |
The algorithm is not perfect. |
182 |
|
183 |
The output format is not easily scriptable, and the program should |
184 |
feed moves directly into Ganeti (either via RAPI or via a gnt-debug |
185 |
input file). |
186 |
|
187 |
.SH EXAMPLE |
188 |
|
189 |
.SS Default output |
190 |
|
191 |
With the default options, the program shows each individual step and |
192 |
the improvements it brings in cluster score: |
193 |
|
194 |
.in +4n |
195 |
.nf |
196 |
.RB "$" " hbal" |
197 |
Loaded 20 nodes, 80 instances |
198 |
Cluster is not N+1 happy, continuing but no guarantee that the cluster will end N+1 happy. |
199 |
Initial score: 0.52329131 |
200 |
Trying to minimize the CV... |
201 |
1. instance14 node1:node10 => node16:node10 0.42109120 a=f r:node16 f |
202 |
2. instance54 node4:node15 => node16:node15 0.31904594 a=f r:node16 f |
203 |
3. instance4 node5:node2 => node2:node16 0.26611015 a=f r:node16 |
204 |
4. instance48 node18:node20 => node2:node18 0.21361717 a=r:node2 f |
205 |
5. instance93 node19:node18 => node16:node19 0.16166425 a=r:node16 f |
206 |
6. instance89 node3:node20 => node2:node3 0.11005629 a=r:node2 f |
207 |
7. instance5 node6:node2 => node16:node6 0.05841589 a=r:node16 f |
208 |
8. instance94 node7:node20 => node20:node16 0.00658759 a=f r:node16 |
209 |
9. instance44 node20:node2 => node2:node15 0.00438740 a=f r:node15 |
210 |
10. instance62 node14:node18 => node14:node16 0.00390087 a=r:node16 |
211 |
11. instance13 node11:node14 => node11:node16 0.00361787 a=r:node16 |
212 |
12. instance19 node10:node11 => node10:node7 0.00336636 a=r:node7 |
213 |
13. instance43 node12:node13 => node12:node1 0.00305681 a=r:node1 |
214 |
14. instance1 node1:node2 => node1:node4 0.00263124 a=r:node4 |
215 |
15. instance58 node19:node20 => node19:node17 0.00252594 a=r:node17 |
216 |
Cluster score improved from 0.52329131 to 0.00252594 |
217 |
.fi |
218 |
.in |
219 |
|
220 |
In the above output, we can see: |
221 |
- the input data (here from files) shows a cluster with 20 nodes and |
222 |
80 instances |
223 |
- the cluster is not initially N+1 compliant |
224 |
- the initial score is 0.52329131 |
225 |
|
226 |
The step list follows, showing the instance, its initial |
227 |
primary/secondary nodes, the new primary secondary, the cluster list, |
228 |
and the actions taken in this step (with 'f' denoting failover/migrate |
229 |
and 'r' denoting replace secondary). |
230 |
|
231 |
Finally, the program shows the improvement in cluster score. |
232 |
|
233 |
A more detailed output is obtained via the \fB-C\fR and \fB-p\fR options: |
234 |
|
235 |
.in +4n |
236 |
.nf |
237 |
.RB "$" " hbal" |
238 |
Loaded 20 nodes, 80 instances |
239 |
Cluster is not N+1 happy, continuing but no guarantee that the cluster will end N+1 happy. |
240 |
Initial cluster status: |
241 |
N1 Name t_mem f_mem r_mem t_dsk f_dsk pri sec p_fmem p_fdsk |
242 |
* node1 32762 1280 6000 1861 1026 5 3 0.03907 0.55179 |
243 |
node2 32762 31280 12000 1861 1026 0 8 0.95476 0.55179 |
244 |
* node3 32762 1280 6000 1861 1026 5 3 0.03907 0.55179 |
245 |
* node4 32762 1280 6000 1861 1026 5 3 0.03907 0.55179 |
246 |
* node5 32762 1280 6000 1861 978 5 5 0.03907 0.52573 |
247 |
* node6 32762 1280 6000 1861 1026 5 3 0.03907 0.55179 |
248 |
* node7 32762 1280 6000 1861 1026 5 3 0.03907 0.55179 |
249 |
node8 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
250 |
node9 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
251 |
* node10 32762 7280 12000 1861 1026 4 4 0.22221 0.55179 |
252 |
node11 32762 7280 6000 1861 922 4 5 0.22221 0.49577 |
253 |
node12 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
254 |
node13 32762 7280 6000 1861 922 4 5 0.22221 0.49577 |
255 |
node14 32762 7280 6000 1861 922 4 5 0.22221 0.49577 |
256 |
* node15 32762 7280 12000 1861 1131 4 3 0.22221 0.60782 |
257 |
node16 32762 31280 0 1861 1860 0 0 0.95476 1.00000 |
258 |
node17 32762 7280 6000 1861 1106 5 3 0.22221 0.59479 |
259 |
* node18 32762 1280 6000 1396 561 5 3 0.03907 0.40239 |
260 |
* node19 32762 1280 6000 1861 1026 5 3 0.03907 0.55179 |
261 |
node20 32762 13280 12000 1861 689 3 9 0.40535 0.37068 |
262 |
|
263 |
Initial score: 0.52329131 |
264 |
Trying to minimize the CV... |
265 |
1. instance14 node1:node10 => node16:node10 0.42109120 a=f r:node16 f |
266 |
2. instance54 node4:node15 => node16:node15 0.31904594 a=f r:node16 f |
267 |
3. instance4 node5:node2 => node2:node16 0.26611015 a=f r:node16 |
268 |
4. instance48 node18:node20 => node2:node18 0.21361717 a=r:node2 f |
269 |
5. instance93 node19:node18 => node16:node19 0.16166425 a=r:node16 f |
270 |
6. instance89 node3:node20 => node2:node3 0.11005629 a=r:node2 f |
271 |
7. instance5 node6:node2 => node16:node6 0.05841589 a=r:node16 f |
272 |
8. instance94 node7:node20 => node20:node16 0.00658759 a=f r:node16 |
273 |
9. instance44 node20:node2 => node2:node15 0.00438740 a=f r:node15 |
274 |
10. instance62 node14:node18 => node14:node16 0.00390087 a=r:node16 |
275 |
11. instance13 node11:node14 => node11:node16 0.00361787 a=r:node16 |
276 |
12. instance19 node10:node11 => node10:node7 0.00336636 a=r:node7 |
277 |
13. instance43 node12:node13 => node12:node1 0.00305681 a=r:node1 |
278 |
14. instance1 node1:node2 => node1:node4 0.00263124 a=r:node4 |
279 |
15. instance58 node19:node20 => node19:node17 0.00252594 a=r:node17 |
280 |
Cluster score improved from 0.52329131 to 0.00252594 |
281 |
|
282 |
Commands to run to reach the above solution: |
283 |
echo step 1 |
284 |
echo gnt-instance migrate instance14 |
285 |
echo gnt-instance replace-disks -n node16 instance14 |
286 |
echo gnt-instance migrate instance14 |
287 |
echo step 2 |
288 |
echo gnt-instance migrate instance54 |
289 |
echo gnt-instance replace-disks -n node16 instance54 |
290 |
echo gnt-instance migrate instance54 |
291 |
echo step 3 |
292 |
echo gnt-instance migrate instance4 |
293 |
echo gnt-instance replace-disks -n node16 instance4 |
294 |
echo step 4 |
295 |
echo gnt-instance replace-disks -n node2 instance48 |
296 |
echo gnt-instance migrate instance48 |
297 |
echo step 5 |
298 |
echo gnt-instance replace-disks -n node16 instance93 |
299 |
echo gnt-instance migrate instance93 |
300 |
echo step 6 |
301 |
echo gnt-instance replace-disks -n node2 instance89 |
302 |
echo gnt-instance migrate instance89 |
303 |
echo step 7 |
304 |
echo gnt-instance replace-disks -n node16 instance5 |
305 |
echo gnt-instance migrate instance5 |
306 |
echo step 8 |
307 |
echo gnt-instance migrate instance94 |
308 |
echo gnt-instance replace-disks -n node16 instance94 |
309 |
echo step 9 |
310 |
echo gnt-instance migrate instance44 |
311 |
echo gnt-instance replace-disks -n node15 instance44 |
312 |
echo step 10 |
313 |
echo gnt-instance replace-disks -n node16 instance62 |
314 |
echo step 11 |
315 |
echo gnt-instance replace-disks -n node16 instance13 |
316 |
echo step 12 |
317 |
echo gnt-instance replace-disks -n node7 instance19 |
318 |
echo step 13 |
319 |
echo gnt-instance replace-disks -n node1 instance43 |
320 |
echo step 14 |
321 |
echo gnt-instance replace-disks -n node4 instance1 |
322 |
echo step 15 |
323 |
echo gnt-instance replace-disks -n node17 instance58 |
324 |
|
325 |
Final cluster status: |
326 |
N1 Name t_mem f_mem r_mem t_dsk f_dsk pri sec p_fmem p_fdsk |
327 |
node1 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
328 |
node2 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
329 |
node3 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
330 |
node4 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
331 |
node5 32762 7280 6000 1861 1078 4 5 0.22221 0.57947 |
332 |
node6 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
333 |
node7 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
334 |
node8 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
335 |
node9 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
336 |
node10 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
337 |
node11 32762 7280 6000 1861 1022 4 4 0.22221 0.54951 |
338 |
node12 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
339 |
node13 32762 7280 6000 1861 1022 4 4 0.22221 0.54951 |
340 |
node14 32762 7280 6000 1861 1022 4 4 0.22221 0.54951 |
341 |
node15 32762 7280 6000 1861 1031 4 4 0.22221 0.55408 |
342 |
node16 32762 7280 6000 1861 1060 4 4 0.22221 0.57007 |
343 |
node17 32762 7280 6000 1861 1006 5 4 0.22221 0.54105 |
344 |
node18 32762 7280 6000 1396 761 4 2 0.22221 0.54570 |
345 |
node19 32762 7280 6000 1861 1026 4 4 0.22221 0.55179 |
346 |
node20 32762 13280 6000 1861 1089 3 5 0.40535 0.58565 |
347 |
|
348 |
.fi |
349 |
.in |
350 |
|
351 |
Here we see, beside the step list, the initial and final cluster |
352 |
status, with the final one showing all nodes being N+1 compliant, and |
353 |
the command list to reach the final solution. In the initial listing, |
354 |
we see which nodes are not N+1 compliant. |
355 |
|
356 |
The algorithm is stable as long as each step above is fully completed, |
357 |
e.g. in step 8, both the migrate and the replace-disks are |
358 |
done. Otherwise, if only the migrate is done, the input data is |
359 |
changed in a way that the program will output a different solution |
360 |
list (but hopefully will end in the same state). |
361 |
|
362 |
.SH SEE ALSO |
363 |
hn1(1), ganeti(7), gnt-instance(8), gnt-node(8) |