changeset 533:fb630c3c5039

Revamped the upstream documentation somewhat.
author Ruslan Ermilov <ru@nginx.com>
date Fri, 08 Jun 2012 19:05:36 +0000
parents 480a4cd56a6a
children 6761e05e5128
files xml/en/docs/http/ngx_http_upstream_module.xml xml/ru/docs/http/ngx_http_upstream_module.xml
diffstat 2 files changed, 284 insertions(+), 263 deletions(-) [+]
line wrap: on
line diff
--- a/xml/en/docs/http/ngx_http_upstream_module.xml	Fri Jun 08 15:03:42 2012 +0000
+++ b/xml/en/docs/http/ngx_http_upstream_module.xml	Fri Jun 08 19:05:36 2012 +0000
@@ -11,8 +11,9 @@
 <para>
 The <literal>ngx_http_upstream_module</literal> module
 allows to define groups of servers that can be referenced
-from the <link doc="ngx_http_proxy_module.xml" id="proxy_pass"/> and
-<link doc="ngx_http_fastcgi_module.xml" id="fastcgi_pass"/> directives.
+from the <link doc="ngx_http_proxy_module.xml" id="proxy_pass"/>,
+<link doc="ngx_http_fastcgi_module.xml" id="fastcgi_pass"/>, and
+<link doc="ngx_http_memcached_module.xml" id="memcached_pass"/> directives.
 </para>
 
 </section>
@@ -44,15 +45,147 @@
 
 <section id="directives" name="Directives">
 
+<directive name="upstream">
+<syntax block="yes"><value>name</value></syntax>
+<default/>
+<context>http</context>
+
+<para>
+Defines a group of servers.
+Servers can listen on different ports.
+In addition, servers listening on TCP and UNIX-domain sockets
+can be mixed.
+</para>
+
+<para>
+Example:
+<example>
+upstream backend {
+    server backend1.example.com weight=5;
+    server 127.0.0.1:8080       max_fails=3 fail_timeout=30s;
+    server unix:/tmp/backend3;
+}
+</example>
+</para>
+
+<para>
+By default, requests are distributed between servers using a
+weighted round-robin balancing method.
+In the above example, each 7 requests will be distributed as follows:
+5 requests to <literal>backend1.example.com</literal>
+and one request to each of second and third servers.
+If an error occurs when communicating with the server, a request will
+be passed to the next server, and so on until all of the functioning
+servers will be tried.
+If a successful response could not be obtained from any of the servers,
+the client will be returned the result of contacting the last server.
+</para>
+
+</directive>
+
+
+<directive name="server">
+<syntax><value>address</value> [<value>parameters</value>]</syntax>
+<default/>
+<context>upstream</context>
+
+<para>
+Defines an <value>address</value> and other <value>parameters</value>
+of the server.
+An address can be specified as a domain name or IP address,
+and an optional port, or as a UNIX-domain socket path
+specified after the “<literal>unix:</literal>” prefix.
+If port is not specified, the port 80 is used.
+A domain name that resolves to several IP addresses essentially defines
+multiple servers.
+</para>
+
+<para>
+The following parameters can be defined:
+<list type="tag">
+
+<tag-name><literal>weight</literal>=<value>number</value></tag-name>
+<tag-desc>
+sets a weight of the server, by default 1.
+</tag-desc>
+
+<tag-name><literal>max_fails</literal>=<value>number</value></tag-name>
+<tag-desc>
+sets a number of unsuccessful attempts to communicate with the server
+during a time set by the <literal>fail_timeout</literal> parameter
+after which it will be considered down for a period of time also set
+by the <literal>fail_timeout</literal> parameter.
+By default, the number of unsuccessful attempts is set to 1.
+A value of zero disables accounting of attempts.
+What is considered to be an unsuccessful attempt is configured by the
+<link doc="ngx_http_proxy_module.xml" id="proxy_next_upstream"/>,
+<link doc="ngx_http_fastcgi_module.xml" id="fastcgi_next_upstream"/>, and
+<link doc="ngx_http_memcached_module.xml" id="memcached_next_upstream"/>
+directives.
+The <literal>http_404</literal> state is not considered
+an unsuccessful attempt.
+</tag-desc>
+
+<tag-name><literal>fail_timeout</literal>=<value>time</value></tag-name>
+<tag-desc>
+sets
+<list type="bullet">
+
+<listitem>
+a time during which the specified number of unsuccessful attempts to
+communicate with the server should happen for the server to be
+considered down;
+</listitem>
+
+<listitem>
+and a period of time the server will be considered down.
+</listitem>
+
+</list>
+By default, timeout is set to 10 seconds.
+</tag-desc>
+
+<tag-name><literal>backup</literal></tag-name>
+<tag-desc>
+marks the server as a backup server.
+It will be passed requests when the primary servers are down.
+</tag-desc>
+
+<tag-name><literal>down</literal></tag-name>
+<tag-desc>
+marks the server as permanently down; used along with
+the <link id="ip_hash"/> directive.
+</tag-desc>
+
+</list>
+</para>
+
+<para>
+Example:
+<example>
+upstream backend {
+    server backend1.example.com     weight=5;
+    server 127.0.0.1:8080           max_fails=3 fail_timeout=30s;
+    server unix:/tmp/backend3;
+
+    server backup1.example.com:8080 backup;
+}
+</example>
+</para>
+
+</directive>
+
+
 <directive name="ip_hash">
 <syntax/>
 <default/>
 <context>upstream</context>
 
 <para>
