Tomcat6 a server using the company's default configuration, click on servers in the background while you scrap the whole, and checked the default value will be too small to cause PERMSIZE (16-64)
TOMCAT_HOME / bin / catalina.sh
Add a line: JAVA_OPTS = "-XX: PermSize = 64M-XX: MaxPermSize = 128m"
Problem solving (perhaps too many reasons to call the JAR files) to see some of the settings below are online
JAVA_OPTS = "-server-Xms800m-Xmx800m-XX: PermSize = 64M-XX: MaxNewSize = 256m-XX: MaxPermSize = 128m-Djava.awt.headless = true"
When its concurrent test, and it's basically 30 USER crash, and also modify the default number of connections setting: the following four lines TOMCAT6 in the red phase is not good, you can manually add, and basically solve the connection number of crashes caused by excessive. Specific values can be set with the actual situation according to
<Connector port = "80" protocol = "HTTP/1.1"
maxThreads = "600"
minSpareThreads = "100"
maxSpareThreads = "500"
acceptCount = "700"
connectionTimeout = "20000"
redirectPort = "8443" />
After this set, basically had no further crashes. . . . .
maxThreads = "600" / / / maximum number of threads
minSpareThreads = "100" / / / initialize number of threads created when
maxSpareThreads = "500" / / / Once you create a thread more than this value, Tomcat will no longer need to close the socket thread.
acceptCount = "700" / / specify if all that can be used to process the request threads are used, you can put the number of processing requests in the queue, more than the number of requests will not be processed
-------------------------------------------------- -------------------------------------------------- ------------------------------
A, Tomcat's JVM memory leak prompts
View% TOMCAT_HOME% \ logs folder, the log file out of memory error
Second, modify the Tomcat JVM
1, error: java.lang.OutOfMemoryError: Java heap space
Tomcat can use the default memory of 128MB, the application of the larger projects, this memory is not enough, it may cause the system to not run. A common problem is reported Tomcat memory overflow error, Out of Memory (system memory) exception, which causes the client shows 500 error, the use of general adjustment Tomcat memory will solve this problem.
Windows environment to modify "% TOMCAT_HOME% \ bin \ catalina.bat" file, in the beginning of the file add the following setting: set JAVA_OPTS =- Xms256m-Xmx512m
Linux environment changes "% TOMCAT_HOME% \ bin \ catalina.sh" file, in the beginning of the file add the following settings: JAVA_OPTS = '-Xms256m-Xmx512m'
Which,-Xms setting initialization memory size,-Xmx set maximum memory that can be used.
2, error: java.lang.OutOfMemoryError: PermGen space
PermGen space full name is the Permanent Generation space, refers to the memory of the permanent preservation areas, this is mainly the JVM memory and Meta information stored Class, Class Loader when it is being put PermGen space in it and store instances of the class (Instance) of the
Heap region different, GC (Garbage Collection) will not run in the main phase of the PermGen space to clean up, so if your application has a very CLASS, then it is possible PermGen space error, this error is common in web server for JSP to pre compile time. If you are under the WEB APP with a large number of third-party jar, its size exceeds the default jvm size (4M), it will produce this error information.
Increase in the first line of catalina.bat:
set JAVA_OPTS =- Xms64m-Xmx256m-XX: PermSize = 128M-XX: MaxNewSize = 256m -
XX: MaxPermSize = 256m
Increase in the first line of catalina.sh:
JAVA_OPTS =- Xms64m-Xmx256m-XX: PermSize = 128M-XX: MaxNewSize = 256m -
XX: MaxPermSize = 256m
3, JVM settings
-Xmssize in bytes
Set the initial Java heap size, the default size is 2097152 (2MB). This value must be 1024 bytes (1KB) multiples, and more than it big. (-Server option to default size to 32M.)
-Xmnsize in bytes
Eden object to set the initial Java heap size, default value is 640K. (-Server option to default size to 2M.)
-Xmxsize in bytes
Set the maximum Java heap size, the default value is 64M, (-server option to default size to 128M.) Maximum heap size to nearly 2GB (2048MB).
Note: Many of the garbage collector options depend on the heap size settings. Fine-tune the garbage collector in the memory of the way before use to confirm whether the correct set heap size.
Garbage collection: memory usage
-XX: MinHeapFreeRatio = percentage as a whole number
Modify the available heap memory after garbage collection, the minimum percentage of the default value is 40. If garbage collection after at least 40% of the heap memory is not released, the system will increase the heap size.
-XX: MaxHeapFreeRatio = percentage as a whole number
After changing the garbage collection and heap memory available before narrowing the maximum percentage of heap memory, the default value is 70. This means that if the garbage collection is followed by more than 70% of the heap memory, the system will reduce the heap size.
-XX: NewSize = size in bytes
Allocated memory for the objects in the Eden-generation set the default memory size. Its default value is 640K. (-Server option to default size to 2M.)
-XX: MaxNewSize = size in bytes
Allows you to change the upper limit of the initial object space, the memory required for the new object is assigned to this space, this option is the default value is 640K. (-Server option to default size to 2M.)
-XX: NewRatio = value
Changes in the proportion of old and new dimensions of space, the default value of this ratio is 8, meaning that new space the size of the old space of 1 / 8.
-XX: SurvivorRatio = number
Change the Eden space and remaining space of the object size ratio, the ratio of the default value is 10, meaning the size of the object space than Eden remaining space survivorRatio +2 times.
-XX: TargetSurvivorRatio = percentage
Set your desired use of the space remaining after extraction of the percentage of space, the default value is 50.
-XX: MaxPermSize = size in MB
Long-generation (permanent generation) the size, the default value is 32 (32MB).
Third, check the Tomcat JVM memory
1. Tomcat6 does not set any default user, and therefore need to manually Tomcat6 the conf folder under the tomcat-users.xml file to add users.
Such as: <role rolename="manager"/>
<user username="tomcat" password="tomcat" roles="manager"/>
Note: you add the need to restart Tomcat6.
2 Visit http://localhost:8080/manager/status, enter the above username and password to add.
3. Then as can be seen under the following JVM memory usage.
Free memory: 2.50 MB Total memory: 15.53 MB Max memory: 63.56 MB
Four, Tomcat connections setting
In the tomcat configuration file in server.xml <Connector ... /> configuration, and connection-related parameters are:
minProcessors: Minimum number of idle connections thread, used to improve system processing performance, the default value is 10
maxProcessors: Maximum connection threads, namely: the maximum number of requests processed concurrently, the default value is 75
acceptCount: maximum number of connections, should be greater than or equal maxProcessors, default is 100
enableLookups: Does Reverse domain name, value: true or false. In order to increase processing capacity, should be set to false
connectionTimeout: Network connection timeout, unit: milliseconds. Set to 0 to never time out, so that the settings are hidden. Usually set to 30000 milliseconds.
And the maximum number of connections in which the relevant parameters maxProcessors and acceptCount. If you want to increase the number of concurrent connections, should also increase these two parameters.
web server to allow the maximum number of connections is also subject to the operating system kernel parameters, usually Windows is 2000 or so, Linux is about 1000. Unix how to set these parameters, see the Unix command used to monitor and manage