Comparison of advantages and disadvantages of three Load Balancing Methods in Tomcat Cluster

Source: Internet
Author: User
1. Use DNS round robin.
2. Use Apache R-proxy.
3. Use Apache mod_jk.
The disadvantage of DNS round-robin is that when a server in the cluster stops, the user cannot access the service due to the DNS cache,
You must wait until the DNS resolution is updated or the server restarts.
In addition, all service ports in the cluster must be exposed to the outside world, and the pre-proxy method of Apache is not used for security,
It also occupies a large number of public IP addresses, and Tomcat is also responsible for processing static Web page resources, affecting efficiency.
The advantage is that the cluster configuration is the simplest, And the DNS settings are also very simple.
The disadvantage of R-proxy is that when one of Tomcat stops running, Apache still forwards the request, resulting in a 502 Gateway error.
However, this problem does not exist if the server is restarted.
The advantage of the mod_jk method is that Apache automatically detects the stopped Tomcat and does not send a request again.
The disadvantage is that when the stopped Tomcat server is started again, Apache cannot detect it and will not forward the request.
The common advantage of R-proxy and mod_jk is that only Apache can be deployed on the public network, saving public IP Address resources.
Apache can handle static web pages through settings, so Tomcat can handle dynamic requests such as JSP and servlet.
The common disadvantage is that if the front-end Apache proxy server stops running, all cluster services cannot be provided externally.
R-proxy and mod_jk can be used to select an optimal effect for handling static page requests.
These three methods are insufficient for optimal load balancing, and mod_jk is relatively better. You can assign request tasks by setting the lbfactor parameter.
All of these should be selected based on actual usage.
The configuration is as follows:
Preparations:
1. Download Apache and tomcat:
Apache2.0.53:
Http://www.eu.apache.org/dist/httpd/binaries/win32/apache_2.0.53-win32-x86-no_ssl.msi
Tomcat5.5.9:
Http://www.eu.apache.org/dist/jakarta/tomcat-5/v5.5.9/bin/jakarta-tomcat-5.5.9.zip
Http://www.eu.apache.org/dist/jakarta/tomcat-5/v5.5.9/bin/jakarta-tomcat-5.5.9-fulldocs.tar.gz
Http://www.eu.apache.org/dist/jakarta/tomcat-5/v5.5.9/bin/jakarta-tomcat-5.5.9-compat.zip
Http://www.eu.apache.org/dist/jakarta/tomcat-5/v5.5.9/bin/jakarta-tomcat-5.5.9-admin.zip
Mod_jk.so
Http://www.eu.apache.org/dist/jakarta/tomcat-connectors/jk/binaries/win32/jk-1.2.8/mod_jk-1.2.8-apache-2.0.52.so
(Optional, because apache2.0.53 already comes with it ).
2. Configure the Tomcat cluster.
At the same time, the Web application clusterapp is released. Modify test. jsp,
Enable:
Http: // 192.168.9.235: 12080/clusterapp/test. jsp
And
Http: // 192.168.9.226: 12080/clusterapp/test. jsp
Different page effects are displayed.
3. Install apache2.0.53.
In this case, the Tomcat Cluster Server is:
192.168.9.226: 12080 and 192.168.9.235: 12080

Edit the C:/Windows/system32/Drivers/etc/host file,
Add the last line
127.0.0.1 lizongbo.com
First, the R-proxy method.
The next step is the mod_jk mode.
Restart Apache.
Http://lizongbo.com/clusterapp/test.jsp
Refresh the page without stopping, and different content will be displayed on the page.

References:
Tomcat cluster:
Http://www.onjava.com/onjava/2004/04/14/examples/tomcatclustering.zip
Http://www.onjava.com/pub/a/onjava/2004/11/24/replication1.html
Http://www.onjava.com/pub/a/onjava/2004/11/24/replication1.html? Page = 2
Http://www.onjava.com/pub/a/onjava/2004/04/14/clustering.html
Http://www.onjava.com/pub/a/onjava/2004/04/14/clustering.html? Page = 2
R-Proxy:
Http://www.douzhe.com/docs/ApacheManual/mod/mod_proxy.html#proxypassreverse
Http://www.douzhe.com/docs/ApacheManual/mod/mod_rewrite.html#rewritemap
Http://www.douzhe.com/docs/ApacheManual/mod/mod_rewrite.html#rewriterule
Mod_jk:
Http://jakarta.apache.org/tomcat/connectors-doc/config/apache.html
Http://jakarta.apache.org/tomcat/connectors-doc/config/workers.html
Http://jakarta.apache.org/tomcat/connectors-doc/common/ajpv13a.html
Http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg146787.html
Relatively outdated materials (because mod_jk2 is no longer recommended and mod_jk2 is no longer updated ):
Http://www.sentom.net/list.asp? Id = 14
Http://www.linuxforum.net/docnew/showthreaded.php? Cat = & board = Server & number = 507 & page = 1 & view = collapsed & SB = 5 & O = All & fpart =
Http://www.ecoo.net/list.asp? ArticleID = 2311
Http://www.linuxaid.com.cn/forum/showdoc.jsp? L = 1 & I = 81013 & M = 0
Http://search.csdn.net/expert/topicview1.asp? Id = 1706745
Http://www.chinaitlab.com/www/news/article_show.asp? Id = 11921
Useful information: (because I have not carefully read it)
Http://www.phpv.net/article.php/92
Http://raibledesigns.com/tomcat/
Http://www.crazysquirrel.com/debian/tomcat55.php
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.