~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to proxy/mgmt2/stats/spec

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//-----------------------------------------------------------------------------
 
2
//
 
3
// Statistics Processor
 
4
//
 
5
// Last Update: 04/11/2001
 
6
//
 
7
//-----------------------------------------------------------------------------
 
8
 
 
9
//-----------------------------------------------------------------------------
 
10
// Design
 
11
//-----------------------------------------------------------------------------
 
12
 
 
13
This statistics processor is a Cougar II (Tsunami) feature. 
 
14
It is designed to replace the StatAggregate.cc and portion of WebOverview.cc 
 
15
for scalability, maintainability, and ability to customize reasons.
 
16
 
 
17
The statistics processor aggregate/calculate traffic server statistics based
 
18
on a XML-based configuration file. At the processor's initialization, the 
 
19
configuration file is read and parsed. Each set of calculation is then stored
 
20
as a C++ object, called StatObject; and each StatObject is linked into a list,
 
21
called StatObjectList.
 
22
 
 
23
The mgmt2/traffic_manager threads will invoke the StatObjectList->Eval() to
 
24
perform the statistics aggregation and calculation within its event loop. As
 
25
Eval() is call, each StatObject in StatObjectList is evaluated.
 
26
 
 
27
Recall: StatAggregate.cc aggregates/calculates/copies proxy.process.* TS
 
28
variables to proxy.node.* variables. Similarly, WebOverview.cc aggregate
 
29
proxy.node.* variables to their corresponding proxy.cluster.* variable.
 
30
 
 
31
So there are two types of calculations in the statistics processor: NodeEval
 
32
and ClusterEval. As their names imply, they aggregate node-based statistics
 
33
and clsuter-based statistics, respectively. We call the different basis of 
 
34
statistics aggregation as "scope". (See "Destination Attributes")
 
35
 
 
36
In the cluster-based statistics, the aggregation is further divided into two
 
37
types: sum and re-calculate. Sum refers calculating the proxy.cluster.* 
 
38
variable by simply summing all required proxy.node.* variables from nodes in
 
39
the cluster. Re-calculate refers to summing all proxy.nodes.* variables that 
 
40
are used in the process of calculation before performing the calculation. 
 
41
An analogy would be, summing all open connection in the cluster vs. the 
 
42
average hit rate in the cluster.
 
43
 
 
44
//-----------------------------------------------------------------------------
 
45
// Destination Attributes
 
46
//-----------------------------------------------------------------------------
 
47
        
 
48
        "scope" 
 
49
        - "node"
 
50
        - "cluster"
 
51
 
 
52
        "operation"
 
53
        - "sum"
 
54
                summing the corresponding node variable across all nodes in the cluster.
 
55
        - "re-calculate"
 
56
                
 
57
 
 
58
        "define"
 
59
        - "custom"
 
60
        - "built-in"
 
61
 
 
62
//-----------------------------------------------------------------------------
 
63
// Predefined Constants and Functions
 
64
//-----------------------------------------------------------------------------
 
65
        
 
66
        Predefined Constants
 
67
 
 
68
        . BYTES_TO_MB_SCALE (1/(1024*1024.0))
 
69
          - convert bytes to mega-bytes
 
70
 
 
71
        . MBIT_TO_KBIT_SCALE (1000.0)
 
72
          - convert mega-bits to kilo-bits
 
73
 
 
74
        . SECOND_TO_MILLISECOND_SCALE (1000.0)
 
75
          - convert seconds to milliseconds
 
76
 
 
77
        . PCT_TO_INTPCT_SCALE (100.0)
 
78
          - convert ratios to percentage
 
79
 
 
80
        . HRTIME_SECOND
 
81
          - converting milli-seconds to seconds
 
82
 
 
83
        . BYTES_TO_MBIT_SCALE (8/1000000.0)
 
84
          - convert bytes to mega-bits
 
85
 
 
86
        Predefined Functions
 
87
        . DIFFTIME
 
88
          - the number of milliseconds since last update. Usually used in 
 
89
        combination of HRTIME_SECOND which computes the number of seconds
 
90
        since last update.
 
91
 
 
92
//-----------------------------------------------------------------------------
 
93
// Unit test plan
 
94
//-----------------------------------------------------------------------------
 
95
 
 
96
The statistics processor is designed to replace StatAggregate.cc and part of
 
97
the WebOverview. The first thing to test StatProcessor is to comment the 
 
98
aggregateNodeRecords() and doClusterAg() calls from proxy/mgmt2/Main.cc.
 
99
 
 
100
The next step is to replace the above function calls with StatProcessor::
 
101
processStat().
 
102
 
 
103
This statistics processor is a rather complicated module in traffic manager.
 
104
Hence it can't be easily tested. We divided the test into multiple sections.
 
