]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_lbmethod_byrequests.html.en
2009 -> 2010 in the copyright statement. Nobody seems to know if this is
[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.3</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.3</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 document is still under development.</p>
34 </div>
35 <div id="quickview"><h3 class="directives">Directives</h3>
36 <p>This module provides no
37             directives.</p>
38 <h3>Topics</h3>
39 <ul id="topics">
40 <li><img alt="" src="../images/down.gif" /> <a href="#requests">Request Counting Algorithm</a></li>
41 </ul><h3>See also</h3>
42 <ul class="seealso">
43 <li><code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></li>
44 <li><code class="module"><a href="../mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code></li>
45 </ul></div>
46 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
47 <div class="section">
48 <h2><a name="requests" id="requests">Request Counting Algorithm</a></h2>
49     
50     <p>Enabled via <code>lbmethod=byrequests</code>, the idea behind this
51     scheduler is that we distribute the requests among the
52     various workers to ensure that each gets their configured share
53     of the number of requests. It works as follows:</p>
54
55     <p><dfn>lbfactor</dfn> is <em>how much we expect this worker
56     to work</em>, or <em>the workers's work quota</em>. This is
57     a normalized value representing their "share" of the amount of
58     work to be done.</p>
59
60     <p><dfn>lbstatus</dfn> is <em>how urgent this worker has to work
61     to fulfill its quota of work</em>.</p>
62
63     <p>The <dfn>worker</dfn> is a member of the load balancer,
64     usually a remote host serving one of the supported protocols.</p>
65
66     <p>We distribute each worker's work quota to the worker, and then look
67     which of them needs to work most urgently (biggest lbstatus).  This
68     worker is then selected for work, and its lbstatus reduced by the
69     total work quota we distributed to all workers.  Thus the sum of all
70     lbstatus does not change(*) and we distribute the requests
71     as desired.</p>
72
73     <p>If some workers are disabled, the others will
74     still be scheduled correctly.</p>
75
76     <div class="example"><pre><code>for each worker in workers
77     worker lbstatus += worker lbfactor
78     total factor    += worker lbfactor
79     if worker lbstatus &gt; candidate lbstatus
80         candidate = worker
81
82 candidate lbstatus -= total factor</code></pre></div>
83
84     <p>If a balancer is configured as follows:</p>
85     
86     <table><tr><th>worker</th>
87         <th class="data">a</th>
88         <th class="data">b</th>
89         <th class="data">c</th>
90         <th class="data">d</th></tr>
91 <tr><th>lbfactor</th>
92         <td class="data">25</td>
93         <td class="data">25</td>
94         <td class="data">25</td>
95         <td class="data">25</td></tr>
96 <tr><th>lbstatus</th>
97         <td class="data">0</td>
98         <td class="data">0</td>
99         <td class="data">0</td>
100         <td class="data">0</td></tr>
101 </table>
102
103     <p>And <var>b</var> gets disabled, the following schedule is produced:</p>
104
105     <table><tr><th>worker</th>
106         <th class="data">a</th>
107         <th class="data">b</th>
108         <th class="data">c</th>
109         <th class="data">d</th></tr>
110 <tr><th>lbstatus</th>
111         <td class="data"><em>-50</em></td>
112         <td class="data">0</td>
113         <td class="data">25</td>
114         <td class="data">25</td></tr>
115 <tr><th>lbstatus</th>
116         <td class="data">-25</td>
117         <td class="data">0</td>
118         <td class="data"><em>-25</em></td>
119         <td class="data">50</td></tr>
120 <tr><th>lbstatus</th>
121         <td class="data">0</td>
122         <td class="data">0</td>
123         <td class="data">0</td>
124         <td class="data"><em>0</em></td></tr>
125 <tr><td class="data" colspan="5">(repeat)</td></tr>
126 </table>
127
128     <p>That is it schedules: <var>a</var> <var>c</var> <var>d</var>
129     <var>a</var> <var>c</var> <var>d</var> <var>a</var> <var>c</var>
130     <var>d</var> ... Please note that:</p>
131
132     <table><tr><th>worker</th>
133         <th class="data">a</th>
134         <th class="data">b</th>
135         <th class="data">c</th>
136         <th class="data">d</th></tr>
137 <tr><th>lbfactor</th>
138         <td class="data">25</td>
139         <td class="data">25</td>
140         <td class="data">25</td>
141         <td class="data">25</td></tr>
142 </table>
143
144     <p>Has the exact same behavior as:</p>
145
146     <table><tr><th>worker</th>
147         <th class="data">a</th>
148         <th class="data">b</th>
149         <th class="data">c</th>
150         <th class="data">d</th></tr>
151 <tr><th>lbfactor</th>
152         <td class="data">1</td>
153         <td class="data">1</td>
154         <td class="data">1</td>
155         <td class="data">1</td></tr>
156 </table>
157
158     <p>This is because all values of <dfn>lbfactor</dfn> are normalized
159     with respect to the others. For:</p>
160
161     <table><tr><th>worker</th>
162         <th class="data">a</th>
163         <th class="data">b</th>
164         <th class="data">c</th></tr>
165 <tr><th>lbfactor</th>
166         <td class="data">1</td>
167         <td class="data">4</td>
168         <td class="data">1</td></tr>
169 </table>
170
171     <p>worker <var>b</var> will, on average, get 4 times the requests
172     that <var>a</var> and <var>c</var> will.</p>
173
174     <p>The following asymmetric configuration works as one would expect:</p>
175
176     <table><tr><th>worker</th>
177         <th class="data">a</th>
178         <th class="data">b</th></tr>
179 <tr><th>lbfactor</th>
180         <td class="data">70</td>
181         <td class="data">30</td></tr>
182 <tr><td class="data" colspan="2">&nbsp;</td></tr>
183 <tr><th>lbstatus</th>
184         <td class="data"><em>-30</em></td>
185         <td class="data">30</td></tr>
186 <tr><th>lbstatus</th>
187         <td class="data">40</td>
188         <td class="data"><em>-40</em></td></tr>
189 <tr><th>lbstatus</th>
190         <td class="data"><em>10</em></td>
191         <td class="data">-10</td></tr>
192 <tr><th>lbstatus</th>
193         <td class="data"><em>-20</em></td>
194         <td class="data">20</td></tr>
195 <tr><th>lbstatus</th>
196         <td class="data"><em>-50</em></td>
197         <td class="data">50</td></tr>
198 <tr><th>lbstatus</th>
199         <td class="data">20</td>
200         <td class="data"><em>-20</em></td></tr>
201 <tr><th>lbstatus</th>
202         <td class="data"><em>-10</em></td>
203         <td class="data">10</td></tr>
204 <tr><th>lbstatus</th>
205         <td class="data"><em>-40</em></td>
206         <td class="data">40</td></tr>
207 <tr><th>lbstatus</th>
208         <td class="data">30</td>
209         <td class="data"><em>-30</em></td></tr>
210 <tr><th>lbstatus</th>
211         <td class="data"><em>0</em></td>
212         <td class="data">0</td></tr>
213 <tr><td class="data" colspan="3">(repeat)</td></tr>
214 </table>
215
216     <p>That is after 10 schedules, the schedule repeats and 7 <var>a</var>
217     are selected with 3 <var>b</var> interspersed.</p>
218 </div>
219 </div>
220 <div class="bottomlang">
221 <p><span>Available Languages: </span><a href="../en/mod/mod_lbmethod_byrequests.html" title="English">&nbsp;en&nbsp;</a></p>
222 </div><div id="footer">
223 <p class="apache">Copyright 2010 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>
224 <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>
225 </body></html>