Tomcat6 some tuning settings memory and connections

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

Reasons:
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.
Solution:

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

Heap size
-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.

JVM

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

分类:OS 时间:2011-01-24 人气:271
分享到:
blog comments powered by Disqus

相关文章

  • Class loader - the memory leak problem of 2 2010-07-29

    Serious warning: If there is any application other than from a reference cited by the J2EE application itself class loader loads the class and class instance object, then ClassLoader class loader memory leak problem arises. ClassLoader class loader m

  • [Change] Java Virtual Machine (JVM) in the memory settings Xiangjie 2010-07-30

    Java Virtual Machine (JVM) in the memory settings Xiangjie This article introduces you to the Java virtual machine, that is, how to set JVM memory, the GC to achieve good efficiency. In larger-scale applications, Java Virtual Machine (JVM) memory set

  • How to configure Tomcat's JVM virtual machine memory size 2010-08-24

    Tomcat itself does not directly run on computers need to rely on hardware-based operating system and a java virtual machine. You can choose your own need to select different operating systems and the corresponding JDK version (as long as is consisten

  • linux to change the maximum shared memory 2010-07-26

    System V IPC parameters Name Description Reasonable values SHMMAX Maximum shared memory segment size (bytes) At least several trillion (see text) SHMMIN Minimum shared memory segment size (bytes) 1 SHMALL The total amount of shared memory available (

  • WebSphere Application Server memory leak detection and diagnostic tools 2010-11-25

    Level: Intermediate School North Lee (lixuec@cn.ibm.com), Senior Software Engineer, IBM China Software Development Center November 21, 2006 This article describes how to implement WebSphere Application Server application memory leak detection, and IB

  • JAVA memory leak is divided into two situations 2011-07-12

    JAVA-memory is divided into two situations: When one is enough memory JVM heap memory is adequate, but just did not result in a continuous memory space, memory space such as a continuous array of applications: Java code String [] array = new String [

  • Optimization into a worry: String.split caused by "memory leak" 2010-03-29

    Has been praised Sun rigorous and elegant treatment technologies (bless Sun). Sun JDK source code in the Java libraries, even the notes are clear and regulatory norms Fan, javadoc comment use was also a meticulous reading comfortably familiar. Thus,

  • tomcat memory leak summary 2010-03-29

    http://www.beckdim.cn/?p=110 Tomcat in a production environment is very vulnerable to bad memory settings in memory overflow. The reason is not the same result in the memory, of course, is not the same approach. Here encountered under normal conditio

  • Java memory leak problem analysis 2010-03-29

    <! - Info --><!-- div> </ div> <div> <ul> <img src = "http://img1.e800.com.cn/service/temp/t12.jpg "/> <p> <a href=""> information first time </ a> </ p> </ ul> <ul&g

  • Java-based intensive training - memory leak. Memory leak 2010-04-08

    -------------------------------------------------- ------------------------------------------ Reference: http://developer.51cto.com/art/200906/129346.htm -------------------------------------------------- ------------------------------------------ Po

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.260 (s). 12 q(s)