]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_lbmethod_byrequests.html.en
Merge in APR[-util] macros from branches/trunk-buildconf-noapr
[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 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
5 <!--
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7               This file is generated from xml source: DO NOT EDIT
8         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
9       -->
10 <title>mod_lbmethod_byrequests - Apache HTTP Server Version 2.5</title>
11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
13 <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" />
14 <script src="../style/scripts/prettify.min.js" type="text/javascript">
15 </script>
16
17 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
18 <body>
19 <div id="page-header">
20 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.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>
21 <p class="apache">Apache HTTP Server Version 2.5</p>
22 <img alt="" src="../images/feather.png" /></div>
23 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
24 <div id="path">
25 <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>
26 <div id="page-content">
27 <div id="preamble"><h1>Apache Module mod_lbmethod_byrequests</h1>
28 <div class="toplang">
29 <p><span>Available Languages: </span><a href="../en/mod/mod_lbmethod_byrequests.html" title="English">&nbsp;en&nbsp;</a> |
30 <a href="../fr/mod/mod_lbmethod_byrequests.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
31 </div>
32 <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>
33 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
34 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>lbmethod_byrequests_module</td></tr>
35 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_lbmethod_byrequests.c</td></tr>
36 <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>
37 <h3>Summary</h3>
38
39 <p>This module does not provide any configuration directives of its own.
40 It requires the services of <code class="module"><a href="../mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code>, and
41 provides the <code>byrequests</code> load balancing method..</p>
42 </div>
43 <div id="quickview"><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 class="directives">Directives</h3>
47 <p>This module provides no
48             directives.</p>
49 <h3>Bugfix checklist</h3><ul class="seealso"><li><a href="https://www.apache.org/dist/httpd/CHANGES_2.4">httpd changelog</a></li><li><a href="https://bz.apache.org/bugzilla/buglist.cgi?bug_status=__open__&amp;list_id=144532&amp;product=Apache%20httpd-2&amp;query_format=specific&amp;order=changeddate%20DESC%2Cpriority%2Cbug_severity&amp;component=mod_lbmethod_byrequests">Known issues</a></li><li><a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2&amp;component=mod_lbmethod_byrequests">Report a bug</a></li></ul><h3>See also</h3>
50 <ul class="seealso">
51 <li><code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code></li>
52 <li><code class="module"><a href="../mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code></li>
53 <li><a href="#comments_section">Comments</a></li></ul></div>
54 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
55 <div class="section">
56 <h2><a name="requests" id="requests">Request Counting Algorithm</a></h2>
57     
58     <p>Enabled via <code>lbmethod=byrequests</code>, the idea behind this
59     scheduler is that we distribute the requests among the
60     various workers to ensure that each gets their configured share
61     of the number of requests. It works as follows:</p>
62
63     <p><dfn>lbfactor</dfn> is <em>how much we expect this worker
64     to work</em>, or <em>the workers' work quota</em>. This is
65     a normalized value representing their "share" of the amount of
66     work to be done.</p>
67
68     <p><dfn>lbstatus</dfn> is <em>how urgent this worker has to work
69     to fulfill its quota of work</em>.</p>
70
71     <p>The <dfn>worker</dfn> is a member of the load balancer,
72     usually a remote host serving one of the supported protocols.</p>
73
74     <p>We distribute each worker's work quota to the worker, and then look
75     which of them needs to work most urgently (biggest lbstatus).  This
76     worker is then selected for work, and its lbstatus reduced by the
77     total work quota we distributed to all workers.  Thus the sum of all
78     lbstatus does not change(*) and we distribute the requests
79     as desired.</p>
80
81     <p>If some workers are disabled, the others will
82     still be scheduled correctly.</p>
83
84     <div class="example"><pre><code>for each worker in workers
85     worker lbstatus += worker lbfactor
86     total factor    += worker lbfactor
87     if worker lbstatus &gt; candidate lbstatus
88         candidate = worker
89
90 candidate lbstatus -= total factor</code></pre></div>
91
92     <p>If a balancer is configured as follows:</p>
93
94     <table><tr><th>worker</th>
95         <th class="data">a</th>
96         <th class="data">b</th>
97         <th class="data">c</th>
98         <th class="data">d</th></tr>
99 <tr><th>lbfactor</th>
100         <td class="data">25</td>
101         <td class="data">25</td>
102         <td class="data">25</td>
103         <td class="data">25</td></tr>
104 <tr><th>lbstatus</th>
105         <td class="data">0</td>
106         <td class="data">0</td>
107         <td class="data">0</td>
108         <td class="data">0</td></tr>
109 </table>
110
111     <p>And <var>b</var> gets disabled, the following schedule is produced:</p>
112
113     <table><tr><th>worker</th>
114         <th class="data">a</th>
115         <th class="data">b</th>
116         <th class="data">c</th>
117         <th class="data">d</th></tr>
118 <tr><th>lbstatus</th>
119         <td class="data"><em>-50</em></td>
120         <td class="data">0</td>
121         <td class="data">25</td>
122         <td class="data">25</td></tr>
123 <tr><th>lbstatus</th>
124         <td class="data">-25</td>
125         <td class="data">0</td>
126         <td class="data"><em>-25</em></td>
127         <td class="data">50</td></tr>
128 <tr><th>lbstatus</th>
129         <td class="data">0</td>
130         <td class="data">0</td>
131         <td class="data">0</td>
132         <td class="data"><em>0</em></td></tr>
133 <tr><td class="data" colspan="5">(repeat)</td></tr>
134 </table>
135
136     <p>That is it schedules: <var>a</var> <var>c</var> <var>d</var>
137     <var>a</var> <var>c</var> <var>d</var> <var>a</var> <var>c</var>
138     <var>d</var> ... Please note that:</p>
139
140     <table><tr><th>worker</th>
141         <th class="data">a</th>
142         <th class="data">b</th>
143         <th class="data">c</th>
144         <th class="data">d</th></tr>
145 <tr><th>lbfactor</th>
146         <td class="data">25</td>
147         <td class="data">25</td>
148         <td class="data">25</td>
149         <td class="data">25</td></tr>
150 </table>
151
152     <p>Has the exact same behavior as:</p>
153
154     <table><tr><th>worker</th>
155         <th class="data">a</th>
156         <th class="data">b</th>
157         <th class="data">c</th>
158         <th class="data">d</th></tr>
159 <tr><th>lbfactor</th>
160         <td class="data">1</td>
161         <td class="data">1</td>
162         <td class="data">1</td>
163         <td class="data">1</td></tr>
164 </table>
165
166     <p>This is because all values of <dfn>lbfactor</dfn> are normalized
167     with respect to the others. For:</p>
168
169     <table><tr><th>worker</th>
170         <th class="data">a</th>
171         <th class="data">b</th>
172         <th class="data">c</th></tr>
173 <tr><th>lbfactor</th>
174         <td class="data">1</td>
175         <td class="data">4</td>
176         <td class="data">1</td></tr>
177 </table>
178
179     <p>worker <var>b</var> will, on average, get 4 times the requests
180     that <var>a</var> and <var>c</var> will.</p>
181
182     <p>The following asymmetric configuration works as one would expect:</p>
183
184     <table><tr><th>worker</th>
185         <th class="data">a</th>
186         <th class="data">b</th></tr>
187 <tr><th>lbfactor</th>
188         <td class="data">70</td>
189         <td class="data">30</td></tr>
190 <tr><td class="data" colspan="2">&nbsp;</td></tr>
191 <tr><th>lbstatus</th>
192         <td class="data"><em>-30</em></td>
193         <td class="data">30</td></tr>
194 <tr><th>lbstatus</th>
195         <td class="data">40</td>
196         <td class="data"><em>-40</em></td></tr>
197 <tr><th>lbstatus</th>
198         <td class="data"><em>10</em></td>
199         <td class="data">-10</td></tr>
200 <tr><th>lbstatus</th>
201         <td class="data"><em>-20</em></td>
202         <td class="data">20</td></tr>
203 <tr><th>lbstatus</th>
204         <td class="data"><em>-50</em></td>
205         <td class="data">50</td></tr>
206 <tr><th>lbstatus</th>
207         <td class="data">20</td>
208         <td class="data"><em>-20</em></td></tr>
209 <tr><th>lbstatus</th>
210         <td class="data"><em>-10</em></td>
211         <td class="data">10</td></tr>
212 <tr><th>lbstatus</th>
213         <td class="data"><em>-40</em></td>
214         <td class="data">40</td></tr>
215 <tr><th>lbstatus</th>
216         <td class="data">30</td>
217         <td class="data"><em>-30</em></td></tr>
218 <tr><th>lbstatus</th>
219         <td class="data"><em>0</em></td>
220         <td class="data">0</td></tr>
221 <tr><td class="data" colspan="3">(repeat)</td></tr>
222 </table>
223
224     <p>That is after 10 schedules, the schedule repeats and 7 <var>a</var>
225     are selected with 3 <var>b</var> interspersed.</p>
226 </div>
227 </div>
228 <div class="bottomlang">
229 <p><span>Available Languages: </span><a href="../en/mod/mod_lbmethod_byrequests.html" title="English">&nbsp;en&nbsp;</a> |
230 <a href="../fr/mod/mod_lbmethod_byrequests.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
231 </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>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
232 <script type="text/javascript"><!--//--><![CDATA[//><!--
233 var comments_shortname = 'httpd';
234 var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_lbmethod_byrequests.html';
235 (function(w, d) {
236     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
237         d.write('<div id="comments_thread"><\/div>');
238         var s = d.createElement('script');
239         s.type = 'text/javascript';
240         s.async = true;
241         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
242         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
243     }
244     else {
245         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
246     }
247 })(window, document);
248 //--><!]]></script></div><div id="footer">
249 <p class="apache">Copyright 2017 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>
250 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.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[//><!--
251 if (typeof(prettyPrint) !== 'undefined') {
252     prettyPrint();
253 }
254 //--><!]]></script>
255 </body></html>