-Specifies that a group should use a balancing method where requests
+Specifies that a group should use a load balancing method where requests
 are distributed between servers based on client IP addresses.
-A class C network containing the client IP address is used as a hashing key.
+The first three octets of the client IPv4 address
+are used as a hashing key.
 The method ensures that requests of the same client will always be
 passed to the same server except when this server is considered down
 in which case client requests will be passed to another server and
@@ -82,7 +215,7 @@
 <para>
 <note>
 Until version 1.3.1 it was not possible to specify a weight for
-servers using the <literal>ip_hash</literal> balancing method.
+servers using the <literal>ip_hash</literal> load balancing method.
 </note>
 </para>
 
@@ -196,13 +329,13 @@
 
 <para>
 <note>
-When using load balancer modules other than the default
+When using load balancer methods other than the default
 round-robin, it is necessary to activate them before
 the <literal>keepalive</literal> directive.
 </note>
 
 <note>
-SCGI and uwsgi protocols do not define keepalive connections.
+SCGI and uwsgi protocols do not have a notion of keepalive connections.
 </note>
 </para>
 
@@ -216,133 +349,11 @@
 <appeared-in>1.3.1</appeared-in>
 
 <para>
-Specifies that a group should use a balancing method where a request
+Specifies that a group should use a load balancing method where a request
 is passed to the server with the least number of active connections,
 taking into account weights of servers.
