mod_proxy_balancer.xml revision a652b68dea502131f70084ead7981d5fc754cd34
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<!-- $LastChangedRevision$ -->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Licensed to the Apache Software Foundation (ASF) under one or more
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte contributor license agreements. See the NOTICE file distributed with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte this work for additional information regarding copyright ownership.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte The ASF licenses this file to You under the Apache License, Version 2.0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (the "License"); you may not use this file except in compliance with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte the License. You may obtain a copy of the License at
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Unless required by applicable law or agreed to in writing, software
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte distributed under the License is distributed on an "AS IS" BASIS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte See the License for the specific language governing permissions and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<modulesynopsis metafile="mod_proxy_balancer.xml.meta">
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami<description><module>mod_proxy</module> extension for load balancing </description>
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami<compatibility>Available in version 2.1 and later</compatibility>
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami <p>This module <em>requires</em> the service of <module
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami >mod_proxy</module>. It provides load balancing support for
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami <code>HTTP</code>, <code>FTP</code> and <code>AJP13</code> protocols
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami <p>Load balancing scheduler algorithm is provided by not this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte module but other modules such as:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <p>Thus, in order to get the ability of load balancing,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <module>mod_proxy</module>, <module>mod_proxy_balancer</module>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte and at least one of load balancing scheduler algorithm modules have
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte to be present in the server.</p>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte href="mod_proxy.html#access">secured your server</a>. Open proxy
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte servers are dangerous both to your network and to the Internet at
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <p>At present, there are 3 load balancer scheduler algorithms available
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for use: Request Counting, Weighted Traffic Counting and Pending Request
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Counting. These are controlled via the <code>lbmethod</code> value of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte the Balancer definition. See the <directive module="mod_proxy">ProxyPass</directive>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte directive for more information, especially regarding how to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte configure the Balancer and BalancerMembers.</p>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <p>The balancer supports stickyness. When a request is proxied
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte to some back-end, then all following requests from the same user
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte should be proxied to the same back-end. Many load balancers implement
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte this feature via a table that maps client IP addresses to back-ends.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte This approach is transparent to clients and back-ends, but suffers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte from some problems: unequal load distribution if clients are themselves
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hidden behind proxies, stickyness errors when a client uses a dynamic
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IP address that changes during a session and loss of stickyness, if the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mapping table overflows.</p>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <p>The module <module>mod_proxy_balancer</module> implements stickyness
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte on top of two alternative means: cookies and URL encoding. Providing the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cookie can be either done by the back-end or by the Apache web server
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte itself. The URL encoding is usually done on the back-end.</p>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <title>Examples of a balancer configuration</title>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <p>Before we dive into the technical details, here's an example of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte how you might use <module>mod_proxy_balancer</module> to provide
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte load balancing between two back-end servers:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <Proxy balancer://mycluster><br />
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte </Proxy><br />
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ProxyPass /test balancer://mycluster<br />
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ProxyPassReverse /test balancer://mycluster
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <p>Another example of how to provide load balancing with stickyness
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte using <module>mod_headers</module>, even if the back-end server does
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte not set a suitable session cookie:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte env=BALANCER_ROUTE_CHANGED<br />
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte <Proxy balancer://mycluster><br />
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BalancerMember http://192.168.1.50:80 route=1<br />
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ProxySet stickysession=ROUTEID<br />
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte </Proxy><br />
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ProxyPass /test balancer://mycluster<br />
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ProxyPassReverse /test balancer://mycluster
<dt><var><a name="balancer_session_sticky" id="balancer_session_sticky">BALANCER_SESSION_STICKY</a></var></dt>
<dt><var><a name="balancer_session_route" id="balancer_session_route">BALANCER_SESSION_ROUTE</a></var></dt>
<dt><var><a name="balancer_worker_name" id="balancer_worker_name">BALANCER_WORKER_NAME</a></var></dt>
<dt><var><a name="balancer_worker_route" id="balancer_worker_route">BALANCER_WORKER_ROUTE</a></var></dt>
<dt><var><a name="balancer_route_changed" id="balancer_route_changed">BALANCER_ROUTE_CHANGED</a></var></dt>
is different from the route of the worker, i.e.