]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_lbmethod_byrequests.html.en
rebuild
[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" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
12 <script src="../style/scripts/prettify.js" type="text/javascript">
13 </script>
14
15 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
16 <body>
17 <div id="page-header">
18 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
19 <p class="apache">Apache HTTP Server Version 2.5</p>
20 <img alt="" src="../images/feather.gif" /></div>
21 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
22 <div id="path">
23 <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>
24 <div id="page-content">
25 <div id="preamble"><h1>Apache Module mod_lbmethod_byrequests</h1>
26 <div class="toplang">
27 <p><span>Available Languages: </span><a href="../en/mod/mod_lbmethod_byrequests.html" title="English">&nbsp;en&nbsp;</a></p>
28 </div>
29 <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>
30 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
31 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>lbmethod_byrequests_module</td></tr>
32 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_lbmethod_byrequests.c</td></tr>
33 <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>
34 <h3>Summary</h3>
35
36 <p>This module does not provide any configuration directives of its own.
37 It requires the services of <code class="module"><a href="../mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code>, and
38 provides the <code>byrequests</code> load balancing method..</p>
39 </div>
40 <div id="quickview"><h3 class="directives">Directives</h3>
41 <p>This module provides no
42             directives.</p>
43 <h3>Topics</h3>
44 <ul id="topics">
45 <li><img alt="" src="../images/down.gif" /> <a href="#requests">Request Counting Algorithm</a></li>
46 </ul><h3>See also</h3>
47 <ul class="seealso">
48 <li><code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></li>
49 <li><code class="module"><a href="../mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code></li>
50 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
51 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
52 <div class="section">
53 <h2><a name="requests" id="requests">Request Counting Algorithm</a></h2>
54     
55     <p>Enabled via <code>lbmethod=byrequests</code>, the idea behind this
56     scheduler is that we distribute the requests among the
57     various workers to ensure that each gets their configured share
58     of the number of requests. It works as follows:</p>
59
60     <p><dfn>lbfactor</dfn> is <em>how much we expect this worker
61     to work</em>, or <em>the workers' work quota</em>. This is
62     a normalized value representing their "share" of the amount of
63     work to be done.</p>
64
65     <p><dfn>lbstatus</dfn> is <em>how urgent this worker has to work
66     to fulfill its quota of work</em>.</p>
67
68     <p>The <dfn>worker</dfn> is a member of the load balancer,
69     usually a remote host serving one of the supported protocols.</p>
70
71     <p>We distribute each worker's work quota to the worker, and then look
72     which of them needs to work most urgently (biggest lbstatus).  This
73     worker is then selected for work, and its lbstatus reduced by the
74     total work quota we distributed to all workers.  Thus the sum of all
75     lbstatus does not change(*) and we distribute the requests
76     as desired.</p>
77
78     <p>If some workers are disabled, the others will
79     still be scheduled correctly.</p>
80
81     <div class="example"><pre><code>for each worker in workers
82     worker lbstatus += worker lbfactor
83     total factor    += worker lbfactor
84     if worker lbstatus &gt; candidate lbstatus
85         candidate = worker
86
87 candidate lbstatus -= total factor</code></pre></div>
88
89     <p>If a balancer is configured as follows:</p>
90
91     <table><tr><th>worker</th>
92         <th class="data">a</th>
93         <th class="data">b</th>
94         <th class="data">c</th>
95         <th class="data">d</th></tr>
96 <tr><th>lbfactor</th>
97         <td class="data">25</td>
98         <td class="data">25</td>
99         <td class="data">25</td>
100         <td class="data">25</td></tr>
101 <tr><th>lbstatus</th>
102         <td class="data">0</td>
103         <td class="data">0</td>
104         <td class="data">0</td>
105         <td class="data">0</td></tr>
106 </table>
107
108     <p>And <var>b</var> gets disabled, the following schedule is produced:</p>
109
110     <table><tr><th>worker</th>
111         <th class="data">a</th>
112         <th class="data">b</th>
113         <th class="data">c</th>
114         <th class="data">d</th></tr>
115 <tr><th>lbstatus</th>
116         <td class="data"><em>-50</em></td>
117         <td class="data">0</td>
118         <td class="data">25</td>
119         <td class="data">25</td></tr>
120 <tr><th>lbstatus</th>
121         <td class="data">-25</td>
122         <td class="data">0</td>
123         <td class="data"><em>-25</em></td>
124         <td class="data">50</td></tr>
125 <tr><th>lbstatus</th>
126         <td class="data">0</td>
127         <td class="data">0</td>
128         <td class="data">0</td>
129         <td class="data"><em>0</em></td></tr>
130 <tr><td class="data" colspan="5">(repeat)</td></tr>
131 </table>
132
133     <p>That is it schedules: <var>a</var> <var>c</var> <var>d</var>
134     <var>a</var> <var>c</var> <var>d</var> <var>a</var> <var>c</var>
135     <var>d</var> ... Please note that:</p>
136
137     <table><tr><th>worker</th>
138         <th class="data">a</th>
139         <th class="data">b</th>
140         <th class="data">c</th>
141         <th class="data">d</th></tr>
142 <tr><th>lbfactor</th>
143         <td class="data">25</td>
144         <td class="data">25</td>
145         <td class="data">25</td>
146         <td class="data">25</td></tr>
147 </table>
148
149     <p>Has the exact same behavior as:</p>
150
151     <table><tr><th>worker</th>
152         <th class="data">a</th>
153         <th class="data">b</th>
154         <th class="data">c</th>
155         <th class="data">d</th></tr>
156 <tr><th>lbfactor</th>
157         <td class="data">1</td>
158         <td class="data">1</td>
159         <td class="data">1</td>
160         <td class="data">1</td></tr>
161 </table>
162
163     <p>This is because all values of <dfn>lbfactor</dfn> are normalized
164     with respect to the others. For:</p>
165
166     <table><tr><th>worker</th>
167         <th class="data">a</th>
168         <th class="data">b</th>
169         <th class="data">c</th></tr>
170 <tr><th>lbfactor</th>
171         <td class="data">1</td>
172         <td class="data">4</td>
173         <td class="data">1</td></tr>
174 </table>
175
176     <p>worker <var>b</var> will, on average, get 4 times the requests
177     that <var>a</var> and <var>c</var> will.</p>
178
179     <p>The following asymmetric configuration works as one would expect:</p>
180
181     <table><tr><th>worker</th>
182         <th class="data">a</th>
183         <th class="data">b</th></tr>
184 <tr><th>lbfactor</th>
185         <td class="data">70</td>
186         <td class="data">30</td></tr>
187 <tr><td class="data" colspan="2">&nbsp;</td></tr>
188 <tr><th>lbstatus</th>
189         <td class="data"><em>-30</em></td>
190         <td class="data">30</td></tr>
191 <tr><th>lbstatus</th>
192         <td class="data">40</td>
193         <td class="data"><em>-40</em></td></tr>
194 <tr><th>lbstatus</th>
195         <td class="data"><em>10</em></td>
196         <td class="data">-10</td></tr>
197 <tr><th>lbstatus</th>
198         <td class="data"><em>-20</em></td>
199         <td class="data">20</td></tr>
200 <tr><th>lbstatus</th>
201         <td class="data"><em>-50</em></td>
202         <td class="data">50</td></tr>
203 <tr><th>lbstatus</th>
204         <td class="data">20</td>
205         <td class="data"><em>-20</em></td></tr>
206 <tr><th>lbstatus</th>
207         <td class="data"><em>-10</em></td>
208         <td class="data">10</td></tr>
209 <tr><th>lbstatus</th>
210         <td class="data"><em>-40</em></td>
211         <td class="data">40</td></tr>
212 <tr><th>lbstatus</th>
213         <td class="data">30</td>
214         <td class="data"><em>-30</em></td></tr>
215 <tr><th>lbstatus</th>
216         <td class="data"><em>0</em></td>
217         <td class="data">0</td></tr>
218 <tr><td class="data" colspan="3">(repeat)</td></tr>
219 </table>
220
221     <p>That is after 10 schedules, the schedule repeats and 7 <var>a</var>
222     are selected with 3 <var>b</var> interspersed.</p>
223 </div>
224 </div>
225 <div class="bottomlang">
226 <p><span>Available Languages: </span><a href="../en/mod/mod_lbmethod_byrequests.html" title="English">&nbsp;en&nbsp;</a></p>
227 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>This section is experimental!</strong><br />Comments placed here should not be expected 
228 to last beyond the testing phase of this system, nor do we in any way guarantee that we'll read them.</div>
229 <script type="text/javascript"><!--//--><![CDATA[//><!--
230 var disqus_shortname = 'httpd';
231 var disqus_identifier = 'http://httpd.apache.org/docs/2.4/mod/mod_lbmethod_byrequests.html.en';
232 (function(w, d) {
233     var disabled = true;
234     if (w.location.hostname.toLowerCase() == "httpd.apache.org" && disabled !== true) {
235         d.write('<div id="disqus_thread"><\/div>');
236         var s = d.createElement('script');
237         s.type = 'text/javascript';
238         s.async = true;
239         s.src = 'http' + '://' + disqus_shortname + '.disqus.com/embed.js';
240         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
241     }
242     else {
243         d.write('<div id="disqus_thread">Comments are disabled for this page at the moment.<\/div>');
244     }
245 })(window, document);
246 //--><!]]></script></div><div id="footer">
247 <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>
248 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
249 if (typeof(prettyPrint) !== 'undefined') {
250     prettyPrint();
251 }
252 //--><!]]></script>
253 </body></html>