Sie sind auf Seite 1von 7

9/4/13

Apache JK Tomcat load balancing configuration

Home

Reading room

Museum Friends

My Library

Log in Registration

From: floating in the Northern Wolf > Apache

Color:

Font Size: big middle small

Floating in the Northern Wolf


Collection: 366 Me: 37

Apache JK Tomcat load balancing configuration


2007-03-16 | Viewed: 1637 rpm: 17 | Share

Online on Apache + JK + Tomcat cluster configuration of many examples, according to an example configuration down, basically to run, but, in some important places but no further explanation. The company is the use of a product Apache + JK + Tomcat cluster, the entire configuration, testing process, encountered many problems, through constant testing, trial and error, but finally was buttoned up, performance is also achieved the expected goals. For example online, I feel it is necessary to re-introduce my detailed configuration process, paying particular attention to some place supplement. Unlike distributed cluster solution, which is used in each server running the same policies applied by the server responsible for balancing shunt, which improve overall system concurrency and throughput is more effective way. The processing of the request have clustered in two different ways: load balancing, state replication ( ie, clusters ) , state replication between the servers need to copy the application state, and load balancing is not, each server is independent. Practice has proved that the application server is not required between the various state replication, the load balancing can be achieved and the higher the performance of concurrent linear growth requirements. For other clusters basics, this is not to do cumbersome. Following on the Apache + JK + Tomcat load balancing configuration summary, focusing on the entire configuration and precautions.
29 118.00

Latest Articles

