Remove unused and obsolete function
[ganeti-local] / hbal.1
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 status of the node, with '-' meaning an
110     offline node, '*' meaning N+1 failure and blank meaning a good
111     node
112   - the node name
113   - the total node memory
114   - the memory used by the node itself
115   - the free node memory
116   - the reserved node memory, which is the amount of free memory
117     needed for N+1 compliance
118   - total disk
119   - free disk
120   - number of primary instances
121   - number of secondary instances
122   - percent of free memory
123   - percent of free disk
124
125 .TP
126 .B -o, --oneline
127 Only shows a one-line output from the program, designed for the case
128 when one wants to look at multiple clusters at once and check their
129 status.
130
131 The line will contain four fields:
132   - initial cluster score
133   - number of steps in the solution
134   - final cluster score
135   - improvement in the cluster score
136
137 .TP
138 .BI "-n" nodefile ", --nodes=" nodefile
139 The name of the file holding node information (if not collecting via
140 RAPI), instead of the default
141 .I nodes
142 file.
143
144 .TP
145 .BI "-i" instancefile ", --instances=" instancefile
146 The name of the file holding instance information (if not collecting
147 via RAPI), instead of the default
148 .I instances
149 file.
150
151 .TP
152 .BI "-m" cluster
153 Collect data not from files but directly from the
154 .I cluster
155 given as an argument via RAPI. This work for both Ganeti 1.2 and
156 Ganeti 2.0.
157
158 .TP
159 .BI "-l" N ", --max-length=" N
160 Restrict the solution to this length. This can be used for example to
161 automate the execution of the balancing.
162
163 .TP
164 .B -v, --verbose
165 Increase the output verbosity. Each usage of this option will increase
166 the verbosity (currently more than 2 doesn't make sense) from the
167 default of zero.
168
169 .TP
170 .B -V, --version
171 Just show the program version and exit.
172
173 .SH EXIT STATUS
174
175 The exist status of the command will be zero, unless for some reason
176 the algorithm fatally failed (e.g. wrong node or instance data).
177
178 .SH BUGS
179
180 The program does not check its input data for consistency, and aborts
181 with cryptic errors messages in this case.
182
183 The algorithm is not perfect.
184
185 The output format is not easily scriptable, and the program should
186 feed moves directly into Ganeti (either via RAPI or via a gnt-debug
187 input file).
188
189 .SH EXAMPLE
190
191 .SS Default output
192
193 With the default options, the program shows each individual step and
194 the improvements it brings in cluster score:
195
196 .in +4n
197 .nf
198 .RB "$" " hbal"
199 Loaded 20 nodes, 80 instances
200 Cluster is not N+1 happy, continuing but no guarantee that the cluster will end N+1 happy.
201 Initial score: 0.52329131
202 Trying to minimize the CV...
203     1. instance14  node1:node10  => node16:node10 0.42109120 a=f r:node16 f
204     2. instance54  node4:node15  => node16:node15 0.31904594 a=f r:node16 f
205     3. instance4   node5:node2   => node2:node16  0.26611015 a=f r:node16
206     4. instance48  node18:node20 => node2:node18  0.21361717 a=r:node2 f
207     5. instance93  node19:node18 => node16:node19 0.16166425 a=r:node16 f
208     6. instance89  node3:node20  => node2:node3   0.11005629 a=r:node2 f
209     7. instance5   node6:node2   => node16:node6  0.05841589 a=r:node16 f
210     8. instance94  node7:node20  => node20:node16 0.00658759 a=f r:node16
211     9. instance44  node20:node2  => node2:node15  0.00438740 a=f r:node15
212    10. instance62  node14:node18 => node14:node16 0.00390087 a=r:node16
213    11. instance13  node11:node14 => node11:node16 0.00361787 a=r:node16
214    12. instance19  node10:node11 => node10:node7  0.00336636 a=r:node7
215    13. instance43  node12:node13 => node12:node1  0.00305681 a=r:node1
216    14. instance1   node1:node2   => node1:node4   0.00263124 a=r:node4
217    15. instance58  node19:node20 => node19:node17 0.00252594 a=r:node17
218 Cluster score improved from 0.52329131 to 0.00252594
219 .fi
220 .in
221
222 In the above output, we can see:
223   - the input data (here from files) shows a cluster with 20 nodes and
224     80 instances
225   - the cluster is not initially N+1 compliant
226   - the initial score is 0.52329131
227
228 The step list follows, showing the instance, its initial
229 primary/secondary nodes, the new primary secondary, the cluster list,
230 and the actions taken in this step (with 'f' denoting failover/migrate
231 and 'r' denoting replace secondary).
232
233 Finally, the program shows the improvement in cluster score.
234
235 A more detailed output is obtained via the \fB-C\fR and \fB-p\fR options:
236
237 .in +4n
238 .nf
239 .RB "$" " hbal"
240 Loaded 20 nodes, 80 instances
241 Cluster is not N+1 happy, continuing but no guarantee that the cluster will end N+1 happy.
242 Initial cluster status:
243 N1 Name   t_mem f_mem r_mem t_dsk f_dsk pri sec  p_fmem  p_fdsk
244  * node1  32762  1280  6000  1861  1026   5   3 0.03907 0.55179
245    node2  32762 31280 12000  1861  1026   0   8 0.95476 0.55179
246  * node3  32762  1280  6000  1861  1026   5   3 0.03907 0.55179
247  * node4  32762  1280  6000  1861  1026   5   3 0.03907 0.55179
248  * node5  32762  1280  6000  1861   978   5   5 0.03907 0.52573
249  * node6  32762  1280  6000  1861  1026   5   3 0.03907 0.55179
250  * node7  32762  1280  6000  1861  1026   5   3 0.03907 0.55179
251    node8  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
252    node9  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
253  * node10 32762  7280 12000  1861  1026   4   4 0.22221 0.55179
254    node11 32762  7280  6000  1861   922   4   5 0.22221 0.49577
255    node12 32762  7280  6000  1861  1026   4   4 0.22221 0.55179
256    node13 32762  7280  6000  1861   922   4   5 0.22221 0.49577
257    node14 32762  7280  6000  1861   922   4   5 0.22221 0.49577
258  * node15 32762  7280 12000  1861  1131   4   3 0.22221 0.60782
259    node16 32762 31280     0  1861  1860   0   0 0.95476 1.00000
260    node17 32762  7280  6000  1861  1106   5   3 0.22221 0.59479
261  * node18 32762  1280  6000  1396   561   5   3 0.03907 0.40239
262  * node19 32762  1280  6000  1861  1026   5   3 0.03907 0.55179
263    node20 32762 13280 12000  1861   689   3   9 0.40535 0.37068
264
265 Initial score: 0.52329131
266 Trying to minimize the CV...
267     1. instance14  node1:node10  => node16:node10 0.42109120 a=f r:node16 f
268     2. instance54  node4:node15  => node16:node15 0.31904594 a=f r:node16 f
269     3. instance4   node5:node2   => node2:node16  0.26611015 a=f r:node16
270     4. instance48  node18:node20 => node2:node18  0.21361717 a=r:node2 f
271     5. instance93  node19:node18 => node16:node19 0.16166425 a=r:node16 f
272     6. instance89  node3:node20  => node2:node3   0.11005629 a=r:node2 f
273     7. instance5   node6:node2   => node16:node6  0.05841589 a=r:node16 f
274     8. instance94  node7:node20  => node20:node16 0.00658759 a=f r:node16
275     9. instance44  node20:node2  => node2:node15  0.00438740 a=f r:node15
276    10. instance62  node14:node18 => node14:node16 0.00390087 a=r:node16
277    11. instance13  node11:node14 => node11:node16 0.00361787 a=r:node16
278    12. instance19  node10:node11 => node10:node7  0.00336636 a=r:node7
279    13. instance43  node12:node13 => node12:node1  0.00305681 a=r:node1
280    14. instance1   node1:node2   => node1:node4   0.00263124 a=r:node4
281    15. instance58  node19:node20 => node19:node17 0.00252594 a=r:node17
282 Cluster score improved from 0.52329131 to 0.00252594
283
284 Commands to run to reach the above solution:
285   echo step 1
286   echo gnt-instance migrate instance14
287   echo gnt-instance replace-disks -n node16 instance14
288   echo gnt-instance migrate instance14
289   echo step 2
290   echo gnt-instance migrate instance54
291   echo gnt-instance replace-disks -n node16 instance54
292   echo gnt-instance migrate instance54
293   echo step 3
294   echo gnt-instance migrate instance4
295   echo gnt-instance replace-disks -n node16 instance4
296   echo step 4
297   echo gnt-instance replace-disks -n node2 instance48
298   echo gnt-instance migrate instance48
299   echo step 5
300   echo gnt-instance replace-disks -n node16 instance93
301   echo gnt-instance migrate instance93
302   echo step 6
303   echo gnt-instance replace-disks -n node2 instance89
304   echo gnt-instance migrate instance89
305   echo step 7
306   echo gnt-instance replace-disks -n node16 instance5
307   echo gnt-instance migrate instance5
308   echo step 8
309   echo gnt-instance migrate instance94
310   echo gnt-instance replace-disks -n node16 instance94
311   echo step 9
312   echo gnt-instance migrate instance44
313   echo gnt-instance replace-disks -n node15 instance44
314   echo step 10
315   echo gnt-instance replace-disks -n node16 instance62
316   echo step 11
317   echo gnt-instance replace-disks -n node16 instance13
318   echo step 12
319   echo gnt-instance replace-disks -n node7 instance19
320   echo step 13
321   echo gnt-instance replace-disks -n node1 instance43
322   echo step 14
323   echo gnt-instance replace-disks -n node4 instance1
324   echo step 15
325   echo gnt-instance replace-disks -n node17 instance58
326
327 Final cluster status:
328 N1 Name   t_mem f_mem r_mem t_dsk f_dsk pri sec  p_fmem  p_fdsk
329    node1  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
330    node2  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
331    node3  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
332    node4  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
333    node5  32762  7280  6000  1861  1078   4   5 0.22221 0.57947
334    node6  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
335    node7  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
336    node8  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
337    node9  32762  7280  6000  1861  1026   4   4 0.22221 0.55179
338    node10 32762  7280  6000  1861  1026   4   4 0.22221 0.55179
339    node11 32762  7280  6000  1861  1022   4   4 0.22221 0.54951
340    node12 32762  7280  6000  1861  1026   4   4 0.22221 0.55179
341    node13 32762  7280  6000  1861  1022   4   4 0.22221 0.54951
342    node14 32762  7280  6000  1861  1022   4   4 0.22221 0.54951
343    node15 32762  7280  6000  1861  1031   4   4 0.22221 0.55408
344    node16 32762  7280  6000  1861  1060   4   4 0.22221 0.57007
345    node17 32762  7280  6000  1861  1006   5   4 0.22221 0.54105
346    node18 32762  7280  6000  1396   761   4   2 0.22221 0.54570
347    node19 32762  7280  6000  1861  1026   4   4 0.22221 0.55179
348    node20 32762 13280  6000  1861  1089   3   5 0.40535 0.58565
349
350 .fi
351 .in
352
353 Here we see, beside the step list, the initial and final cluster
354 status, with the final one showing all nodes being N+1 compliant, and
355 the command list to reach the final solution. In the initial listing,
356 we see which nodes are not N+1 compliant.
357
358 The algorithm is stable as long as each step above is fully completed,
359 e.g. in step 8, both the migrate and the replace-disks are
360 done. Otherwise, if only the migrate is done, the input data is
361 changed in a way that the program will output a different solution
362 list (but hopefully will end in the same state).
363
364 .SH SEE ALSO
365 hn1(1), ganeti(7), gnt-instance(8), gnt-node(8)