Tomcat face questions Summary

See: Tomcat face questions Summary: https: //blog.csdn.net/qq_25934401/article/details/81536958

1, the default port Tomcat is how much, how to modify?

tomcat default port 8080, the port will occupy 8005,8009 and 8443.

Enter tomcat installation directory, edit the file "installation directory \ apache-tomcat-7.0.6 \ conf \ server.xml" (you can use Notepad to open) 

2, tomcat servlet container is how to create an instance of the class? What principle is used?

When the container starts, it will read web.xml files for all web applications in the webapps directory, and then parse xml file, 

and read the servlet registration information. Then, each registered application loaded servlet class, and by way of example of the reflection. 

(Sometimes also in the first instance of the request) plus if positive, then at the outset instantiated register servlet, 

if you do not write or negative, the first request instantiated.

3. Memory Tuning

Memory mode is set in catalina.sh, in catalina.bat , the JAVA_OPTS variable to adjust, because the parameters will start behind the JAVA_OPTS as a startup parameter to the JVM process. 
Setting is as follows: JAVA_OPTS = "$ JAVA_OPTS -Xmx3550m -Xms3550m -Xss128k -XX: NewRatio = 4 -XX: SurvivorRatio = 4"
its parameters are as follows:
-Xmx3550m: setting the maximum memory available JVM 3550M.

-Xms3550m: Setting JVM memory to promote 3550m. This value can be set the same -Xmx, each JVM to avoid reallocate memory garbage collection completes.

-Xmn2g: Set the size of the young generation 2G. The young generation throughout the heap size = size + size + old generation of permanent generation size. Permanent generation is generally a fixed size 64m, so the increase in the young generation, will reduce the size of the old generation.
This value greater impact on system performance, Sun official recommended configuration for the entire heap of 3/8.

-Xss128k: Sets the stack size for each thread. JDK5.0 after each thread stack size is 1M, before each thread stack size is 256K. Thread more application memory size of the required adjustment.
At the same physical memory, reducing this value can generate more threads. However, the number of operating system threads within a process still limited, not unlimited generation, experience in 3000 and 5000.

-XX: NewRatio = 4: Set the young generation (including Eden and two Survivor areas) the ratio of the old generation (excluding permanent generation). Is set to 4, the share of the young generation and the old generation ratio of 1: 4, the young generation accounts for 1/5 of the entire stack
-XX: SurvivorRatio = 4: Set the size of the area ratio of Eden Survivor young generation area. Is set to 4, the ratio of the two regions with a Survivor Eden zone is 2: 4, the total area Survivor a young generation 1/6
-XX: = MaxPermSize the 16m: setting the size of the permanent generation 16m.
-XX: MaxTenuringThreshold = 0: set the maximum age of garbage. If set to 0, then the younger generation of the object without Survivor areas, directly into the old generation.
For more of the old generation of applications that can improve efficiency. If this value is set to a large value, then the young generation objects will be copied many times in Survivor areas, which can increase the object and then the young generation of survival time,
an increase in the introduction to the young generation namely recycling.

11. Monitoring memory usage of Tomcat

Use JDK comes with jconsole can be relatively straightforward to see the memory usage, thread status, such as the total current load of classes; 

JDK comes jvisualvm can download plug-ins (such as GC, etc.), you can view richer information . If Tomcat local analysis, you can also sample memory and the like, to check use of each class

 

Guess you like

Origin www.cnblogs.com/lukelook/p/11118344.html