| <?xml version="1.0"?> |
| <document> |
| <copyright> |
| Copyright 1999-2004 The Apache Software Foundation |
| |
| Licensed 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. |
| </copyright> |
| |
| <properties> |
| <title>Components</title> |
| |
| <author email="cmanolache@yahoo.com">Costin Manolache</author> |
| <author email="jfrederic.clere@fujitsu-siemens.com">Jean-Frederic Clere</author> |
| <author email="yoavs@apache.org">Yoav Shapira</author> |
| |
| <date>$Date$</date> |
| </properties> |
| |
| <section name="Intro"> |
| <p> |
| Each component instance has a name, that is used for configuration and at runtime. |
| Each component has a number of configurable properties. The following rules are used: |
| <ul> |
| <li>The name is composed from the type and a local part, separated with a ':' ( example: channel.unixsocket:/tmp/jk.socket ) </li> |
| <li>The 'type' consist of '.' and ascii characters. It is mapped to a JMX 'domain'. </li> |
| <li>The local part consists of ascii characters and .:/; |
| |
| <p> |
| Note that '=,' are not currently allowed - a future version may support the jmx syntax by using quotes to separate the local part from the property and value ( in .properties mode we must use '=' to separate the value from type, local name and property name ). |
| </p> |
| </li> |
| <li>The property is a simple name, with no dots. </li> |
| <li>A simple form of substitution is used in values, where $(property) will be replaced with a previously defined setting. If the property has ':' in it, it'll take the value from the object, if not it'll take the value from a global map. |
| </li> |
| </ul> |
| </p> |
| </section> |
| |
| <section name="Common properties"> |
| <p> |
| Common properties for all components |
| </p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>disabled</td> |
| <td>0 (false)</td> |
| <td>"disabled" state for the component, 1=true 0=false</td> |
| </tr> |
| <tr> |
| <td>debug</td> |
| <td>0 (false)</td> |
| <td>Debug level for the component, 0=disabled, 1..10 enabled. Higher levels |
| generate more debug information.</td> |
| </tr> |
| <tr> |
| <td>ver (short for, and formerly known as, version)</td> |
| <td>0</td> |
| <td>'Generation' of the component config. Important for runtime reconfiguration. |
| If you edit the config file or set the shmem properties, you need to also |
| upgrade the version of the modified component. The config layer will detect |
| the change and call the setter method.</td> |
| </tr> |
| </table> |
| </p> |
| </section> |
| |
| <section name="workerEnv"> |
| <p>This component represent the core jk2, it has the default logger for all other components. Is the central controller, it controls global properties |
| and provides access to all other objects</p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>logger</td> |
| <td>logger</td> |
| <td>Default loger used by jk2 components, can be changed in the config file, normally it defaults to "logger" the Alias for the default logger for the Server/platform.</td> |
| </tr> |
| <tr> |
| <td>sslEnable</td> |
| <td>1 (true)</td> |
| <td>Enable handling of SSL</td> |
| </tr> |
| <tr> |
| <td>timing</td> |
| <td>0</td> |
| <td>Will jk2 get request timing (needs APR?)</td> |
| </tr> |
| <tr> |
| <td>forwardKeySize</td> |
| <td>not set</td> |
| <td>Enable filling of javax.servlet.request.key_size</td> |
| </tr> |
| <tr> |
| <td>forwardURICompat</td> |
| <td>set</td> |
| <td>Pass the URI untouched.</td> |
| </tr> |
| <tr> |
| <td>forwardURICompatUnparsed</td> |
| <td>not set</td> |
| <td>Parse the URI until the '?'.</td> |
| </tr> |
| <tr> |
| <td>forwardURIEscaped</td> |
| <td>not set</td> |
| <td>Pass the URI escaped.</td> |
| </tr> |
| <tr> |
| <td>noRecoveryIfRequestSent</td> |
| <td>set</td> |
| <td>No recovery in LB mode if a Tomcat allready received the request.</td> |
| </tr> |
| <tr> |
| <td>noRecoveryIfHeaderSent</td> |
| <td>set</td> |
| <td>No recovery in LB mode if a Tomcat allready start to send reply to client.</td> |
| </tr> |
| </table> |
| </p> |
| <p>Only one of the forwardURI option could be used it replaces the default value.</p> |
| </section> |
| <section name="config"> |
| <p>The config component, hold the detail of the conifg system, such config file name, create global defines</p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>file</td> |
| <td>${serverRoot}/conf/workers2.properties</td> |
| <td>Location of the workers2.properties file</td> |
| </tr> |
| <tr> |
| <td>debug</td> |
| <td>0</td> |
| <td>Set the debug level of the config component</td> |
| </tr> |
| <tr> |
| <td>debugEnv</td> |
| <td>0</td> |
| <td>Set the debug level of the hidden env component </td> |
| </tr> |
| </table> |
| </p> |
| </section> |
| <section name="uriMap"/> |
| <section name="shm"> |
| <p>Shared memory descriptor</p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>file</td> |
| <td>No default value</td> |
| <td>Name of the file that will be mmapped to use as shared memory, If set to 'anonymous' use the anonymous shered memory</td> |
| </tr> |
| <tr> |
| <td>size</td> |
| <td>No default value</td> |
| <td>Deprecated. Size of the file.</td> |
| </tr> |
| <tr> |
| <td>slots</td> |
| <td>256</td> |
| <td>Number of shared memory slots. Set to the number of child processes</td> |
| </tr> |
| <tr> |
| <td>useMemory</td> |
| <td>0</td> |
| <td>Use process memory instead of shared memory. Useful for single child mpm's</td> |
| </tr> |
| </table> |
| </p> |
| </section> |
| <section name="uri"> |
| <p>A uri stores a pattern that is used |
| to match requests to workers, and asociated properties</p> |
| <p>If the uri name doesn't have a slash then it is considered as a virtual host |
| directive. Uri name can have a virtual host name and(or) port associated with. Format |
| of such a name is <b>hostname</b> or <b>hostname:port</b> where hostname |
| is virtual server name and the port is vitual server port number. The port number |
| is used only for the non default server ports.</p> |
| <p> |
| Special case is a default server named as <b>[uri:*]</b> that is used when the virtual |
| host cannot be found inside the configuration. All the uri directives not containing |
| host name belongs to this default server making global mappings. |
| </p> |
| <p> |
| Addition wild char scheme id <b>[uri:*:port]</b> that is used when you wish to |
| match any virtual host having specified (non-default) port number, like [uri:*:443]. |
| This will map all the virtual hosts no mather what is their name but that have port number 443. |
| </p> |
| <p> |
| The order how the host names are resolved is : |
| <ul> |
| <li>Exact host name and optional non default port number</li> |
| <li>Alias matching host name and port number</li> |
| <li>*:port if the port is other then default</li> |
| <li>Default server</li> |
| </ul> |
| </p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>group</td> |
| <td>lb:lb (The default loadbalancer)</td> |
| <td>Name of the tomcat group or worker that will process the request corresponding to the uri. This used |
| to be called 'worker'</td> |
| </tr> |
| <tr> |
| <td>context</td> |
| <td/> |
| <td>the context path for this uri component (webapp style).</td> |
| </tr> |
| <tr> |
| <td>servlet</td> |
| <td/> |
| <td>Servlet path for this mapping</td> |
| </tr> |
| <tr> |
| <td>alias</td> |
| <td/> |
| <td>server name alias. This setting should only be used for |
| host uris like [uri:myHost:myPort] ( i.e. no /) </td> |
| </tr> |
| </table> |
| </p> |
| </section> |
| <section name="vm"> |
| <p>Represents the JVM when used as inprocess container |
| </p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>JVM</td> |
| <td>(Autoguess)</td> |
| <td>JVM to use for this vm</td> |
| </tr> |
| <tr> |
| <td>OPT</td> |
| <td/> |
| <td>Option to pass to this vm, this is a multivalued property</td> |
| </tr> |
| <tr> |
| <td>classpath</td> |
| <td/> |
| <td>-Djava.class.path 0ption to pass to this vm, this is a multivalued property</td> |
| </tr> |
| </table> |
| </p> |
| </section> |
| <section name="channels"> |
| <p>A channel represents a transport protocol, connecting 2 |
| sides for RPC communication. The most common and standard is the tcp socket. |
| Other important channels are unix socket and jni</p> |
| <subsection name="channel.un"> |
| <p> |
| AF_UNIX socket. Only on UNIX like platform. These sockets are faster |
| than "normal" sockets but they are limited to the machine. |
| </p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>file</td> |
| <td>Name of socket</td> |
| <td>Name of the socket file (It is created by the Tomcat ChannelUn)</td> |
| </tr> |
| </table> |
| </p> |
| </subsection> |
| <subsection name="channel.socket"> |
| <p> |
| Defines a communication transport to a remote Servlet Engine. </p> |
| |
| <p>The name of the channels should be: channel.socket:HOST:PORT, where HOST and PORT are the |
| tomcat Ajp location. You could use other names and explicitely set HOST and PORT, but this |
| is discouraged. In most cases, you don't need to set any other config - just add a line like |
| [channel.socket:localhost:8009] and all other things will have good defaults. |
| </p> |
| <p> |
| NB: Starting with JK2 2.0.4, APR is mandatory and the channel.socket use APR (previously |
| called channel.apr). |
| </p> |
| <p> |
| Tomcat Engine must be set with jvmRoute="HOST:PORT", to match the default tomcatId of the channel. |
| </p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>port</td> |
| <td>extracted from the component name</td> |
| <td>Port where Tomcat is listening. It is automatically extracted from the name - you shouldn't have to specify it explicitely.</td> |
| </tr> |
| <tr> |
| <td>host</td> |
| <td>extracted from the component name</td> |
| <td>Remote host. You should use the name, no need to override it</td> |
| </tr> |
| <tr> |
| <td>graceful</td> |
| <td>0</td> |
| <td>If 1, only requests for existing sessions will be forwarded</td> |
| </tr> |
| <tr> |
| <td>keepalive</td> |
| <td>0</td> |
| <td>? </td> |
| </tr> |
| <tr> |
| <td>timeout</td> |
| <td>0 (infinite)</td> |
| <td>Socket timeout for sending and receiving</td> |
| </tr> |
| <tr> |
| <td>ndelay</td> |
| <td>0</td> |
| <td>If set to 1 Disables the Nagle algorithm for send coalescing</td> |
| </tr> |
| <tr> |
| <td>lb_factor</td> |
| <td>1</td> |
| <td>Load balancing factor to use. The lower the lb_factor the more often that tomcat will get requests but see |
| "level" below.</td> |
| </tr> |
| <tr> |
| <td>level</td> |
| <td>1</td> |
| <td>Worker Priority. Valid values are 0-3. The functioning workers with the lowest level |
| will be checked for the lowest lb_value, and if found will be run. The upper level workers are |
| only checked upon failure of all workers on ALL of the levels below them. This is very |
| useful for implementing failover withing a cluster. You could set the tomcat server local |
| on the same machine as the apache instance to level 0 and all of the other workers to level 1. |
| This would cause apache to only use the external tomcats when the local tomcat is down.</td> |
| </tr> |
| <tr> |
| <td>group</td> |
| <td>lb</td> |
| <td>loadbalanced groups to which this channel and the associated worker will be added, multivalued. You need to set it only if you have an advanced setup with multiple clusters.</td> |
| </tr> |
| <tr> |
| <td>tomcatId</td> |
| <td>Automatically set to the localname ( host:port )</td> |
| <td>Must match the JVM route on tomcat the server.xml Engine element, for load balancing</td> |
| </tr> |
| <tr> |
| <td>route</td> |
| <td>Automatically set to the localname ( host:port )</td> |
| <td>Same as tomcatId</td> |
| </tr> |
| </table> |
| </p> |
| </subsection> |
| <subsection name="channel.jni"> |
| <p>The jni channel, used if tomcat is started inprocess</p> |
| </subsection> |
| </section> |
| <section name="workers"> |
| <p> |
| For the moment 4 worker types are supported: worker.jni,ajp13,status,lb. |
| </p> |
| <subsection name="worker.jni"> |
| <p>worker used in inprocess, holds the details of the Tomcat class to startup, and parameters to pass</p> |
| <p>There are two predefined jni workers <b>onStartup</b> and <b>onShutdown</b>. Those two workers are executed |
| during startup and shutdown phase of the connector. Both must exists in the configuration to be able to start |
| and shutdown Tomcat. |
| </p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>class</td> |
| <td>org/apache/jk/apr/TomcatStarter</td> |
| <td>class that holds the main method called to start tomcat</td> |
| </tr> |
| <tr> |
| <td>ARG</td> |
| <td/> |
| <td>Arguments to pass to main method when called</td> |
| </tr> |
| <tr> |
| <td>stdout</td> |
| <td>NULL</td> |
| <td>file to redirect Standard output from the java process</td> |
| </tr> |
| <tr> |
| <td>stderr</td> |
| <td>NULL</td> |
| <td>file to redirect Standard output from the java process </td> |
| </tr> |
| </table> |
| </p> |
| </subsection> |
| <subsection name="ajp13"> |
| <p>Default worker. If a property is in both the worker and the channel, you only need to define it in one place. |
| The channel passes down the properties to its worker. (at least in the ajp13-channel.socket linkage)</p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>secretkey</td> |
| <td>NULL</td> |
| <td> |
| <b>Magic:</b> The secret key will be set automatically on the associated |
| worker. |
| </td> |
| </tr> |
| <tr> |
| <td>tomcatId</td> |
| <td>Automatically set to the localname ( host:port )</td> |
| <td>Must match the JVM route on the tomcat server.xml Engine element, for load balancing</td> |
| </tr> |
| <tr> |
| <td>route</td> |
| <td>Automatically set to the localname ( host:port )</td> |
| <td>Same as tomcatId</td> |
| </tr> |
| <tr> |
| <td>group</td> |
| <td>lb</td> |
| <td>loadbalanced groups to which this channel and the associated worker will be added, multivalued. You need to set it only if you have an advanced setup with multiple clusters.</td> |
| </tr> |
| <tr> |
| <td>lb_factor</td> |
| <td>1</td> |
| <td>Load balancing factor to use. The lower the lb_factor the more often that tomcat will get requests but see |
| "level" below.</td> |
| </tr> |
| <tr> |
| <td>level</td> |
| <td>1</td> |
| <td>Worker Priority. Valid values are 0-3. The functioning workers with the lowest level |
| will be checked for the lowest lb_value, and if found will be run. The upper level workers are |
| only checked upon failure of all workers on ALL of the levels below them. This is very |
| useful for implementing failover withing a cluster. You could set the tomcat server local |
| on the same machine as the apache instance to level 0 and all of the other workers to level 1. |
| This would cause apache to only use the external tomcats when the local tomcat is down.</td> |
| </tr> |
| <tr> |
| <td>channel</td> |
| <td/> |
| <td>Communication channel used by the worker. Use the full name of the channel (everything between the []'s).</td> |
| </tr> |
| <tr> |
| <td>max_connections</td> |
| <td>0 (unlimited)</td> |
| <td>Maximum number of currently used endpoints. |
| If the specified number is reached then the load balancer has the chance |
| to try another worker. This is very useful in situations when having multiple |
| servers and you wish to finer grade the lb_factor. |
| </td> |
| </tr> |
| <tr> |
| <td>connectTimeout</td> |
| <td>0 (no timeout)</td> |
| <td>With such timeout set, the web-server will send a CPING request just after physical connect to the remote Tomcat |
| and will wait for a CPONG reply for the connectTimeout milliseconds, a guarantee that the remote Tomcat is not hang. |
| Side effect, this round trip add a little delay at connection time and require a recent AJP13 implementation, |
| with support for CPING/CPONG command. |
| </td> |
| </tr> |
| <tr> |
| <td>replyTimeout</td> |
| <td>0 (no timeout)</td> |
| <td>With such timeout set, the web-server will wait for Tomcat reply to a forwarded request for replyTimeout milliseconds. |
| Another guarantee that the remote Tomcat is not hang. |
| Warning, if you have 'normal' long running processes on Tomcat side, you shouldn't use this feature to avoid |
| invalid errors reports or set the timeout accordingly. |
| </td> |
| </tr> |
| <tr> |
| <td>prepostTimeout</td> |
| <td>0 (no timeout)</td> |
| <td>With such timeout set, the web-server will send a CPING request just before forwarding the request to the remote Tomcat |
| and will wait for a CPONG reply for the prepostTimeout milliseconds, a guarantee that the remote Tomcat is not hang. |
| Side effect, this round trip add a little delay in forwarding request and require a recent AJP13 implementation, |
| with support for CPING/CPONG command. |
| </td> |
| </tr> |
| </table> |
| </p> |
| </subsection> |
| <subsection name="status"> |
| <p>An optional worker that outputs (HTML) pages with useful information to monitor JK2.</p> |
| <p>To create the worker, add a [status:] or [status:'a name'] section.</p> |
| <p>The status worker needs no 'local' name, although one can be used if desired.</p> |
| <p>To access the worker, add a [uri] section with the group= assigned to this worker.</p> |
| <p>The status worker has the following additional properties: |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>styleMode</td> |
| <td>0 (None)</td> |
| <td>Defines if or how the status worker will apply a Style Sheet to returned pages.</td> |
| </tr> |
| <tr> |
| <td>stylePath</td> |
| <td>NULL</td> |
| <td>For styleMode=2 or 3, where to find the Style Sheet file.</td> |
| </tr> |
| </table> |
| </p> |
| <p>The syleMode setting accepts the following values: |
| <table> |
| <tr> |
| <th>styleMode value</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>0</td> |
| <td>No Style settings are used. (Default)</td> |
| </tr> |
| <tr> |
| <td>1</td> |
| <td>Use the built-in Default Style Sheet. It is presented as an 'Internal Style Sheet' to HTML pages.</td> |
| </tr> |
| <tr> |
| <td>2</td> |
| <td>Use stylePath as a URI context to an external Style Sheet file to be returned by the Web Server.</td> |
| </tr> |
| <tr> |
| <td>3</td> |
| <td>Use stylePath as a file-system reference to a Style Sheet file. It is presented as an 'Internal Style |
| Sheet' to HTML pages.</td> |
| </tr> |
| </table> |
| </p> |
| <p>If the stylePath has not been set, styleMode=2 and 3 are ignored.</p> |
| <p>The sylePath setting accepts the following values: |
| <table> |
| <tr> |
| <th>styleMode value</th> |
| <th>stylePath Description</th> |
| </tr> |
| <tr> |
| <td>2</td> |
| <td>A URI context to a file (e.g /styles/jkstatus.css). It must begin with '/' and include the file name.</td> |
| </tr> |
| <tr> |
| <td>3</td> |
| <td>A file-system path (suitable for the OS in use) plus file name. Also ${serverRoot}/conf/'file name' |
| allows the file to be located in Apache's conf directory.</td> |
| </tr> |
| </table> |
| </p> |
| <p>If the Style file cannot be found, Mode 2 and 3 record Apache log entries.</p> |
| <p>For styleMode=2 and 3, changes in the Style Sheet are effective on the next access to the status worker.</p> |
| </subsection> |
| <subsection name="lb"> |
| <p>Loadbalanced worker</p> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>worker</td> |
| <td/> |
| <td/> |
| </tr> |
| <tr> |
| <td>noErrorHeader</td> |
| <td>1 (true)</td> |
| <td>If set, jk2 won't touch the headers in case of error and will let for example Apache present the ErrorDocument via mod_alias. |
| </td> |
| </tr> |
| <tr> |
| <td>noWorkerMsg</td> |
| <td/> |
| <td/> |
| </tr> |
| <tr> |
| <td>noWorkerCode</td> |
| <td>503</td> |
| <td/> |
| </tr> |
| <tr> |
| <td>hwBalanceErr</td> |
| <td/> |
| <td/> |
| </tr> |
| <tr> |
| <td>timeout</td> |
| <td>0 (disabled)</td> |
| <td>If all the workers are in the error state, probably by Tomcat |
| refusing any new connections due to the overload, you can set the timeout forcing lb to wait that some |
| worker becomes available, instead of immediately returning error to the client. This is very useful in |
| situations with high peek load. The timeout should be set to the maximum application call time, but |
| not less then 1 second. |
| </td> |
| </tr> |
| <tr> |
| <td>attempts</td> |
| <td>3</td> |
| <td>Number of attempts that lb will try on each worker before |
| giving up. |
| </td> |
| </tr> |
| <tr> |
| <td>recovery</td> |
| <td>60 (seconds)</td> |
| <td>Time to wait before retrying to see if the worker came out |
| of the error state. |
| </td> |
| </tr> |
| <tr> |
| <td>stickySession</td> |
| <td>1 (true)</td> |
| <td>Sessions stick to the same worker, 1=true 0=false |
| </td> |
| </tr> |
| </table> |
| </p> |
| </subsection> |
| </section> |
| <section name="loggers"> |
| <p>Any connector based on jk2, at least has a default logger, that can be reached using the "logger" alias, the logger used is the more appropiate for the plataform/server combination, Apache2 under in any platform has logger.apache2 as default, IIS on his only platform uses logger.win32, and Any apache 1 install uses logger.file as default.., the config file lets you change that defaults, you can end using logger.file in IIs i.e</p> |
| <p>The properties shared by all loggers are: |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>level</td> |
| <td>INFO</td> |
| <td>Text of the log level. Strings supported: EMERG, ERROR, INFO, DEBUG</td> |
| </tr> |
| </table> |
| </p> |
| <subsection name="logger.file"> |
| <p> |
| <table> |
| <tr> |
| <th>Property name</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>file</td> |
| <td>${serverRoot}/logs/jk2.log</td> |
| <td> |
| Log file. XXX you may be able to change this at runtime, |
| to implement rolling. |
| </td> |
| </tr> |
| </table> |
| </p> |
| </subsection> |
| <subsection name="logger.win32"> |
| <p>logger used in the IIS server by default, it ends at native Application Event Log.</p> |
| </subsection> |
| <subsection name="logger.apache2"> |
| <p>Logger used in Apache2 servers, it normally in ends in error.log </p> |
| </subsection> |
| </section> |
| <section name="How Load Balancing Works"> |
| <p>The lb_factor and level properties combine to deliver a flexible static load balancing solution. |
| The level property is used to create up to four pools over workers in descending priority and lb_factor |
| is used to weight the workers within a pool. The lower the level the more likely the worker is to be used |
| and the lower the lb_factor the more likely the worker is to be used. Here is how the algorithm is |
| currently implemented:</p> |
| <p> |
| (Assume that every worker's lb_value is set to their lb_factor)<br/> |
| <br/><source> |
| if (loadbalancer has a route) and (stickysession=1){<br/> |
| worker= loadbanlancer.getWorkerForRoute(route)<br/> |
| if worker.hasRedirect<br/> |
| redirect=worker.redirect<br/> |
| else if !worker.hasError<br/> |
| return worker<br/> |
| }<br/> |
| <br/> |
| selectedWorker=null<br/> |
| foreach lb_level {<br/> |
| foreach worker in the level {<br/> |
| if worker.isNotWorking<br/> |
| continue<br/> |
| if selectedWorker == null<br/> |
| selectedWorker = worker<br/> |
| continue<br/> |
| if worker.lb_value < selectedWorker.lb_value<br/> |
| selectedWorker = worker<br/> |
| continue<br/> |
| }<br/> |
| if selectedWorker !=null<br/> |
| break<br/> |
| }<br/> |
| <br/> |
| Reenable workers in error state if the timeout has passed()<br/> |
| <br/> |
| if selectedWorker !=null {<br/> |
| selectedWorker.lb_value += selectedWorker.lb_factor<br/> |
| if selectedWorker.lb_value > 255 {<br/> |
| foreach worker in load_balancer.workers[selectedWorker.level]<br/> |
| worker.lb_value=worker.lb_factor<br/> |
| }<br/> |
| }<br/> |
| return selectedWorker<br/> |
| }<br/></source> |
| </p> |
| |
| </section> |
| </document> |