mod_proxy_balancer.html.en revision c44eeebd065e2c8cd028016b45c58afb480aaf8f
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
50c04f297d76a57ead2fa6b73845f7563b1fc788sf XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
50c04f297d76a57ead2fa6b73845f7563b1fc788sf This file is generated from xml source: DO NOT EDIT
50c04f297d76a57ead2fa6b73845f7563b1fc788sf XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<title>mod_proxy_balancer - Apache HTTP Server Version 2.5</title>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<script src="/style/scripts/prettify.min.js" type="text/javascript">
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<link href="/images/favicon.ico" rel="shortcut icon" /></head>
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.5</a> > <a href="./">Modules</a></div>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<div id="preamble"><h1>Apache Module mod_proxy_balancer</h1>
053bfa8a288528fafab2b7a032c15116bb5de711nd<p><span>Available Languages: </span><a href="/en/mod/mod_proxy_balancer.html" title="English"> en </a> |
053bfa8a288528fafab2b7a032c15116bb5de711nd<a href="/ja/mod/mod_proxy_balancer.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td><code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code> extension for load balancing </td></tr>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>proxy_balancer_module</td></tr>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_proxy_balancer.c</td></tr></table>
1538dfa9300693372892a358260e1dcdbf1138eapoirier <p>This module <em>requires</em> the service of <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code>. It provides load balancing support for
50c04f297d76a57ead2fa6b73845f7563b1fc788sf <code>HTTP</code>, <code>FTP</code> and <code>AJP13</code> protocols
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic <p>Load balancing scheduler algorithm is provided by not this
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic module but other modules such as:
bed3c2e56e8f3328e780200466b9d009093db468sf <code class="module"><a href="/mod/mod_lbmethod_byrequests.html">mod_lbmethod_byrequests</a></code>,
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic <code class="module"><a href="/mod/mod_lbmethod_bytraffic.html">mod_lbmethod_bytraffic</a></code>,
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic <code class="module"><a href="/mod/mod_lbmethod_bybusyness.html">mod_lbmethod_bybusyness</a></code> and
50c04f297d76a57ead2fa6b73845f7563b1fc788sf <code class="module"><a href="/mod/mod_lbmethod_heartbeat.html">mod_lbmethod_heartbeat</a></code>.
50c04f297d76a57ead2fa6b73845f7563b1fc788sf <p>Thus, in order to get the ability of load balancing,
50c04f297d76a57ead2fa6b73845f7563b1fc788sf <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code>, <code class="module"><a href="/mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf and at least one of load balancing scheduler algorithm modules have
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh to be present in the server.</p>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf <p>Do not enable proxying until you have <a href="mod_proxy.html#access">secured your server</a>. Open proxy
50c04f297d76a57ead2fa6b73845f7563b1fc788sf servers are dangerous both to your network and to the Internet at
bed3c2e56e8f3328e780200466b9d009093db468sf large.</p>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<li><img alt="" src="/images/down.gif" /> <a href="#scheduler">Load balancer scheduler algorithm</a></li>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<li><img alt="" src="/images/down.gif" /> <a href="#stickyness">Load balancer stickyness</a></li>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<li><img alt="" src="/images/down.gif" /> <a href="#example">Examples of a balancer configuration</a></li>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<li><img alt="" src="/images/down.gif" /> <a href="#environment">Exported Environment Variables</a></li>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<li><img alt="" src="/images/down.gif" /> <a href="#balancer_manager">Enabling Balancer Manager Support</a></li>
bed3c2e56e8f3328e780200466b9d009093db468sf<li><img alt="" src="/images/down.gif" /> <a href="#stickyness_implementation">Details on load balancer stickyness</a></li>
bed3c2e56e8f3328e780200466b9d009093db468sf<li><img alt="" src="/images/down.gif" /> <a href="#stickyness_troubleshooting">Troubleshooting load balancer stickyness</a></li>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<p>This module provides no
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic directives.</p>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<li><code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code></li>
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
bed3c2e56e8f3328e780200466b9d009093db468sf<h2><a name="scheduler" id="scheduler">Load balancer scheduler algorithm</a></h2>
bed3c2e56e8f3328e780200466b9d009093db468sf <p>At present, there are 3 load balancer scheduler algorithms available
bed3c2e56e8f3328e780200466b9d009093db468sf for use: Request Counting, Weighted Traffic Counting and Pending Request
bed3c2e56e8f3328e780200466b9d009093db468sf Counting. These are controlled via the <code>lbmethod</code> value of
50c04f297d76a57ead2fa6b73845f7563b1fc788sf the Balancer definition. See the <code class="directive"><a href="/mod/mod_proxy.html#proxypass">ProxyPass</a></code>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf directive for more information, especially regarding how to
50c04f297d76a57ead2fa6b73845f7563b1fc788sf configure the Balancer and BalancerMembers.</p>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
50c04f297d76a57ead2fa6b73845f7563b1fc788sf<h2><a name="stickyness" id="stickyness">Load balancer stickyness</a></h2>
053bfa8a288528fafab2b7a032c15116bb5de711nd <p>The balancer supports stickyness. When a request is proxied
053bfa8a288528fafab2b7a032c15116bb5de711nd to some back-end, then all following requests from the same user
727872d18412fc021f03969b8641810d8896820bhumbedooh should be proxied to the same back-end. Many load balancers implement
0d0ba3a410038e179b695446bb149cce6264e0abnd this feature via a table that maps client IP addresses to back-ends.
727872d18412fc021f03969b8641810d8896820bhumbedooh This approach is transparent to clients and back-ends, but suffers
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh from some problems: unequal load distribution if clients are themselves
0d0ba3a410038e179b695446bb149cce6264e0abnd hidden behind proxies, stickyness errors when a client uses a dynamic
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh IP address that changes during a session and loss of stickyness, if the
727872d18412fc021f03969b8641810d8896820bhumbedooh mapping table overflows.</p>
0d0ba3a410038e179b695446bb149cce6264e0abnd <p>The module <code class="module"><a href="/mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code> implements stickyness
0d0ba3a410038e179b695446bb149cce6264e0abnd on top of two alternative means: cookies and URL encoding. Providing the
0d0ba3a410038e179b695446bb149cce6264e0abnd cookie can be either done by the back-end or by the Apache web server
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh itself. The URL encoding is usually done on the back-end.</p>
0d0ba3a410038e179b695446bb149cce6264e0abnd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0d0ba3a410038e179b695446bb149cce6264e0abnd<h2><a name="example" id="example">Examples of a balancer configuration</a></h2>
0d0ba3a410038e179b695446bb149cce6264e0abnd <p>Before we dive into the technical details, here's an example of
0d0ba3a410038e179b695446bb149cce6264e0abnd how you might use <code class="module"><a href="/mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code> to provide
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh load balancing between two back-end servers:
0d0ba3a410038e179b695446bb149cce6264e0abnd <pre class="prettyprint lang-config"><Proxy balancer://mycluster>
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd BalancerMember http://192.168.1.50:80
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd BalancerMember http://192.168.1.51:80
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd</Proxy>
50c04f297d76a57ead2fa6b73845f7563b1fc788sfProxyPass /test balancer://mycluster
using <code class="module"><a href="/mod/mod_headers.html">mod_headers</a></code>, even if the back-end server does
<pre class="prettyprint lang-config">Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
BalancerMember http://192.168.1.50:80 route=1
BalancerMember http://192.168.1.51:80 route=2
<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>
<code class="module"><a href="/mod/mod_status.html">mod_status</a></code> and <code class="module"><a href="/mod/mod_proxy_balancer.html">mod_proxy_balancer</a></code>
Require host example.com
<h2><a name="stickyness_implementation" id="stickyness_implementation">Details on load balancer stickyness</a></h2>
<code class="directive"><a href="/mod/mod_proxy.html#proxyset">ProxySet</a></code>. The cookie can either
this via the web server using <code class="module"><a href="/mod/mod_substitute.html">mod_substitute</a></code> or
<code class="module"><a href="/mod/mod_sed.html">mod_sed</a></code>. This can have negative impact on performance though.</p>
<pre class="prettyprint lang-config">ProxyPass /test balancer://mycluster stickysession=JSESSIONID|jsessionid scolonpathdelim=On
BalancerMember http://192.168.1.50:80 route=node1
BalancerMember http://192.168.1.51:80 route=node2
<h2><a name="stickyness_troubleshooting" id="stickyness_troubleshooting">Troubleshooting load balancer stickyness</a></h2>
is different from the route of the worker, i.e.
<p><span>Available Languages: </span><a href="/en/mod/mod_proxy_balancer.html" title="English"> en </a> |
<a href="/ja/mod/mod_proxy_balancer.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_proxy_balancer.html';
if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
d.write('<div id="comments_thread"><\/div>');
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
(d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
<p class="apache">Copyright 2015 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--