]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_lbmethod_byrequests.html.en
s/2011/2012/g
[apache] / docs / manual / mod / mod_lbmethod_byrequests.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5               This file is generated from xml source: DO NOT EDIT
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7       -->
8 <title>mod_lbmethod_byrequests - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
13 <body>
14 <div id="page-header">
15 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
16 <p class="apache">Apache HTTP Server Version 2.5</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
19 <div id="path">
20 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_lbmethod_byrequests</h1>
23 <div class="toplang">
24 <p><span>Available Languages: </span><a href="../en/mod/mod_lbmethod_byrequests.html" title="English">&nbsp;en&nbsp;</a></p>
25 </div>
26 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Request Counting load balancer scheduler algorithm for <code class="module"><a href="../mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code></td></tr>
27 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
28 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>lbmethod_byrequests_module</td></tr>
29 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_lbmethod_byrequests.c</td></tr>
30 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Split off from <code class="module"><a href="../mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code> in 2.3</td></tr></table>
31 <h3>Summary</h3>
32
33 <p>This module does not provide any configuration directives of its own.
34 It requires the services of <code class="module"><a href="../mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code>, and
35 provides the <code>byrequests</code> load balancing method..</p>
36 </div>
37 <div id="quickview"><h3 class="directives">Directives</h3>
38 <p>This module provides no
39             directives.</p>
40 <h3>Topics</h3>
41 <ul id="topics">
42 <li><img alt="" src="../images/down.gif" /> <a href="#requests">Request Counting Algorithm</a></li>
43 </ul><h3>See also</h3>
44 <ul class="seealso">
45 <li><code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></li>
46 <li><code class="module"><a href="../mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code></li>
47 </ul></div>
48 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
49 <div class="section">
50 <h2><a name="requests" id="requests">Request Counting Algorithm</a></h2>
51     
52     <p>Enabled via <code>lbmethod=byrequests</code>, the idea behind this
53     scheduler is that we distribute the requests among the
54     various workers to ensure that each gets their configured share
55     of the number of requests. It works as follows:</p>
56
57     <p><dfn>lbfactor</dfn> is <em>how much we expect this worker
58     to work</em>, or <em>the workers's work quota</em>. This is
59     a normalized value representing their "share" of the amount of
60     work to be done.</p>
61
62     <p><dfn>lbstatus</dfn> is <em>how urgent this worker has to work
63     to fulfill its quota of work</em>.</p>
64
65     <p>The <dfn>worker</dfn> is a member of the load balancer,
66     usually a remote host serving one of the supported protocols.</p>
67
68     <p>We distribute each worker's work quota to the worker, and then look
69     which of them needs to work most urgently (biggest lbstatus).  This
70     worker is then selected for work, and its lbstatus reduced by the
71     total work quota we distributed to all workers.  Thus the sum of all
72     lbstatus does not change(*) and we distribute the requests
73     as desired.</p>
74
75     <p>If some workers are disabled, the others will
76     still be scheduled correctly.</p>
77
78     <div class="example"><pre><code>for each worker in workers
79     worker lbstatus += worker lbfactor
80     total factor    += worker lbfactor
81     if worker lbstatus &gt; candidate lbstatus
82         candidate = worker
83
84 candidate lbstatus -= total factor</code></pre></div>
85
86     <p>If a balancer is configured as follows:</p>
87
88     <table><tr><th>worker</th>
89         <th class="data">a</th>
90         <th class="data">b</th>
91         <th class="data">c</th>
92         <th class="data">d</th></tr>
93 <tr><th>lbfactor</th>
94         <td class="data">25</td>
95         <td class="data">25</td>
96         <td class="data">25</td>
97         <td class="data">25</td></tr>
98 <tr><th>lbstatus</th>
99         <td class="data">0</td>
100         <td class="data">0</td>
101         <td class="data">0</td>
102         <td class="data">0</td></tr>
103 </table>
104
105     <p>And <var>b</var> gets disabled, the following schedule is produced:</p>
106
107     <table><tr><th>worker</th>
108         <th class="data">a</th>
109         <th class="data">b</th>
110         <th class="data">c</th>
111         <th class="data">d</th></tr>
112 <tr><th>lbstatus</th>
113         <td class="data"><em>-50</em></td>
114         <td class="data">0</td>
115         <td class="data">25</td>
116         <td class="data">25</td></tr>
117 <tr><th>lbstatus</th>
118         <td class="data">-25</td>
119         <td class="data">0</td>
120         <td class="data"><em>-25</em></td>
121         <td class="data">50</td></tr>
122 <tr><th>lbstatus</th>
123         <td class="data">0</td>
124         <td class="data">0</td>
125         <td class="data">0</td>
126         <td class="data"><em>0</em></td></tr>
127 <tr><td class="data" colspan="5">(repeat)</td></tr>
128 </table>
129
130     <p>That is it schedules: <var>a</var> <var>c</var> <var>d</var>
131     <var>a</var> <var>c</var> <var>d</var> <var>a</var> <var>c</var>
132     <var>d</var> ... Please note that:</p>
133
134     <table><tr><th>worker</th>
135         <th class="data">a</th>
136         <th class="data">b</th>
137         <th class="data">c</th>
138         <th class="data">d</th></tr>
139 <tr><th>lbfactor</th>
140         <td class="data">25</td>
141         <td class="data">25</td>
142         <td class="data">25</td>
143         <td class="data">25</td></tr>
144 </table>
145
146     <p>Has the exact same behavior as:</p>
147
148     <table><tr><th>worker</th>
149         <th class="data">a</th>
150         <th class="data">b</th>
151         <th class="data">c</th>
152         <th class="data">d</th></tr>
153 <tr><th>lbfactor</th>
154         <td class="data">1</td>
155         <td class="data">1</td>
156         <td class="data">1</td>
157         <td class="data">1</td></tr>
158 </table>
159
160     <p>This is because all values of <dfn>lbfactor</dfn> are normalized
161     with respect to the others. For:</p>
162
163     <table><tr><th>worker</th>
164         <th class="data">a</th>
165         <th class="data">b</th>
166         <th class="data">c</th></tr>
167 <tr><th>lbfactor</th>
168         <td class="data">1</td>
169         <td class="data">4</td>
170         <td class="data">1</td></tr>
171 </table>
172
173     <p>worker <var>b</var> will, on average, get 4 times the requests
174     that <var>a</var> and <var>c</var> will.</p>
175
176     <p>The following asymmetric configuration works as one would expect:</p>
177
178     <table><tr><th>worker</th>
179         <th class="data">a</th>
180         <th class="data">b</th></tr>
181 <tr><th>lbfactor</th>
182         <td class="data">70</td>
183         <td class="data">30</td></tr>
184 <tr><td class="data" colspan="2">&nbsp;</td></tr>
185 <tr><th>lbstatus</th>
186         <td class="data"><em>-30</em></td>
187         <td class="data">30</td></tr>
188 <tr><th>lbstatus</th>
189         <td class="data">40</td>
190         <td class="data"><em>-40</em></td></tr>
191 <tr><th>lbstatus</th>
192         <td class="data"><em>10</em></td>
193         <td class="data">-10</td></tr>
194 <tr><th>lbstatus</th>
195         <td class="data"><em>-20</em></td>
196         <td class="data">20</td></tr>
197 <tr><th>lbstatus</th>
198         <td class="data"><em>-50</em></td>
199         <td class="data">50</td></tr>
200 <tr><th>lbstatus</th>
201         <td class="data">20</td>
202         <td class="data"><em>-20</em></td></tr>
203 <tr><th>lbstatus</th>
204         <td class="data"><em>-10</em></td>
205         <td class="data">10</td></tr>
206 <tr><th>lbstatus</th>
207         <td class="data"><em>-40</em></td>
208         <td class="data">40</td></tr>
209 <tr><th>lbstatus</th>
210         <td class="data">30</td>
211         <td class="data"><em>-30</em></td></tr>
212 <tr><th>lbstatus</th>
213         <td class="data"><em>0</em></td>
214         <td class="data">0</td></tr>
215 <tr><td class="data" colspan="3">(repeat)</td></tr>
216 </table>
217
218     <p>That is after 10 schedules, the schedule repeats and 7 <var>a</var>
219     are selected with 3 <var>b</var> interspersed.</p>
220 </div>
221 </div>
222 <div class="bottomlang">
223 <p><span>Available Languages: </span><a href="../en/mod/mod_lbmethod_byrequests.html" title="English">&nbsp;en&nbsp;</a></p>
224 </div><div id="footer">
225 <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
226 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
227 </body></html>