A RoR site performance optimization A RoR site performance of the story (4 ... optimization A RoR site performance of the story (3 ... optimization A RoR site performance of the story (2 ... optimization MySpace, six of reconstruction the story (1 ...| Understand the program manager ityum.net CSAI.cn My Maven Project trip (1) Management - Why use ma ... Servlet 2.5 new features - JSP Chinese network Summary of the various perspectives Actual articles: domain Design model your own Annotation Java Annotation ... Advanced Java Annotation Manual - Fuko - ... Applications More >>

P r e p a r a t i o ns o f t w a r e
1, Tomcat or JBoss (this document is used in JBoss4.0.2); 2, Apache2.0.54Is an open source Web server, download address is: http://www.apache.org/dist/httpd/binaries/ ; 3, mod_jk-1.2.14-Apache-2.0.54.so module , jk is mod_jserv replacement, it is the Tomcat-Apache plug-in for Apache and Tomcat connectors, handle Tomcat and Apache communication between the cluster configuration to act as load balancer role in the current latest version is 1.2.15 , but different JK versions with different Apache versions there are some differences between the mix, and some even come Pei Buqi. JK2 is consistent apache2.x series of new products, but because of its configuration too much trouble, very few people use, so the current has stopped development, so we use the jk connector, download address: http://www.apache.org / dist / Tomcat / Tomcat-Connectors / JK / binaries / .

Popular Articles Landlords Egg cure sore throat, immediate Good habit to cultivate children 91 Beautiful coral

C l u s t e r i n ga n dl o a db a l a n c i n g
Using mod_jk default to Round Robin load balancing, assuming there are four
www.360doc.com/content/07/0316/10/7147_399335.shtml

1/7

9/4/13

Using mod_jk default to Round Robin load balancing, assuming there are four

Apache JK Tomcat load balancing configuration


Computer assembly tutorial (Figure) Xinshoubikan Weaving techniques ---Figure and a ... simple and Woman, you practical know ... Precious photos - Chinese century historical figures Philosophy of lifephoto seen through the cold, incisive 2013 review in sentence Mathematics Fast heart Vegetarian: 70 more ... vegetarian Life feeling temple fine blend More >>

server nodes, there are 10 requests, the request number four nodes were treated as follows:
Node 1Node 2Node 3Node 4

10

The cluster approach is the use of this method for balance. Tomcat cluster in principle is the way through the multicast nodes to find and use the TCP connection session replication. Unlike cluster load balancing, because the cluster service needs to handle the session between requests constantly reproduced, copied session will slowly become huge, so it's resources occupancy rate is very high, if the amount of concurrent large application, copy the session size can become quite large, and the total memory is rapidly increasing. But the cluster session replication, increasing the system's high availability. Because each server are stored in a user's Session information, if a server farm units crashes, applications can be automatically switched to other servers continue to run while the user's information is not lost, which enhances the fault tolerance of the application. Specific use of load balancing or clustering, depending application needs.

I n s t a l la n dc o n f i g u r e Apache
1 , download Apache installer apache_2.0.54-Win32-x86-no_ssl.exe , the installation is very simple, all the way round, thus skipped. 2 , the installation is complete, the downloaded mod_jk-1.2.14-Apache-2.0.54.so copied to the Apache installation directory under modules subdirectory. 3 , and then enter the Apache installation directory under the conf subdirectory, open the httpd.conf configuration file, insert the following line at the end: Include conf / mod_jk.conf 4, in the conf subdirectory, create a new configuration file: mod_jk.conf , this file is Apache loaded connector configuration file, the file name can be modified, but the httpd.conf in the Include file name, and reads as follows : # Load mod_jk module. Specify the filename # Of the mod_jk lib you've downloaded and # Installed in the previous section # Load mod_jk module LoadModule jk_module modules/mod_jk-1.2.14-Apache-2.0.54.so # Where to find workers.properties JkWorkersFile conf/workers2.properties # Where to put jk logs JkLogFile logs / mod_jk.log
www.360doc.com/content/07/0316/10/7147_399335.shtml 2/7

9/4/13

Apache JK Tomcat load balancing configuration

# Set the jk log level [debug / error / info] JkLogLevel info # Select the log format JkLogStampFormat "[% a% b% d% H:% M:% S% Y]" # JkOptions indicate to send SSL KEY SIZE, JkOptions + ForwardKeySize + ForwardURICompat-ForwardDirectories # JkRequestLogFormat set the request format JkRequestLogFormat "% w% V% T" # request distribution configuration, you can configure a number of JkMount / * loadbalancer # Turn off the host Lookup , if it is on , it is affecting the performance, you can have 10 more seconds delay. HostnameLookups Off Note: The blue color of the two lines is the key, the first one is the Apache load JK module used; second sentence configure which URL requests handled by the load balancer. 5, in the conf subdirectory, create a new configuration file: workers2.properties , this file is load balancing configuration file, the file name can not be modified, which is JK default name, as follows: worker.list = loadbalancer # Define the first node ... worker.server99.port = 8009 worker.server99.host = 192.168.11.99 worker.server99.type = ajp13 worker.server99.lbfactor = 1 worker.server99.local_worker = 1 worker.server99.cachesize = 1000 worker.server99.cache_timeout = 600 worker.server99.socket_keepalive = 1 worker.server99.socket_timeout = 0 worker.server99.reclycle_timeout = 300 worker.server99.retries = 3 # Define the second node ... worker.server202.port = 8009 worker.server202.host = 192.168.11.202 worker.server202.type = ajp13 worker.server202.lbfactor = 1 worker.server202.local_worker = 1 worker.server202.cachesize = 1000 worker.server202.cache_timeout = 600 worker.server202.socket_keepalive = 1 worker.server202.socket_timeout = 0 worker.server202.reclycle_timeout = 300 worker.server202.retries = 3 # Now we define the load-balancing behaviour worker.loadbalancer.type = lb
www.360doc.com/content/07/0316/10/7147_399335.shtml

worker.retries = 3

3/7

9/4/13

Apache JK Tomcat load balancing configuration

worker.retries = 3 worker.loadbalancer.balance_workers = server99, server202 worker.loadbalancer.sticky_session = true worker.loadbalancer.sticky_session_force = true Note: The above definition of the two worker , one for server99 , the other is server202 , defines a load balancing server LoadBalancer , which focus on the blue label configuration items related details can watch the official website documentation: zh / tomcat.apache.org / Connectors-doc / , other nodes can be defined directly Copy , modify the node name and IP just fine. A , worker.list = LoadBalancer Set work load balancer, the Tomcat node can not join this list. B , worker.server99.lbfactor The weight ratio of load balancing, if the weight ratio is larger, the node is assigned to this request, the more than two nodes such as the weight ratio of 1:1 , compared to the average distribution. C , worker.loadbalancer.balance_workers = server99, server202 Specifies the load balancer is responsible Tomcat application nodes. D , worker.loadbalancer.sticky_session = true Specify here whether the cluster session replication, if set to true , it indicates that the session stickiness, do not replicate the session, when a user requests the first distribution to which Taiwan Tomcat , the subsequent request would have been dispatched to the Tomcat server dealt with; If set to false , it indicates that the demand for session replication. E , worker.loadbalancer.sticky_session_force = true If the above sticky_session set to true , the suggestion here is also set to true , this parameter indicates if a station cluster Tomcat server does not respond after repeated requests, whether the current request, forwarded to other Tomcat server process; this parameters sticky_session = true , the impact is relatively large, will lead forwarded to other Tomcat server requests, can not find the original session , so if there is a request at this time to read session of certain information, it would cause the application of the null exception. 6 , Apache server configuration file httpd.conf , by default, there are three parameters on the performance of relatively large, but depending on the performance requirements, performance parameters not the same, not to mention up too complicated, too big but not good performance , recommended the project needs to be a real test, such as concurrency requirements 800 , it can be set to: # maximum number of requests a connection MaxKeepAliveRequests 1000 (value is 0 , no limit number) # number of threads per process, maximum 1920 . NT starts only son two processes can not be set to start multiple processes ThreadsPerChild 1000 (up to 1920 ) # Each child process can handle the maximum number of requests MaxRequestsPerChild 1000 (value is 0 , no limit number) These three parameters according to different needs, different servers to adjust.

I n s t a l la n dc o n f i g u r e Tomcat o r JBoss
1 , for Tomcat or JBoss installation, are not explained here, now we are using the Apache + JBoss , however, JBoss also used Tomcat , so here's configuration is also suitable for Tomcat 's;
www.360doc.com/content/07/0316/10/7147_399335.shtml

2 , for the JBoss configuration is very simple, only need to change two places will

4/7

9/4/13

Apache JK Tomcat load balancing configuration

2 , for the JBoss configuration is very simple, only need to change two places will be able to: First place: to enter jboss-4.0.2\ Server \ Default \ Deploy \ jbossweb-tomcat55.sar , open server.xml , about the first 32 lines or so, there, Which included a parameter becomes: Second place: Entering jboss-4.0.2\ Server \ default \ deploy \ jbossweb-tomcat55.sar \ META-INF directory, open the JBoss-service.xml , in about 110 lines, withfalse, To read: true There is a need to pay special attention to the place, JBoss in Tomcat , regarding AJP connection protocol's default configuration, it is not enough for a large amount of concurrent use, do some modifications, into the jboss-4.0.2\ Server \ Default \ Deploy \ jbossweb-tomcat55.sar , open server.xml , locate the place, here is the definition of AJP connector where it's configuration does not maxThreads items, default is 200 , we can make changes: <= "" Address = "$ {jboss.bind.address}" port = "8009" /> emptySessionPath = "true" enableLookups = "false" redirectPort = "8443" protocol = "AJP/1.3" maxThreads = "3000" /> maxThreads value depends on how much your concurrency set much is not good.

R u n
At this point, the entire configuration is complete, attention to the fact that, in each JBoss node, restart, or add a new JBoss node, you need to restart Apache , and for the server farm to a JBoss node shutdown , Apache will automatically detect, without restarting . If during operation, a group JBoss node shutdown , log on to the server already on the user's request will be wrong, this server is responsible for the session will be lost, but the Apache server will automatically detect this shutdown , the successor new requests will no longer boot this node. Responsible for requesting distribution for Apache servers, you need to consume a lot of CPU resources, so if during testing some Service Temporarily Unavailable or Server has shut down the connection prematurely such errors, which are generally caused by the server configuration is not good enough, or is Apache , Tomcat , and application of some of the configuration is not enough to use, this time we should consider for better optimization of machine or application configuration.

F r e q u e n t l yA s k e dQ u e s t i o n s
One, Can not Connect to Server : Can not connect to the server. This is the server configuration problems, the server can not afford too many concurrent connections, the need to optimize the server's configuration: Such as the operating system uses a later version, such as Windows 2003 Server , Optimization tomcat configuration: maxThreads = "500" minsparethreads = "400" maxSpareThreads = "450" But tomcat supports up to 500 concurrent access Optimize apache configuration: ThreadsPerChild 1900 MaxRequestsPerChild 10000 Two, Action.c (10): Error -27791: Server has Shut down the Connection prematurely HTTP Status-Code = 503 (Service Temporarily Unavailable) are generally caused due to server configuration is not good enough, the need
www.360doc.com/content/07/0316/10/7147_399335.shtml 5/7

9/4/13

are generally caused due to server configuration is not good enough, the need to optimize hardware and adjustment program.

Apache JK Tomcat load balancing configuration

Three, unable to process the request: When we entered ***. do command, Apache returns an error message, but rather to connect tomcat was no problem. There is no reason to . do command forwarded to tomcat process. Solution as follows: In the apache config file the following: JkMount / *. Jsp loadbalancer JkMount / *. Do loadbalancer
Previous: Distributed deployment of Apache and Tomcat, integration experience (complete success) Next: Apache HTTP Server and Tomcat introduction of the three connections
web linux pc

linux

web

Share to:

Flowers ( 0 )

(This article is floating in the north ... the first possession of the source text URL )

5460

Similar articles apache and tomcat integration solutions to the picture can Apache andnot jboss be cluster positiveconfiguration .... tomcat cluster apache tomcat load cluster with three methods Tomcat cluster, buttoned up! Easy Apache Tomcat clustering and load Apache + JK + Tomcat load balancing balancing Summary of project maintenance - simple configuration Apache + Tomcat Tomc ...configuration More

Close

Close

You might like

Exceptionally strong libido of a woman whose

What are the changes in a woman vagina?

Male and female body animation shows the main

Countries most women love penis size

appearance (Figure) points (Figure) performance (Figure)

Sex vaginal orgasm [knowledge] Baidu Recommended

4.. 2013 !!! ? 021-54.. , !!! ? .. !.. ,24

www.360doc.com/content/07/0316/10/7147_399335.shtml

6/7

9/4/13
Comments:

Apache JK Tomcat load balancing configuration

Hello, please log in or register to comment again

Sign in using partner sites:

Sina microblogging

QQ

Everyone

www.360doc.com/content/07/0316/10/7147_399335.shtml

7/7

Das könnte Ihnen auch gefallen