-If there are several such servers, they are tried in a
-weighted round-robin fashion.
-</para>
-
-</directive>
-
-
-<directive name="server">
-<syntax><value>name</value> [<value>parameters</value>]</syntax>
-<default/>
-<context>upstream</context>
-
-<para>
-Sets a <value>name</value> and other <value>parameters</value> of the server.
-A <value>name</value> can be a domain name, an address, a port, or a
-path of the UNIX-domain socket.
-If a domain name resolves to several addresses, all of them are used.
-<list type="tag">
-
-<tag-name><literal>weight</literal>=<value>number</value></tag-name>
-<tag-desc>
-sets a weight of the server, by default 1.
-</tag-desc>
-
-<tag-name><literal>max_fails</literal>=<value>number</value></tag-name>
-<tag-desc>
-sets a number of unsuccessful attempts to communicate with the server
-during a time set by the <literal>fail_timeout</literal> parameter
-after which it will be considered down for a period of time also set
-by the <literal>fail_timeout</literal> parameter.
-By default, the number of unsuccessful attempts is set to 1.
-A value of zero disables accounting of attempts.
-What is considered to be an unsuccessful attempt is configured by the
-<link doc="ngx_http_proxy_module.xml" id="proxy_next_upstream"/>
-and <link doc="ngx_http_fastcgi_module.xml" id="fastcgi_next_upstream"/>
-directives.
-The <literal>http_404</literal> state is not considered
-an unsuccessful attempt.
-</tag-desc>
-
-<tag-name><literal>fail_timeout</literal>=<value>time</value></tag-name>
-<tag-desc>
-sets
-<list type="bullet">
-
-<listitem>
-a time during which the specified number of unsuccessful attempts to
-communicate with the server should happen for the server to be
-considered down;
-</listitem>
-
-<listitem>
-and a period of time the server will be considered down.
-</listitem>
-
-</list>
-By default, timeout is set to 10 seconds.
-</tag-desc>
-
-<tag-name><literal>backup</literal></tag-name>
-<tag-desc>
-marks the server as a backup server.
-It will be passed requests when the primary servers are down.
-</tag-desc>
-
-<tag-name><literal>down</literal></tag-name>
-<tag-desc>
-marks the server as permanently down; used along with
-the <link id="ip_hash"/> directive.
-</tag-desc>
-
-</list>
-</para>
-
-<para>
-Example:
-<example>
-upstream backend {
-    server backend1.example.com     weight=5;
-    server 127.0.0.1:8080           max_fails=3 fail_timeout=30s;
-    server unix:/tmp/backend3;
-
-    server backup1.example.com:8080 backup;
-}
-</example>
-</para>
-
-</directive>
-
-
-<directive name="upstream">
-<syntax block="yes"><value>name</value></syntax>
-<default/>
-<context>http</context>
-
-<para>
-Defines a group of servers.
-Servers can listen on different ports.
-In addition, servers listening on TCP and UNIX-domain sockets
-can be used simultaneously.
-</para>
-
-<para>
-Example:
-<example>
-upstream backend {
-    server backend1.example.com weight=5;
-    server 127.0.0.1:8080       max_fails=3 fail_timeout=30s;
-    server unix:/tmp/backend3;
-}
-</example>
-</para>
-
-<para>
-Requests are distributed between servers in a
-weighted round-robin fashion.
-In the above example, each 7 requests will be distributed as follows:
-5 requests to <literal>backend1.example.com</literal>
-and one request to each of second and third servers.
-If an error occurs when communicating with the server, a request will
-be passed to the next server, and so on until all of the functioning
-servers will be tried.
-If a successful response could not be obtained from any of the servers,
-the client will be returned the result of contacting the last server.
+If there are several such servers, they are tried using a
+weighted round-robin balancing method.
 </para>
 
 </directive>
--- a/xml/ru/docs/http/ngx_http_upstream_module.xml	Fri Jun 08 15:03:42 2012 +0000
+++ b/xml/ru/docs/http/ngx_http_upstream_module.xml	Fri Jun 08 19:05:36 2012 +0000
@@ -12,8 +12,9 @@
 Модуль <literal>ngx_http_upstream_module</literal>
 позволяет описывать группы серверов,
 которые могут использоваться в директивах
-<link doc="ngx_http_proxy_module.xml" id="proxy_pass"/>
-и <link doc="ngx_http_fastcgi_module.xml" id="fastcgi_pass"/>.
+<link doc="ngx_http_proxy_module.xml" id="proxy_pass"/>,
+<link doc="ngx_http_fastcgi_module.xml" id="fastcgi_pass"/> и
+<link doc="ngx_http_memcached_module.xml" id="memcached_pass"/>.
 </para>
 
 </section>
@@ -45,16 +46,146 @@
 
 <section id="directives" name="Директивы">
 
