Java Enterprise Application "fifth" Tomcat monitoring

Source: Internet
Author: User
Tags unique id

Tomcat uses the Ip_hash rule as much as possible so that the same IP connection is on the same machine. Tomcat Performance Optimizations
    • Jps
    • Jstack
    • Jmap

First, Jps

Used to view the specific state of all processes based on the hotspot JVM, including the process ID, path of process initiation, and so on.
Similar to PS on UNIX, used to display locally-privileged Java processes, you can view a few Java programs running locally,
and show their process number. When using JPS, you do not need to pass the process number as a parameter.
JPS can also display the Java process on a remote system, which requires the remote provider to open the Jstat service, as well as RMI notes and services,
However, common use is to view the local Java process.
Command format:
JPS [Options][hostid]
Common parameter Description:
The-m output is passed to the main method parameter, and if it is an inline JVM, the output is null.
-L OUTPUT The full package name of the application main class, or the full path to the application jar file.
-V output passed to the JVM parameters.

Common commands:
View Process Id:jps
View program startup path, etc.: JPS-LVM

Second, Jstack
If a Java program crashes to generate a core file, the Jstack tool can be used to obtain information about the core file's Java stack and the native stack, making it easy to know if the Java program is crashing and where the problem occurs in the program. In addition, the Jstack tool can be attached to a running Java program to see the Java stack and the native stack of the Java program that was running, and jstack is useful if the Java program that is running now renders hung state.

Command format:
$jstack [Option]pid
$jstack [Option]executable Core
$jstack [Option][[email Protected]]remote-hostname-or-ip

Common parameter Description:
OPTIONS
-F Jstack [-l] PID cannot respond when forcing the print stack
-L long list, print additional information about the lock, such as ownable synchronizers list belonging to Java.util.concurrent
-m mixed-mode output (including Java and local C + + fragment) stacks.
The process number of the Pid:java application can be obtained by JPS;
Executable: Java executable program that produces core dump;
Core: Print out the core file;
REMOTE-HOSTNAME-OR-IP: Name or IP of the remote debug server;
Server-id: Unique ID, if there are multiple remote debug services on a single host;

three, Jmap
Print out a Java process (using PID) in memory, all ' Objects ' (e.g., the number of objects that are produced). The
tool can output all in-memory objects, and even the heap in the VM can be output as text in binary. Use the method Jmap-histo pid.
If you use Shell Jmap-histo Pid>a.log to save it to text, after a while, using the text Comparison tool, you can compare which objects the GC recycles. Jmap-dump:format =b,file=outfile 3024 The memory heap of the 3024 process can be output to the outfile file, and with the Mat (Memory analysis tool) Tool) or with jhat (Java Heap analysis tool) to visually visualize current memory problems in the form of an image. The
64-bit machine needs to be used as follows:
jmap-j-d64-heap PID
Command format:
Jmap [Option]pid
Jmap [option]executable core
Jmap [ Option][[email protected]]remote-hostname-or-ip

Parameter description
1), Options:
Executable Java executable from which, the core dump was produced.
(Probably the Java executable that generated the core dump)
Core dump file that will be printed with the information
Remote-hostname-or-ip the host name or IP of the Remote Debug service
Server-id Unique ID, if multiple Remote debug services on a single host
2), Basic parameters:
-dump:[live]format=b,file=<filename> using the Hprof binary form, the output JVM's heap content to the file =.live sub-option is optional,
If you specify the live option, only the live object is exported to the file.
-finalizerinfo printing information for objects that are waiting to be recycled
-heap Print Heap profile, GC used algorithms, heap configuration and use of the wise heap
-histo[:live] Prints the number of instances per class, memory consumption, class full name information. The internal class name of the VM is prefixed with "*". If the live child parameter is added, only the number of live objects is counted.
-permstat Prints Classload and JVM head for a long layer of information. Contains the name of each classloader, the liveliness, the address, the parent ClassLoader, and the number of classes loaded. In addition, the number of internal strings and the amount of memory consumed are also printed.
-F coercion. Use the-dump or-histo parameter when the PID is not appropriate. In this mode, the live sub-argument is invalid.
-H|-HELP Printing Auxiliary Information
-j Pass parameters to Jmap-initiated JVM.
The Java process ID that the PID needs to be printed with the phase information

Enterprise Case: Java process consumes too much CPU

    1. JPS gets the PID of the Java process.
    2. Jstack PID >> java.txt Export CPU consumes high process line stacks.
    3. Top-h-P PID to see which thread of the corresponding process is consuming high CPU.
    4. echo "OBASE=16; pid "|BC converts the PID of the process to 16 binary.
    5. In the second step of the exported Java.txt, look for the thread PID converted into 16 binary. Find the corresponding line stacks.
    6. Analyze what business operations are doing with high-load line stacks. Optimize the program and handle the problem.

Java Enterprise Application "fifth" Tomcat monitoring

Related Article

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.