File: overload.html

package info (click to toggle)
erlang-doc-html 1%3A10.b.1a-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 22,488 kB
  • ctags: 9,933
  • sloc: erlang: 505; ansic: 323; perl: 61; sh: 45; makefile: 39
file content (216 lines) | stat: -rw-r--r-- 5,822 bytes parent folder | download
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This document was generated using DocBuilder 3.3.2 -->
<HTML>
<HEAD>
  <TITLE>overload</TITLE>
  <SCRIPT type="text/javascript" src="../../../../doc/erlresolvelinks.js">
</SCRIPT>
  <STYLE TYPE="text/css">
<!--
    .REFBODY     { margin-left: 13mm }
    .REFTYPES    { margin-left: 8mm }
-->
  </STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF00FF"
      ALINK="#FF0000">
<!-- refpage -->
<CENTER>
<A HREF="http://www.erlang.se">
  <IMG BORDER=0 ALT="[Ericsson AB]" SRC="min_head.gif">
</A>
<H1>overload</H1>
</CENTER>

<H3>MODULE</H3>
<DIV CLASS=REFBODY>
overload
</DIV>

<H3>MODULE SUMMARY</H3>
<DIV CLASS=REFBODY>
An Overload Regulation Process
</DIV>

<H3>DESCRIPTION</H3>
<DIV CLASS=REFBODY>

<P><CODE>overload</CODE> is a process which indirectly regulates CPU
usage in the system. The idea is that a main application calls
the <CODE>request/0</CODE> function before starting a major job, and
proceeds with the job if the return value is positive; otherwise
the job must not be started.


<P><CODE>overload</CODE> is part of the <CODE>sasl</CODE> application, and all
configuration parameters are defined there.


<P>A set of two intensities are maintained, the <CODE>total
intensity</CODE> and the <CODE>accept intensity</CODE>. For that purpose
there are two configuration parameters, the <CODE>MaxIntensity</CODE>
and the <CODE>Weight</CODE> value (both are measured in 1/second).


<P> Then total and accept intensities are calculated as
follows. Assume that the time of the current call to
<CODE>request/0</CODE> is <CODE>T(n)</CODE>, and that the time of the
previous call was <CODE>T(n-1)</CODE>.


<P>
<UL>

<LI>
The current <CODE>total intensity</CODE>, denoted
         <CODE>TI(n)</CODE>, is calculated according to the formula,
         
        <BR>
<CODE>TI(n) = exp(-Weight*(T(n) - T(n-1)) * TI(n-1) + Weight</CODE>,
         
        <BR>
where <CODE>TI(n-1)</CODE> is the previous total intensity.
         
<BR>

</LI>


<LI>
The current <CODE>accept intensity</CODE>, denoted
        <CODE>AI(n)</CODE>, is determined by the formula,
         
        <BR>
<CODE>AI(n) = exp(-Weight*(T(n) - T(n-1)) * AI(n-1) + Weight</CODE>,
         
        <BR>
where <CODE>AI(n-1)</CODE> is the previous accept intensity,
         provided that the value of <CODE>exp(-Weight*(T(n) - T(n-1)) *
         AI(n-1)</CODE> is less than <CODE>MaxIntensity</CODE>; otherwise the
         value is
         
        <BR>
<CODE>AI(n) = exp(-Weight*(T(n) - T(n-1)) * AI(n-1)</CODE>.
         
<BR>

</LI>


</UL>

<P>The value of configuration parameter <CODE>Weight</CODE> controls the
speed with which the calculations of intensities will react to
changes in the underlying input intensity. The inverted value of
<CODE>Weight</CODE>,


<P><CODE>T = 1/Weight</CODE> 
<P>can be thought of as the &#34;time constant&#34;
of the intensity calculation formulas. For example, if <CODE>Weight =
0.1</CODE>, then a change in the underlying input intensity will be
reflected in the <CODE>total</CODE> and <CODE>accept intensities</CODE> within
approximately 10 seconds.


<P>The overload process defines one alarm, which it sets using
<CODE>alarm_handler:set_alarm(Alarm)</CODE>. <CODE>Alarm</CODE> is defined
as:


<P>
<DL>

<DT>
<CODE>{overload, []}</CODE>
</DT>

<DD>
This alarm is set when the current accept intensity exceeds
         <CODE>MaxIntensity</CODE>. 
         
<BR>

</DD>

</DL>

<P>A new overload alarm is not set until the current accept
intensity has fallen below <CODE>MaxIntensity</CODE>. To prevent the
overload process from generating a lot of set/reset alarms, the
alarm is not reset until the current accept intensity has fallen
below 75% of <CODE>MaxIntensity</CODE>, and it is not until then that
the alarm can be set again.



</DIV>

<H3>EXPORTS</H3>

<P><A NAME="request/0"><STRONG><CODE>request() -&#62; accept | reject</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY>

<P>Returns <CODE>accept</CODE> or <CODE>reject</CODE> depending on the
         current value of the accept intensity. 
<P>The application
         calling this function should be processed with the job in
         question if the return value is <CODE>accept</CODE>; otherwise it
         should not continue with that job.
         

</DIV>

<P><A NAME="get_overload_info/0"><STRONG><CODE>get_overload_info() -&#62; OverloadInfo</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>OverloadInfo = [{total_intensity, TotalIntensity},
         {accept_intensity, AcceptIntensity}, {max_intensity,
         MaxIntensity}, {weight, Weight}, {total_requests,
         TotalRequests}, {accepted_requests, AcceptedRequests}].</CODE></STRONG><BR>
<STRONG><CODE>TotalIntensity = float() &#62; 0</CODE></STRONG><BR>
<STRONG><CODE>AcceptIntensity = float() &#62; 0</CODE></STRONG><BR>
<STRONG><CODE>MaxIntensity = float() &#62; 0</CODE></STRONG><BR>
<STRONG><CODE>Weight = float() &#62; 0</CODE></STRONG><BR>
<STRONG><CODE>TotalRequests = integer()</CODE></STRONG><BR>
<STRONG><CODE>AcceptedRequests = integer()</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Returns the current total and accept intensities, the
         configuration parameters, and absolute counts of the total
         number of requests, and accepted number of requests (since
         the overload process was started).      

</DIV>

<H3>See Also</H3>
<DIV CLASS=REFBODY>

<P> alarm_handler(3), sasl(3)



</DIV>

<H3>AUTHORS</H3>
<DIV CLASS=REFBODY>
Martin Bjrklund - support@erlang.ericsson.se<BR>
Peter Hgfeldt - support@erlang.ericsson.se<BR>

</DIV>
<CENTER>
<HR>
<SMALL>sasl 2.0<BR>
Copyright &copy; 1991-2004
<A HREF="http://www.erlang.se">Ericsson AB</A><BR>
</SMALL>
</CENTER>
</BODY>
</HTML>