Mercurial > hg > nginx-site
diff xml/en/docs/stream/ngx_stream_upstream_module.xml @ 1450:f5b5eefc43cb
Updated commercial docs for the upcoming release.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 09 Apr 2015 19:18:54 +0300 |
parents | f5dcc23b214f |
children | e69e4dbcc760 |
line wrap: on
line diff
--- a/xml/en/docs/stream/ngx_stream_upstream_module.xml Wed Apr 08 13:56:52 2015 +0300 +++ b/xml/en/docs/stream/ngx_stream_upstream_module.xml Thu Apr 09 19:18:54 2015 +0300 @@ -9,7 +9,7 @@ <module name="Module ngx_stream_upstream_module" link="/en/docs/stream/ngx_stream_upstream_module.html" lang="en" - rev="4"> + rev="5"> <section id="summary"> @@ -34,17 +34,23 @@ <para> <example> +resolver 10.0.0.1; + upstream <emphasis>backend</emphasis> { + zone upstream_backend 64k; + hash $remote_addr consistent; server backend1.example.com:12345 weight=5; server 127.0.0.1:12345 max_fails=3 fail_timeout=30s; - server unix:/tmp/backend3; + server unix:/tmp/backend2; + server backend3.example.com:12345 resolve; } server { listen 12346; proxy_pass <emphasis>backend</emphasis>; + health_check; } </example> </para> @@ -72,7 +78,8 @@ upstream backend { server backend1.example.com:12345 weight=5; server 127.0.0.1:12345 max_fails=3 fail_timeout=30s; - server unix:/tmp/backend3; + server unix:/tmp/backend2; + server backend3.example.com:12345 resolve; server backup1.example.com:12345 backup; } @@ -179,6 +186,34 @@ Default value is zero, meaning there is no limit. </tag-desc> +<tag-name id="resolve"> +<literal>resolve</literal> +</tag-name> +<tag-desc> +monitors changes of the IP addresses +that correspond to a domain name of the server, +and automatically modifies the upstream configuration +without the need of restarting nginx (1.7.10). +<para> +In order for this parameter to work, +the <link doc="ngx_stream_core_module.xml" id="resolver"/> directive +must be specified in the +<link doc="ngx_stream_core_module.xml" id="stream"/> block. +Example: +<example> +stream { + resolver 10.0.0.1; + + upstream u { + zone ...; + ... + server example.com:12345 resolve; + } +} +</example> +</para> +</tag-desc> + <tag-name id="slow_start"> <literal>slow_start</literal>=<value>time</value> </tag-name> @@ -204,6 +239,27 @@ </directive> +<directive name="zone"> +<syntax><value>name</value> <value>size</value></syntax> +<default/> +<context>upstream</context> +<appeared-in>1.7.10</appeared-in> + +<para> +Defines the <value>name</value> and <value>size</value> of the shared +memory zone that keeps the group’s configuration and run-time state that are +shared between worker processes. +Such groups allow changing the group membership +or modifying the settings of a particular server +without the need of restarting nginx. +The configuration is accessible via a special location +handled by +<link doc="../http/ngx_http_upstream_conf_module.xml" id="upstream_conf"/>. +</para> + +</directive> + + <directive name="hash"> <syntax><value>key</value> [<literal>consistent</literal>]</syntax> <default/> @@ -253,6 +309,229 @@ </directive> + +<directive name="least_time"> +<syntax><literal>connect</literal> | + <literal>first_byte</literal> | + <literal>last_byte</literal></syntax> +<default/> +<context>upstream</context> +<appeared-in>1.7.11</appeared-in> + +<para> +Specifies that a group should use a load balancing method where a connection +is passed to the server with the least average time and +least number of active connections, taking into account weights of servers. +If there are several such servers, they are tried in turn using a +weighted round-robin balancing method. +</para> + +<para> +If the <literal>connect</literal> parameter is specified, +time to connect to the upstream server is used. +If the <literal>first_byte</literal> parameter is specified, +time to receive the first byte of data is used. +If the <literal>last_byte</literal> is specified, +time to receive the last byte of data is used. +</para> + +</directive> + + +<directive name="health_check"> +<syntax>[<value>parameters</value>]</syntax> +<default/> +<context>server</context> +<appeared-in>1.7.10</appeared-in> + +<para> +Enables periodic health checks of the servers in a +<link id="upstream">group</link>. +</para> + +<para> +The following optional parameters are supported: +<list type="tag"> + +<tag-name id="interval"> +<literal>interval</literal>=<value>time</value> +</tag-name> +<tag-desc> +sets the interval between two consecutive health checks, +by default, 5 seconds; +</tag-desc> + +<tag-name id="fails"> +<literal>fails</literal>=<value>number</value> +</tag-name> +<tag-desc> +sets the number of consecutive failed health checks of a particular server +after which this server will be considered unhealthy, +by default, 1; +</tag-desc> + +<tag-name id="passes"> +<literal>passes</literal>=<value>number</value> +</tag-name> +<tag-desc> +sets the number of consecutive passed health checks of a particular server +after which the server will be considered healthy, +by default, 1; +</tag-desc> + +<tag-name id="hc_match"> +<literal>match</literal>=<value>name</value> +</tag-name> +<tag-desc> +specifies the <literal>match</literal> block configuring the tests that a +successful connection should pass in order for a health check to pass; +by default, only the ability to connect to the server is checked. +</tag-desc> + +</list> +</para> + +<para> +For example, +<example> +server { + proxy_pass backend; + health_check; +} +</example> +will check the ability to connect to each +server in the <literal>backend</literal> group every five seconds. +When a connection to the server cannot be established, +the health check will fail, and the server will +be considered unhealthy. +Client connections are not passed to unhealthy servers. +</para> + +<para> +Health checks can also be configured to test data obtained from the server. +Tests are configured separately using the <link id="match"/> directive +and referenced in the <literal>match</literal> parameter. +</para> + +<para> +The server group must reside in the <link id="zone">shared memory</link>. +</para> + +<para> +If several health checks are defined for the same group of servers, +a single failure of any check will make the corresponding server be +considered unhealthy. +</para> + +</directive> + + +<directive name="health_check_timeout"> +<syntax><value>timeout</value></syntax> +<default>5s</default> +<context>stream</context> +<context>server</context> +<appeared-in>1.7.10</appeared-in> + +<para> +Overrides the +<link doc="ngx_stream_proxy_module.xml" id="proxy_timeout"/> +value for health checks. +</para> + +</directive> + + +<directive name="match"> +<syntax block="yes"><value>name</value> </syntax> +<default/> +<context>stream</context> +<appeared-in>1.7.10</appeared-in> + +<para> +Defines the named test set used to verify server responses to health checks. +</para> + +<para> +The following parameters can be configured: +<list type="tag"> + +<tag-name> +<literal>send</literal> <value>string</value>; +</tag-name> +<tag-desc> +sends a <value>string</value> to the server; +</tag-desc> + +<tag-name> +<literal>expect</literal> <literal>~</literal> <value>regexp</value>; +</tag-name> +<tag-desc> +a regular expression that the data obtained from the server should match. +The regular expression is specified with the preceding +“<literal>~*</literal>” modifier (for case-insensitive matching), or the +“<literal>~</literal>” modifier (for case-sensitive matching). +</tag-desc> + +</list> +</para> + +<para> +Health check is passed if: +<list type="bullet"> +<listitem> +the connection was successfully established; +</listitem> + +<listitem> +the <value>string</value> from the <literal>send</literal> parameter, +if specified, was sent; +</listitem> + +<listitem> +the data obtained from the server matched the regular expression +from the <literal>expect</literal> parameter, if specified; +</listitem> + +<listitem> +the time elapsed does not exceed the value specified +in the <link id="health_check_timeout"/> directive. +</listitem> + +</list> +</para> + +<para> +Example: +<example> +upstream backend { + zone upstream_backend 10m; + server 127.0.0.1:12345; +} + +match http { + send "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n"; + expect ~ "200 OK"; +} + +server { + listen 12346; + proxy_pass backend; + health_check match=http; +} +</example> +</para> + +<para> +<note> +Only the first +<link doc="ngx_stream_proxy_module.xml" id="proxy_upstream_buffer"/> +bytes of data obtained from the server are examined. +</note> +</para> + +</directive> + </section> </module>