+<directive name="upstream">
+<syntax block="yes"><value>название</value></syntax>
+<default/>
+<context>http</context>
+
+<para>
+Описывает группу серверов.
+Серверы могут слушать на разных портах.
+Кроме того, можно одновременно использовать серверы,
+слушающие на TCP- и UNIX-сокетах.
+</para>
+
+<para>
+Пример:
+<example>
+upstream backend {
+    server backend1.example.com weight=5;
+    server 127.0.0.1:8080       max_fails=3 fail_timeout=30s;
+    server unix:/tmp/backend3;
+}
+</example>
+</para>
+
+<para>
+По умолчанию запросы распределяются по серверам циклически
+(в режиме round-robin) с учётом весов серверов.
+В вышеприведённом примере каждые 7 запросов будут распределены так:
+5 запросов на <literal>backend1.example.com</literal>
+и по одному запросу на второй и третий серверы.
+Если при попытке работы с сервером произошла ошибка, то запрос будет
+передан следующему серверу, и так до тех пор, пока не будут опробованы
+все работающие серверы.
+Если не удастся получить успешный ответ
+ни от одного из серверов, то клиенту будет возвращён результат работы
+с последним сервером.
+</para>
+
+</directive>
+
+
+<directive name="server">
+<syntax><value>адрес</value> [<value>параметры</value>]</syntax>
+<default/>
+<context>upstream</context>
+
+<para>
+Задаёт <value>адрес</value> и другие <value>параметры</value>
+сервера.
+Адрес может быть указан в виде доменного имени или IP-адреса,
+и необязательного порта, или в виде пути UNIX-сокета, который
+указывается после префикса “<literal>unix:</literal>”.
+Если порт не указан, используется порт 80.
+Доменное имя, которому соответствует несколько IP-адресов,
+задаёт сразу несколько серверов.
+</para>
+
+<para>
+Могут быть заданы следующие параметры:
+<list type="tag">
+
+<tag-name><literal>weight</literal>=<value>число</value></tag-name>
+<tag-desc>
+задаёт вес сервера, по умолчанию 1.
+</tag-desc>
+
+<tag-name><literal>max_fails</literal>=<value>число</value></tag-name>
+<tag-desc>
+задаёт число неудачных попыток работы с сервером
+в течение времени, заданного параметром <literal>fail_timeout</literal>,
+после которого он считается неработающим, также в течение времени
+заданного параметром <literal>fail_timeout</literal>.
+По умолчанию число попыток устанавливается равным 1.
+Нулевое значение запрещает учёт попыток.
+Что считается неудачной попыткой, задаётся директивами
+<link doc="ngx_http_proxy_module.xml" id="proxy_next_upstream"/>,
+<link doc="ngx_http_fastcgi_module.xml" id="fastcgi_next_upstream"/> и
+<link doc="ngx_http_memcached_module.xml" id="memcached_next_upstream"/>.
+Состояние <literal>http_404</literal>
+не считается неудачной попыткой.
+</tag-desc>
+
+<tag-name><literal>fail_timeout</literal>=<value>время</value></tag-name>
+<tag-desc>
+задаёт
+<list type="bullet">
+
+<listitem>
+время, в течение которого должно произойти заданное число неудачных
+попыток работы с сервером для того, чтобы сервер считался неработающим;
+</listitem>
+
+<listitem>
+и время, в течение которого сервер будет считаться неработающим.
+</listitem>
+
+</list>
+По умолчанию таймаут равен 10 секундам.
+</tag-desc>
+
+<tag-name><literal>backup</literal></tag-name>
+<tag-desc>
+помечает сервер как запасной сервер.
+На него будут передаваться запросы в случае, если не работают основные серверы.
+</tag-desc>
+
+<tag-name><literal>down</literal></tag-name>
+<tag-desc>
+помечает сервер как постоянно неработающий; используется
+совместно с директивой <link id="ip_hash"/>.
+</tag-desc>
+
+</list>
+</para>
+
+<para>
+Пример:
+<example>
+upstream backend {
+    server backend1.example.com     weight=5;
+    server 127.0.0.1:8080           max_fails=3 fail_timeout=30s;
+    server unix:/tmp/backend3;
+
+    server backup1.example.com:8080 backup;
+}
+</example>
+</para>
+
+</directive>
+
+
 <directive name="ip_hash">
 <syntax/>
 <default/>
 <context>upstream</context>
 
 <para>
-Задаёт для группы метод распределения запросов по серверам
-на основе IP-адресов клиентов.
-В качестве ключа для хэширования используется сеть класса C,
-в которой находится адрес клиента.
+Задаёт для группы метод балансировки нагрузки, при котором запросы
+распределяются по серверам на основе IP-адресов клиентов.
+В качестве ключа для хэширования используются первые три
+октета IPv4-адреса клиента.
 Метод гарантирует, что запросы одного и того же клиента
 будут всегда передаваться на один и тот же сервер.
 Если же этот сервер будет считаться неработающим,
@@ -84,7 +215,7 @@
 
 <para>
 <note>
-До версии 1.3.1 для серверов, использующих метод распределения
+До версии 1.3.1 для серверов, использующих метод балансировки нагрузки
 <literal>ip_hash</literal>, нельзя было задать вес.
 </note>
 </para>
@@ -199,7 +330,7 @@
 
 <para>
 <note>
-При использовании модулей балансировки нагрузки, отличных
+При использовании методов балансировки нагрузки, отличных
 от стандартного round-robin, следует активировать их до
 директивы <literal>keepalive</literal>.
 </note>
@@ -219,8 +350,8 @@
 <appeared-in>1.3.1</appeared-in>
 
 <para>
