Академический Документы
Профессиональный Документы
Культура Документы
ANDROID CORE JAVA DESKTOP JAVA ENTERPRISE JAVA JAVA BASICS JVM LANGUAGES SOFTWARE DEVELOPMENT DEVOPS
Load balancing improves the distribution of workloads across multiple Tomcat servers.
Load balancing aims to optimize resource use, maximize throughput, minimize
response time, and avoid overload of any single resource.
Table Of Contents
1. The tools
2. Introduction
3. Prerequisites
4. Download Tomcat
5. Download Apache httpd server
NEWSLETTER
6. Download mod_jk
7. Tomcat Installation
7.1 Uncompress Apache Tomcat 165,000 insiders are alre
7.2 Install the Tomcat service weekly updates and complime
7.3 Start the Tomcat service whitepapers!
7.4 Check that tomcat is running Join them now to ga
8. Apache httpd Installation access to the latest news in
8.1 Uncompress Apache httpd server as well as insights about Andr
8.2 Edit the server root Groovy and other related tech
8.3 Install the httpd service
8.4 Start the Tomcat service
Email address:
8.5 Check that tomcat is running Your email address
9. mod_jk installation
9.1 Add mod_jk to the httpd.conf
Receive Java & Developer
9.2 Configure mod_jk in the Apache httpd server your Area
9.3 Create the workers.properties file
10. Conclusion
Sign up
Want to master Tomcat Server ?
Subscribe to our newsletter and download the Apache Tomcat
Cookbook right now! JOIN US
With 1,
In order to get you prepared for your Tomcat development needs, we have compiled unique v
numerous recipes to help you kick-start your projects. Besides reading them online you may 500 au
download the eBook in PDF format! placed a
related s
Constan
lookout
encoura
So If yo
Download NOW!
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 1/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
unique and interesting content t
check out our JCG partners prog
be a guest writer for Java Cod
your writing skills!
A Tomcat cluster consists of a set of connected Tomcat Servers that work together so that, in many respects, they can be viewed as a single
system. Each node, sets to perform the same task, controlled and scheduled by load balancer.
1. The tools
Java JDK
Apache Tomcat
Apache httpd server
mod_jk connector
2. Introduction
In this example, we are going to set up your own Apache Tomcat clusters using Apache Httpd as a load balancer front end for the cluster.
3. Prerequisites
JDK installed
4. Download Tomcat
Go to the page https://tomcat.apache.org/download-80.cgi and download the tomcat server as a zip compressed file for windows.
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 2/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
6. Download mod_jk
Go to the page https://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/ and download the mod_jk as a zip compressed
file for windows.
7. Tomcat Installation
7.1 Uncompress Apache Tomcat
Choose an installation directory and uncompress the Tomcat server in its own directory.
4 Uncompress Tomcat
7.2 Install the Tomcat service
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 3/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
Open the Windows terminal and go to the Tomcat Installation bin directory.
Tomcat installation directory
1 C:\Java\Apache Tomcat 8.0.15\bin>
console
01 SERVICE_NAME: Tomcat8
02 TYPE : 10 WIN32_OWN_PROCESS
03 STATUS : 2 START_PENDING
04 (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
05 WIN32_OUTPUT_CODE : 0 (0x0)
06 SERVICE_OUTPUT_CODE: 0 (0x0)
07 CHECK-POINT : 0x0
08 START-INDICATOR : 0x7d0
09 PID : 5552
10 MARKS :
5 Tomcat Welcome
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 4/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
SRVROOT
1 Define SRVROOT "C:\Java\Apache24"
console
01 SERVICE_NAME: Apache2.4
02 TYPE : 10 WIN32_OWN_PROCESS
03 STATUS : 2 START_PENDING
04 (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 5/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
05 WIN32_OUTPUT_CODE : 0 (0x0)
06 SERVICE_OUTPUT_CODE: 0 (0x0)
07 CHECK-POINT : 0x0
08 START-INDICATOR : 0x7d0
09 PID : 3268
10 MARKS :
9. mod_jk installation
Extract the mod_jk compressed file and copy the file
mod_jk.so
8 Install mod_jk
file.
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 6/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
9 Edit httpd
Load mod_jk
1 LoadModule jk_module modules/mod_jk.so
Configure mod_jk
1 JkWorkersFile C:\Java\Apache24\conf\workers.properties
2 JkShmFile C:\Java\Apache24\log\mod_jk.shm
3 JkLogFile C:\Java\Apache24\log\mod_jk.log
4 JkLogLevel error
5 JkMount /status status
6 JkMount /* balancer
JkWorkersFile C:\Java\Apache24\conf\workers.properties.
JkLogFile C:\Java\Apache24\log\mod_jk.log
directory of the Apache httpd server, create a new text file with the name
workers.properties
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 7/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
10 Create workers.properties
Edit the
worker.properties file
Workers properties
01 worker.list=balancer,status
02
03 worker.tomcat1.type=ajp13
04 worker.tomcat1.port=8009
05 worker.tomcat1.host=localhost
06
07 worker.tomcat2.type=ajp13
08 worker.tomcat2.port=8010
09 worker.tomcat2.host=localhost
10
11 worker.tomcat3.type=ajp13
12 worker.tomcat3.port=8011
13 worker.tomcat3.host=localhost
14
15
16 worker.balancer.type=lb
17 worker.balancer.balance_workers=tomcat1,tomcat2,tomcat3
18
19 worker.status.type=status
worker.list=balancer,stat
From outside we have 2 visible workers: balancer and stat. All the request that comes to the balancer are managed by the balancer worker.
worker.tomcat1.type=ajp13
Defines a native connector to use with the Tomcat instance, is the same for each worker.
worker.tomcat1.host=localhost
Sets the host of the worker, this is done for each worker.
worker.tomcat1.port=8009
worker.balancer.type=lb
worker.status.type=status
The status worker will log changes made to the configuration with log level “info” to the usual JK log file. Invalid requests will be logged with
log level “warn”.
At this point the Apache httpd server its working as a front end of the Tomcat load balancer.
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 8/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
10. Conclusion
When you access the Httpd server from the browser, each request is going to be distributed to the three tomcat instances. If one of the
tomcat instances fail then load balancer stops to forward requests to that failed instance.
If that failed instance becomes active then the load balancer adds it to the cluster and forward requests again. The key here is that you make
each node of the load balancer a different Tomcat server from a separate host.
Email address:
Your email address
Sign up
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 9/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
Complete End-to-End Spring Cloud Eureka JAX-WS Web Services Apache Tomcat Mod_jk
Testing - Setup, Write, Server Tutorial On Tomcat Tutorial
Run, & Record
Weblogic Server How to Install Jetty JDBC Connection Pool Apache ActiveMQ Load
Administration Tutorial Application Server Example Balancing Example
5 Leave a Reply
3 2 0 5
Brian
In this example, those multiple Tomcat instances are installed on the same server host. What is the difference for
multiple Tomcat instances installed on different server hosts?
Guest
Amit Arora
Biswajeet Rout
Guest
0 Reply 4 months ago
Tabitarh
Great tutorial.
Just to find out.
Guest
If I have a folder created in the webapps directory to store some uploaded file in say tomcat instance 1, how will
the other tomcat instances access this folder.
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 10/11
10/10/2019 Apache Tomcat Load Balancing Tutorial | Examples Java Code Geeks - 2019
Member Don’t use the webapps directory. Store the uploaded file under the Apache httpd server. You’ll need to
configure httpd.conf or vhosts.conf to point to the directory of the uploaded files. See “JKMount”.
Examples Java Code Geeks and all content copyright © 2010-2019, Exelixis Media P.C. | Terms of Use | Privacy Policy | Contact
https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-load-balancing-tutorial/ 11/11