105
 
 
106
1) Node-based Simple Aggregation
 
107
        - simply performs those aggregation that are node-based and the aggregation
 
108
      is performed every time statProcess() is invoked.
 
109
          E.g.: hit rate = doc. hit / doc. served.
 
110
 
 
111
2) Node-based Time-Delta Aggregation
 
112
        - performs those aggregation that are node-based but the operation is only
 
113
      perform in a regular interval AND one of more variables in the 
 
114
      calculation is obtained by calculating the difference between the last
 
115
      updated value and the current value. E.g. average connections per second
 
116
      is calculated by subtracting the 10 seconds ago connection count from the
 
117
      current connection count and divide the quotient by 10.
 
118
 
 
119
Repeat the about 2 testes with cluster-based variables. So, we have, at least,
 
120
4 test cases.
 
121
 
 
122
Developing a PASS/FAIL unit test that will test the statistics processor is not 
 
123
cost-efficient. The approach we are going to use is to display the input value
 
124
and the output value before and after the calculation is done.
 
125
 
 
126
Let's subdivide the testes in two stages:
 
127
 
 
128
Stage 1 : Synthetic Data
 
129
------------------------
 
130
We control the testing environment by setting the input values. This will test
 
131
the correctness of the statistics processor in a controlled environment. PASS/
 
132
FAIL is determined by matching the input/output values.
 
133
 
 
134
Stage 2 : Load Data
 
135
-------------------
 
136
Submitting network traffic through traffic server with load tools like jtest and
 
137
ftest, dumps the statistics to a text file, periodically and examines the
 
138
resulting values
 
139
 
 
140
//-----------------------------------------------------------------------------
 
141
// For QA Engineer
 
142
//-----------------------------------------------------------------------------
 
143
The most concerning question for QA engineers is "how can I tell if the 
 
144
Statistics Processor is working correctly?"
 
145
 
 
146
Recall, the new Statistics Processor is meant to replace the StatAggregate.cc
 
147
and part of the WebOverview.cc. In essence, you should not see any apparent
 
148
change.
 
149
 
 
150
If you ever see a value of -9999.0 (or -9999), then there is an error in
 
151
computing that value.
 
152
 
 
153
 
 
154
<expr>
 
155
    - %d
 
156
    - %f
 
157
    - %k
 
158
 
 
159
<dst>
 
160
    - specifies the variable that stores that result value.
 
161
    - ATTRIBUTE: type
 
162
        built-in: variables that are built-in/defined in traffic server
 
163
        custom: variables that are introducted to be temporary storage or
 
164
                variables that are introdcuted by the client.
 
165
    - default attributes:
 
166
        type = built-in  
 
167
 
 
168
<src>
 
169
    - variable need to computer the <dst>
 
170
    - ATTRIBUTE: type
 
171
        node: this is a proxy.node.* variables
 
172
        cluster: the is a proxy.node.* variables but summing over all
 
173
                 nodes in the cluster.
 
174
    - default attributes:
 
175
        type = node
 
176
 
 
177
<min>
 
178
    - specifics what is the smallest possible value for <dst>. For values
 
179
      smaller than <min>, the <defualt> is used.
 
180
 
 
181
<max>
 
182
    - specifics what is the largest possible value for <dst>. For values
 
183
      larger than <max>, the <defualt> is used.
 
184
 
 
185
<default>
 
186
    - specifics what value to be assigned to <dst> is the result <dst>
 
187
      value is smaller then <min> or larger then <max>
 
188
 
 
189
RULES: (some of these are enfored by the DTD anyways)
 
190
- all operator and operand in <expr> MUST BE separated by a single space.
 
191
- the order of the tags matters
 
192
- the order of each entry matters
 
193
- each statistics entry has have at most 1 <dst>
 
194
 
 
195
 
 
196
DEFINED CONSTANT (in alphabetical order)
 
197
* _BYTES_TO_MB_SCALE
 
198
        * Origin: utils/WebMgmtUtils.h
 
199
        * Value:  (1/(1024*1024.0))
 
200
 
 
201
*  _HRTIME_SECOND
 
202
        * Origin:
 
203
        * Value: 
 
204
 
 
205
*  _MBIT_TO_KBIT_SCALE
 
206
        * Origin: utils/WebMgmtUtils.h
 
207
        * Value:  (1000.0);
 
208
 
 
209
*  _PCT_TO_INTPCT_SCALE
 
210
        * Origin: utils/WebMgmtUtils.h
 
211
        * Value:  (100.0);
 
212
 
 
213
*  _SECOND_TO_MILLISECOND_SCALE
 
214
        * Origin: utils/WebMgmtUtils.h
 
215
        * Value:  (1000.0);
 
216
 
 
217
 
 
218
            __DIFFTIME