File: loadbalancers.xml

package info (click to toggle)
libapache-mod-jk 1%3A1.2.30-1squeeze2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 10,056 kB
  • ctags: 5,973
  • sloc: ansic: 54,056; xml: 12,930; sh: 9,363; java: 1,921; perl: 1,004; makefile: 275; awk: 59
file content (176 lines) | stat: -rw-r--r-- 6,134 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE document [
  <!ENTITY project SYSTEM "project.xml">
]>
<document url="loadbalancers.html">

  &project;
<copyright>
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You 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>LoadBalancer HowTo</title>
<author email="mturk@apache.org">Mladen Turk</author>
<date>$Date: 2010-01-28 20:47:58 +0100 (Thu, 28 Jan 2010) $</date>
</properties>
<body>
<section name="Introduction"> 
<br/>
<p>A Load balancer is a virtual worker that does not really communicate with Tomcat workers.
Instead it is responsible for the management of several "real" workers.
The worker is supposed to be a load balancer if its worker type is <b>lb</b>.
See workers <b>type</b> directive. For a complete reference of all load balancer configuration
items, please consult the worker <a href="../reference/workers.html">reference</a>.
The comprehensive status management features of the load balancer together with the status worker,
makes its use an interesting option, even if only combined with a single "real" worker.
<warn>As long as the "real" workers should only be used via the load balancer worker,
there is no need to also put them into the <b>worker.list</b> property.</warn>
</p>

<subsection name="lb Worker properties">
<p>
The load-balancing worker does not really communicate with Tomcat workers.
Instead it is responsible for the management of several "real" workers. 
This management includes:
</p>

<ul>
<li>
Instantiating the workers in the web server.
</li>
<li>
Using the worker's load-balancing factor, perform weighed-round-robin load balancing where 
high lbfactor means stronger machine (that is going to handle more requests)
</li>
<li>
Keeping requests belonging to the same session executing on the same Tomcat worker.
</li>
<li>
Identifying failed Tomcat workers, suspending requests to them and instead falling-back on 
other workers managed by the lb worker.
</li>
</ul>

<p>
The overall result is that workers managed by the same lb worker are load-balanced (based on their lbfactor and current user session) and also fall-backed so a single Tomcat process death will not "kill" the entire site.
</p>
<warn>
If you want to use session stickiness, you must set different jvmRoute attributes
in the Engine element in Tomcat's server.xml. Furthermore the names of the workers
which are managed by the balancer have to be equal to the jvmRoute of the Tomcat
instance they connect with.
</warn>
<p>
The following table specifies some properties that the lb worker can accept:
<ul>
<li><b>balance_workers</b> is a comma separated list of workers that the load balancer need to manage. 
These workers do not need to appear in the worker.list property. This directive can be used multiple times for the same load balancer.</li>
<li><b>sticky_session</b> specifies whether requests with SESSION ID's should be routed back to the same
Tomcat worker. You can set sticky_session to False when Tomcat is using a Session Manager which
can persist session data across multiple instances of Tomcat. By default sticky_session is set to True.</li>
</ul>
</p>

<source>
  # The worker balance1 while use "real" workers worker1 and worker2
  worker.balance1.balance_workers=worker1, worker2
</source>

</subsection>

<subsection name="Advanced lb Worker properties">
<p>
With JK 1.2.x, new load-balancing and fault-tolerant support has been added via
2 new properties, <b>redirect</b> and <b>activation</b>.
</p>

<p>
Let's take an example environment:
</p>

<p>
A cluster with two nodes (worker1+worker2), running a webserver + tomcat tandem on each node and 
a loadbalancer in front of the nodes.
</p>

<source>
  # The advanced router LB worker
  worker.list=router

  # Define a worker using ajp13
  worker.worker1.port=8009
  worker.worker1.host=node1.domain.org
  worker.worker1.type=ajp13
  worker.worker1.lbfactor=1
  # Define preferred failover node for worker1
  worker.worker1.redirect=worker2

  # Define another worker using ajp13
  worker.worker2.port=8009
  worker.worker2.host=node2.domain.org
  worker.worker2.type=ajp13
  worker.worker2.lbfactor=1
  # Disable worker2 for all requests except failover
  worker.worker2.activation=disabled
  
  # Define the LB worker
  worker.router.type=lb
  worker.router.balance_workers=worker1,worker2
</source>

<p>
The <b>redirect</b> flag on worker1 tells the <b>lb_worker</b> to redirect the requests
to worker2 only if worker1 is in error state. In other cases worker2 will not receive
any requests, thus acting like a hot standby.
</p>


</subsection>

<subsection name="Status Worker properties">
<p>
The status worker does not communicate with Tomcat.
Instead it is responsible for the load balancer management. 
</p>
<source>
  # Add the status worker to the worker list
  worker.list=jkstatus
  # Define a 'jkstatus' worker using status
  worker.jkstatus.type=status
</source>
<p>Next thing is to mount the requests to the jkstatus worker. For Apache
web servers use the:</p>
<source>
  # Add the jkstatus mount point
  JkMount /jkmanager/* jkstatus 
</source>
<p>To obtain a higher level of security use the:</p>
<source>
  # Enable the JK manager access from localhost only
 &lt;Location /jkmanager/&gt;
    JkMount jkstatus
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
 &lt;/Location&gt;
</source>

</subsection>

</section>

</body>
</document>