-Задаёт для группы метод распределения запросов по серверам, при
-котором запрос передаётся серверу с наименьшим числом активных соединений,
+Задаёт для группы метод балансировки нагрузки, при котором запрос
+передаётся серверу с наименьшим числом активных соединений,
 с учётом весов серверов.
 Если подходит сразу несколько серверов, они выбираются циклически
 (в режиме round-robin) с учётом их весов.
@@ -228,127 +359,6 @@
 
 </directive>
 
-
-<directive name="server">
-<syntax><value>имя</value> [<value>параметры</value>]</syntax>
-<default/>
-<context>upstream</context>
-
-<para>
-Задаёт <value>имя</value> и другие <value>параметры</value> сервера.
-В качестве имени можно использовать доменное имя, адрес, порт или путь
-UNIX-сокета.
-Если доменному имени соответствует несколько адресов, то все они используются.
-<list type="tag">
-
-<tag-name><literal>weight</literal>=<value>число</value></tag-name>
-<tag-desc>
-задаёт вес сервера, по умолчанию 1.
-</tag-desc>
-
-<tag-name><literal>max_fails</literal>=<value>число</value></tag-name>
-<tag-desc>
-задаёт число неудачных попыток работы с сервером
-в течение времени, заданного параметром <literal>fail_timeout</literal>,
-после которого он считается неработающим, также в течение времени
-заданного параметром <literal>fail_timeout</literal>.
-По умолчанию число попыток устанавливается равным 1.
-Нулевое значение запрещает учёт попыток.
-Что считается неудачной попыткой, задаётся директивами
-<link doc="ngx_http_proxy_module.xml" id="proxy_next_upstream"/>
-и <link doc="ngx_http_fastcgi_module.xml" id="fastcgi_next_upstream"/>.
-Состояние <literal>http_404</literal>
-не считается неудачной попыткой.
-</tag-desc>
-
-<tag-name><literal>fail_timeout</literal>=<value>время</value></tag-name>
-<tag-desc>
-задаёт
-<list type="bullet">
-
-<listitem>
-время, в течение которого должно произойти заданное число неудачных
-попыток работы с сервером для того, чтобы сервер считался неработающим;
-</listitem>
-
-<listitem>
-и время, в течение которого сервер будет считаться неработающим.
-</listitem>
-
-</list>
-По умолчанию таймаут равен 10 секундам.
-</tag-desc>
-
-<tag-name><literal>backup</literal></tag-name>
-<tag-desc>
-помечает сервер как запасной сервер.
-На него будут передаваться запросы в случае, если не работают основные серверы.
-</tag-desc>
-
-<tag-name><literal>down</literal></tag-name>
-<tag-desc>
-помечает сервер как постоянно неработающий; используется
-совместно с директивой <link id="ip_hash"/>.
-</tag-desc>
-
-</list>
-</para>
-
-<para>
-Пример:
-<example>
-upstream backend {
-    server backend1.example.com     weight=5;
-    server 127.0.0.1:8080           max_fails=3 fail_timeout=30s;
-    server unix:/tmp/backend3;
-
-    server backup1.example.com:8080 backup;
-}
-</example>
-</para>
-
-</directive>
-
-
-<directive name="upstream">
-<syntax block="yes"><value>название</value></syntax>
-<default/>
-<context>http</context>
-
-<para>
-Описывает группу серверов.
-Серверы могут слушать на разных портах.
-Кроме того, можно одновременно использовать серверы,
-слушающие на TCP- и UNIX-сокетах.
-</para>
-
-<para>
-Пример:
-<example>
-upstream backend {
-    server backend1.example.com weight=5;
-    server 127.0.0.1:8080       max_fails=3 fail_timeout=30s;
-    server unix:/tmp/backend3;
-}
-</example>
-</para>
-
-<para>
-Запросы распределяются по серверам циклически (в режиме round-robin)
-с учётом весов серверов.
-В вышеприведённом примере каждые 7 запросов будут распределены так:
-5 запросов на <literal>backend1.example.com</literal>
-и по одному запросу на второй и третий серверы.
-Если при попытке работы с сервером произошла ошибка, то запрос будет
-передан следующему серверу, и так до тех пор, пока не будут опробованы
-все работающие серверы.
-Если не удастся получить успешный ответ
-ни от одного из серверов, то клиенту будет возвращён результат работы
-с последним сервером.
-</para>
-
-</directive>
-
 </section>