| <?xml version="1.0" encoding="UTF-8" ?> | |
| <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd"> | |
| <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?> | |
| <!-- English Revision: 395228:1933739 (outdated) --> | |
| <!-- | |
| Licensed to the Apache Software Foundation (ASF) under one or more | |
| contributor license agreements. See the NOTICE file distributed with | |
| this work for additional information regarding copyright ownership. | |
| The ASF licenses this file to You under the Apache License, Version 2.0 | |
| (the "License"); you may not use this file except in compliance with | |
| the License. You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software | |
| distributed under the License is distributed on an "AS IS" BASIS, | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| See the License for the specific language governing permissions and | |
| limitations under the License. | |
| --> | |
| <modulesynopsis metafile="mod_proxy_balancer.xml.meta"> | |
| <name>mod_proxy_balancer</name> | |
| <description>負荷分散のための <module>mod_proxy</module> 拡張</description> | |
| <status>Extension</status> | |
| <sourcefile>mod_proxy_balancer.c</sourcefile> | |
| <identifier>proxy_balancer_module</identifier> | |
| <compatibility>2.1 以降</compatibility> | |
| <summary> | |
| <p>本モジュールには <module>mod_proxy</module> が<em>必要です</em>。 | |
| <code>HTTP</code>, <code>FTP</code> と <code>AJP13</code> | |
| プロトコルのロードバランス機能を持っています。</p> | |
| <p>ですから、 ロードバランスを有効にする場合 <module>mod_proxy</module> | |
| と <module>mod_proxy_balancer</module> がサーバに組み込まれて | |
| いなければいけません。</p> | |
| <note type="warning"><title>警告</title> | |
| <p><a href="mod_proxy.html#access" | |
| >安全なサーバにする</a>までプロクシ機能は有効にしないでください。 | |
| オープンプロキシサーバはあなた自身のネットワークにとっても、 | |
| インターネット全体にとっても危険です。</p> | |
| </note> | |
| </summary> | |
| <seealso><module>mod_proxy</module></seealso> | |
| <section id="scheduler"> | |
| <title>ロードバランサのスケジューラのアルゴリズム</title> | |
| <p>現時点では 2 種類のロードバランサスケジューラアルゴリズムから選べます。 | |
| リクエスト回数によるもの <transnote>Request Counting</transnote> | |
| と、トラフィック量によるもの <transnote>Weighted Traffic Counting</transnote> | |
| があります。バランサの設定 <code>lbmethod</code> 値で、どちらを使うか指定します。 | |
| 詳細は <directive module="mod_proxy">Proxy</directive> ディレクティブを | |
| 参照してください。</p> | |
| </section> | |
| <section id="requests"> | |
| <title>Request Counting アルゴリズム</title> | |
| <p><code>lbmethod=byrequests</code> で有効になります。 | |
| このスケジューラの背景にある考え方は、様々なワーカーがそれぞれ、 | |
| 設定されている分担リクエスト数をきちんと受け取れるように、 | |
| リクエストを扱うという考え方です。次のように動作します:</p> | |
| <p><dfn>lbfactor</dfn> は、<em>どの程度ワーカーに仕事を振るか</em> | |
| つまり<em>ワーカーのクオータ</em>を指します。この値は "分担" | |
| 量を表す正規化された値です。</p> | |
| <p><dfn>lbstatus</dfn> は、<em>ワーカーのクオータを満たすために | |
| どのぐらい急ぎで働かなければならないか</em>を指します。</p> | |
| <p><dfn>ワーカー</dfn>はロードバランサのメンバで、通常は、 | |
| サポートされるプロトコルのうちの一つを提供しているリモートホストです。 | |
| </p> | |
| <p>まず個々のワーカーにワーカークオータを割り振り、どのワーカーが最も急ぎで | |
| 働かなければならないか (lbstatus が最大のもの) を調べます。 | |
| 次に仕事をするようにこのワーカーを選択し、選択したワーカーの lbstatus | |
| を全体に割り振ったぶんだけ差し引きます。ですから、lbstatus の総量は | |
| 結果的に変化しません(*)し、リクエストは期待通りに分散されます。</p> | |
| <p>あるワーカーが無効になっても、他のものは正常にスケジュールされ続けます。 | |
| </p> | |
| <example><pre><code>for each worker in workers | |
| worker lbstatus += worker lbfactor | |
| total factor += worker lbfactor | |
| if worker lbstatus > candidate lbstatus | |
| candidate = worker | |
| candidate lbstatus -= total factor</code></pre> | |
| </example> | |
| <p>バランサを次のように設定した場合:</p> | |
| <table style="data"> | |
| <tr><th>worker</th> | |
| <th>a</th> | |
| <th>b</th> | |
| <th>c</th> | |
| <th>d</th></tr> | |
| <tr><th>lbfactor</th> | |
| <td>25</td> | |
| <td>25</td> | |
| <td>25</td> | |
| <td>25</td></tr> | |
| <tr><th>lbstatus</th> | |
| <td>0</td> | |
| <td>0</td> | |
| <td>0</td> | |
| <td>0</td></tr> | |
| </table> | |
| <p>そして <var>b</var> が無効になった場合、次のようなスケジュールが | |
| 行われます。</p> | |
| <table style="data"> | |
| <tr><th>worker</th> | |
| <th>a</th> | |
| <th>b</th> | |
| <th>c</th> | |
| <th>d</th></tr> | |
| <tr><th>lbstatus</th> | |
| <td><em>-50</em></td> | |
| <td>0</td> | |
| <td>25</td> | |
| <td>25</td></tr> | |
| <tr><th>lbstatus</th> | |
| <td>-25</td> | |
| <td>0</td> | |
| <td><em>-25</em></td> | |
| <td>50</td></tr> | |
| <tr><th>lbstatus</th> | |
| <td>0</td> | |
| <td>0</td> | |
| <td>0</td> | |
| <td><em>0</em></td></tr> | |
| <tr><td colspan="5">(repeat)</td></tr> | |
| </table> | |
| <p>つまりこのようにスケジュールされます: <var>a</var> <var>c</var> | |
| <var>d</var> <var>a</var> <var>c</var> <var>d</var> <var>a</var> | |
| <var>c</var> <var>d</var> ... 次の点に注意してください:</p> | |
| <table style="data"> | |
| <tr><th>worker</th> | |
| <th>a</th> | |
| <th>b</th> | |
| <th>c</th> | |
| <th>d</th></tr> | |
| <tr><th>lbfactor</th> | |
| <td>25</td> | |
| <td>25</td> | |
| <td>25</td> | |
| <td>25</td></tr> | |
| </table> | |
| <p>この挙動は、次の設定と全く同じになります:</p> | |
| <table style="data"> | |
| <tr><th>worker</th> | |
| <th>a</th> | |
| <th>b</th> | |
| <th>c</th> | |
| <th>d</th></tr> | |
| <tr><th>lbfactor</th> | |
| <td>1</td> | |
| <td>1</td> | |
| <td>1</td> | |
| <td>1</td></tr> | |
| </table> | |
| <p>This is because all values of <dfn>lbfactor</dfn> are normalized | |
| with respect to the others. For:</p> | |
| <p><dfn>lbfactor</dfn> は全て正規化されたもので、 | |
| 他との相対値だからです。次の設定では:</p> | |
| <table style="data"> | |
| <tr><th>worker</th> | |
| <th>a</th> | |
| <th>b</th> | |
| <th>c</th></tr> | |
| <tr><th>lbfactor</th> | |
| <td>1</td> | |
| <td>4</td> | |
| <td>1</td></tr> | |
| </table> | |
| <p>ワーカー <var>b</var> は、平均して、<var>a</var> と <var>c</var> | |
| の 4 倍の数のリクエストを受け持つことになります。</p> | |
| <p>次のような非対称な設定では、こうなると予想されるでしょう:</p> | |
| <table style="data"> | |
| <tr><th>worker</th> | |
| <th>a</th> | |
| <th>b</th></tr> | |
| <tr><th>lbfactor</th> | |
| <td>70</td> | |
| <td>30</td></tr> | |
| <tr><td colspan="2"> </td></tr> | |
| <tr><th>lbstatus</th> | |
| <td><em>-30</em></td> | |
| <td>30</td></tr> | |
| <tr><th>lbstatus</th> | |
| <td>40</td> | |
| <td><em>-40</em></td></tr> | |
| <tr><th>lbstatus</th> | |
| <td><em>10</em></td> | |
| <td>-10</td></tr> | |
| <tr><th>lbstatus</th> | |
| <td><em>-20</em></td> | |
| <td>20</td></tr> | |
| <tr><th>lbstatus</th> | |
| <td><em>-50</em></td> | |
| <td>50</td></tr> | |
| <tr><th>lbstatus</th> | |
| <td>20</td> | |
| <td><em>-20</em></td></tr> | |
| <tr><th>lbstatus</th> | |
| <td><em>-10</em></td> | |
| <td>10</td></tr> | |
| <tr><th>lbstatus</th> | |
| <td><em>-40</em></td> | |
| <td>40</td></tr> | |
| <tr><th>lbstatus</th> | |
| <td>30</td> | |
| <td><em>-30</em></td></tr> | |
| <tr><th>lbstatus</th> | |
| <td><em>0</em></td> | |
| <td>0</td></tr> | |
| <tr><td colspan="3">(repeat)</td></tr> | |
| </table> | |
| <p>スケジュールは 10 スケジュール後に繰り返され、<var>a</var> 7 回と | |
| <var>b</var> 3 回でまばらに選ばれます。</p> | |
| </section> | |
| <section id="traffic"> | |
| <title>Weighted Traffic Counting アルゴリズム</title> | |
| <p><code>lbmethod=bytraffic</code> で有効になります。 | |
| このスケジューラの背景にある考え方は、Request Counting | |
| と非常に似ていますが、次の違いがあります:</p> | |
| <p><dfn>lbfactor</dfn> は <em>どれだけのバイト数のトラフィック量を、 | |
| このワーカーに処理してもらいたいか</em> を表します。 | |
| この値も同様に正規化された値で、ワーカー全体のうちでの "分担" | |
| 量を表現しています。リクエスト数を単純に数える代わりに、 | |
| どれだけの転送量を処理したかを数えます。</p> | |
| <p>次のようにバランサを設定した場合:</p> | |
| <table style="data"> | |
| <tr><th>worker</th> | |
| <th>a</th> | |
| <th>b</th> | |
| <th>c</th></tr> | |
| <tr><th>lbfactor</th> | |
| <td>1</td> | |
| <td>2</td> | |
| <td>1</td></tr> | |
| </table> | |
| <p><var>b</var> には <var>a</var> や <var>c</var> の 2 倍 | |
| 処理してほしいということになります。 | |
| <var>b</var> は 2 倍の I/O を処理するという意味になり、 | |
| 2 倍のリクエスト数を処理するということにはなりません。 | |
| ですからリクエストとレスポンスのサイズが、 | |
| 重み付けと振り分けのアルゴリズムに効いています。</p> | |
| </section> | |
| <section id="enable"> | |
| <title>バランサマネージャのサポートを有効にする</title> | |
| <p>このモジュールは <module>mod_status</module> のサービスを | |
| <em>必要とします</em>。 | |
| バランサマネージャを使うと、バランサのメンバーの動的な更新が | |
| できます。バランサマネージャを使って、バランス係数 (lbfactor) | |
| を変更したり、メンバーを変更したり、特定のメンバーを | |
| オフラインモードにしたりできます。</p> | |
| <p>ですから、ロードバランサ管理機能を使いたければ、 | |
| <module>mod_status</module> と <module>mod_proxy_balancer</module> | |
| をサーバに組み込まなければなりません。</p> | |
| <p>foo.com ドメインのブラウザからロードバランサ管理機能を | |
| 使えるようにするには、次のようなコードを <code>httpd.conf</code> | |
| に追加します。</p> | |
| <example> | |
| <Location /balancer-manager><br /> | |
| SetHandler balancer-manager<br /> | |
| <br /> | |
| Order Deny,Allow<br /> | |
| Deny from all<br /> | |
| Allow from .foo.com<br /> | |
| </Location> | |
| </example> | |
| <p>こうすると、<code>http://your.server.name/balancer-manager</code> | |
| のページ経由で、ウェブブラウザからロードバランサマネージャに | |
| アクセスできるようになります。</p> | |
| </section> | |
| </modulesynopsis> |