TOMCAT7 1000 concurrency Configuration tomcat7 configuration optimization

Source: Internet
Author: User
Tags xms

  1. Modify the Tomcat/conf/server.xml configuration file.
  2. <executor name= "Tomcatthreadpool" nameprefix= "catalina-exec-"
  3. "maxthreads=" minsparethreads= "/>"
  4. <connector executor= "Tomcatthreadpool"
  5. Port= "protocol=" http/1.1 "
  6. connectiontimeout= "20000" enablelookups= "false"
  7. Redirectport= "8443" uriencoding= "UTF-8" acceptcount= "+"/>
  8. Modify the Tomcat/bin/catalina.bat configuration file to the following.
  9. This sentence is added to the
  10. REM---------------------------------------------------------------------------
  11. REM Guess catalina_home if not defined
  12. The position between, do not add to those if inside go, otherwise not necessarily will take effect.
  13. Set java_opts=-xms1024m-xmx1024m-xx:permsize=128m-xx:maxpermsize=256m
  14. If you have questions.
  15. Echo%java_opts%>d:\java_opts.log

Mainly modified the MaxThreads, Acceptcount. Google data said, "If you want to increase the number of concurrent connections, you should increase both parameters."


1. The number of threads in Tomcat is debatable. Too many thread leads to excessive switching and severe performance degradation. This quantity should be the load-carrying capacity of your individual machine and the result of the stress test. Do not increase arbitrarily. In general, 256-512 are already very high values.
2. JVM parameter configuration, you this will cause serious stop world time. If you want to apply a gentle response, generally see your application for temporary memory requirements, generally speaking,-xmn128-256m is enough, this depends on your pause time calculation, you put GC collection print out, and then study the maximum pause time. This my blog said more detailed. You go and see it.
3. -xss128k This parameter, it is recommended that you set to 256k, otherwise it is not easy to use, especially your program has more recursive behavior. such as sorting.
4. In addition, if you want to improve the memory performance, you can look at the large memory settings. Not very good operation, I have not tested.
5. In terms of performance improvements, I recommend that you use the Linux kernel 2.6.22+ version, JAVA6 is not very important for 32 bit. This promotion is very large.

32 bit, your understanding of the memory that Java can configure is wrong. Generally speaking 1. 5G configuration, can cause a problem with the JVM process, this test I did, generally high pressure operation after 2-3 days, the JVM will crash, I do not quite understand why, there may be JAVA5 problems in the CMS caused. It is generally recommended to configure memory at 1280m under 32 bits.
=================================================================================

The heap Size should not exceed 80% of the available physical memory, typically set the-XMS and-XMX options to the same heap memory allocation (consistent when the traffic is larger)

The initial memory allocated by the JVM is specified by-XMS, the default is physical memory 1/64;JVM the maximum allocated memory is specified by-XMX, which defaults to 1/4 of the physical memory. When the default free heap memory is less than 40%, the JVM increases the heap until the maximum limit of-xmx, and when the free heap memory is greater than 70%, the JVM reduces the heap until the minimum limit of-XMS. So the server generally sets-xms,-xmx equal to avoid resizing the heap after each GC.

Non-heap memory allocation
The JVM uses-xx:permsize to set the non-heap memory initial value, which defaults to 1/64 of the physical memory, and the maximum non-heap memory by Xx:maxpermsize, which by default is 1/4 of physical memory.
JVM Memory Limit (max)
First, the JVM memory is limited to the actual maximum physical memory (nonsense!). hehe), assuming that the physical memory is infinitely large, the maximum value of the JVM memory is very much related to the operating system. Simply put, 32-bit processor Although the controllable memory space has 4GB, but the specific operating system will give a limit, this limit is generally 2GB-3GB (generally speaking, Windows system under the 1.5g-2g,linux system for 2G-3G), There is no limit to processors over 64bit. (test out the maximum supported values using the Java command)

The following parameters of the context element in Tomcat's server.xml should fit

<connector port= "8080"
Maxthreads= "150"
Minsparethreads= "25"
maxsparethreads= "75"
acceptcount= "100"
/>

Answer:

Maxthreads= "150" means up to 150 connections at a time
Minsparethreads= "25" means that even if no one is using it, open so many empty threads waiting
maxsparethreads= "75" means that if you can empty up to 75 threads, such as 80 people at a time, and no one has access after that, Tomcat does not keep 80 empty threads, but turns off 5 empty.

acceptcount= "100" when the number of simultaneous connections reaches MaxThreads, it is also possible to receive queued connections that exceed this connection and directly return a deny connection.

Based on your configuration recommendations
Maxthreads= "500"
minsparethreads= "100" If your site has a large number of frequent visits, the default is to open the larger
maxsparethreads= "300"
acceptcount= "100"
It's just that your server can support so many users, but it depends on what you have installed and whether your program is efficient enough.

(second method)

A few configuration instructions in Tomcat

How to increase the number of Tomcat connections


In the configuration in Tomcat configuration file Server.xml, the parameters related to the number of connections are:
Minprocessors: Minimum number of idle connection threads for improved system processing performance with a default value of 10
Maxprocessors: Maximum number of connection threads, which is the maximum number of requests concurrently processed, with a default value of 75
Acceptcount: Maximum number of connections allowed, should be greater than or equal to Maxprocessors, default value is 100
Enablelookups: Whether to reverse the domain name, the value is: TRUE or false. To improve processing power, set to False
ConnectionTimeout: Network connection time-out, unit: milliseconds. Set to 0 to never time out, so the setting is hidden. It can usually be set to 30000 milliseconds.

The parameters associated with the maximum number of connections are maxprocessors and Acceptcount. If you want to increase the number of concurrent connections, both parameters should be increased.


The maximum number of connections allowed by Web server is also subject to the kernel parameter settings of the operating system, usually Windows is about 2000, and Linux is about 1000. For how to set these parameters in Unix, see Common UNIX monitoring and Management commands

Examples of configurations in TOMCAT4:
port= "8080" minprocessors= "ten" maxprocessors= "1024"
Enablelookups= "false" redirectport= "8443"
Acceptcount= "1024x768" debug= "0" connectiontimeout= "30000"/>

The listening configuration for the other ports, and so on.

2. How to disable files in a column directory in Tomcat
In {tomcat_home}/conf/web.xml, set the listings parameter to False, as follows:

...

Listings
False

TOMCAT7 1000 concurrency Configuration tomcat7 configuration optimization

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.