Apache + Tomcat + Server Load balancer configuration tutorial

Source: Internet
Author: User
Finally, we have configured apache + tomcat + load balancing! I feel a little difficult. 1. Load Balancing: each server is independent. It only balances the request load, rather than replicating the status (SESSION. Status replication (cluster): load balancing is performed first, and application status is replicated between servers. 2. The principle of apache Load Balancing finally puts apache + McAt + load balancing is configured, dizzy! It feels a little difficult

1. Load Balancing:

Each server is independent. It only balances the request load and does not copy the status (SESSION.Status replication (Cluster):Load Balancing is performed first, and application statuses are replicated between servers.

2,ApacheServer Load balancerPrinciple:

Mod_jk Load Balancing Principle:
Use mod_jk to balance the load in the round robin mode by default. If there are four server nodes and 10 requests
The first node will receive requests, 9;
The second node will receive 2, 6, 10 requests;
The third node will receive 3, 7 requests;
The fourth node will receive requests;

Mod_JK2 negativeLoad Balancing and fault recovery:

ApacheHttpdIs used as a web server, use mod_jk2 to send the request to TomCatLoad Balancing and fault tolerance functions of mod_jk2 can be used.Apache (httpd) with mod_jk2 can do the following:

A. You can allocate requests to one or more Tomcat instances on the workers of mod_jk2. in the properties file, set many Tomcat instances and assign each instance an lb_factor value as the weighting factor for request allocation.

B. Check whether the Tomcat instance fails. When the connector service of the Tomcat instance no longer responds, mod_jk2 will detect it in time and stop sending the request to it. Other Tomcat instances will accept the load of the invalid instance.

C. After detecting when a Tomcat instance is restored after it becomes invalid because of the connector service failure and stops allocating requests to the Tomcat instance, mod_jk2 periodically checks whether the service has been resumed, and automatically add it to the current Tomcat instance pool.

Practice has proved that load balancing can achieve linear performance growth and higher concurrency requirements without the need for State replication between application servers.

Cluster principle:

This method is also used to balance the cluster. In Tomcat, the cluster principle is to find nodes through multicast and use TCP connections for session replication.

Advantages and disadvantages of cluster and load balancing:

Disadvantages:

The cluster is different from the load balancing, because the cluster service needs to continuously copy sessions between processing requests, the copied sessions will gradually become large, so its resources:

The source usage is very high. In applications with a large concurrency, the size of the replication session will become quite large, and the total memory used will increase rapidly.

Advantages:

However, cluster session replication increases the high availability of the system. Because the user's Session information is stored on each server, if a server in the server group runs on a certain machine, the application can automatically switch to another server to continue running, and the user's information will not be lost, this improves the redundancy of applications.


Files required:

Jakarta-tomcat-connectors-1.2.14-src.tar.gz

Httpd-2.2.19.tar.bz2

Apache-tomcat-7.0.19.tar(Required for both windows and linux)

I configured it in win7 and installed Vmware7.1 + REdHat6.1.

Install Tomcat 7 in win7

Install Tomcat 7 + apache2.2 under RedHat

Install in RedHatJakarta-tomcat-connectors-1.2.14-src.tar.gz


1. Modify httpd. cnf
Find httpd. conf In the conf directory under the apache installation directory, and add the following two sentences at the end of the file. 

  1. LoadMoDuLe jk_module modules/mod_jk.so
  2. INcLude/apache2.2/conf/mod_jk.conf


2. Create the mod_jk.conf file in the same directory as http. conf, www. linuxIdC.com content is as follows (or you can directly write this content to the above file)
  1. # Load mod_jk Module
  2. LoadModule jk_module modules/mod_jk-apache-2.0.55.so
  3. # Specify the workers. properties file path
  4. JkWorkersFile conf/workers. properties
  5. # Specify the requests to tomcat for processing, "conTrOller "is the server load distribution controller specified in workers. propertise.
  6. JkMount/*. jsp controller
  7. You can also add as needed, such:
  8. JkMount/servlet/* controller
  9. JkMount/*. do controller

Related Article

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.