arthas
Diagnose and troubleshoot Java applications in real-time
TLDR
Start Arthas
Reconnect Arthas (default port used by Arthas is 3658)
Exit the current Arthas client without affecting other clients. equals exit、logout、q command
Terminate the Arthas server, all the Arthas clients connecting to this server will be disconnected
SYNOPSIS
java -jar arthas-boot.jar [pid]
PARAMETERS
[pid]
The process ID (PID) of the Java application to attach to. If no PID is provided, Arthas displays a list of running Java processes that can be targeted. Arthas will use the attach command if the java process is already running.
DESCRIPTION
Arthas is a powerful, open-source, online Java diagnostic tool inspired by alibaba/jvm-sandbox. It monitors, diagnoses, and troubleshoots Java applications in real-time without requiring application restarts or code changes. It offers various features like viewing thread stacks, monitoring method execution details (parameters, return values, exceptions), hot-swapping code, classloader manipulation, and more. Arthas utilizes byte-code instrumentation techniques using the Java Agent and allows attaching to running JVM processes. This enables developers and operators to quickly identify performance bottlenecks, debug complex issues, and gain deeper insights into application behavior in production environments. It's commonly used for troubleshooting problems such as high CPU usage, slow response times, unexpected exceptions, and memory leaks.
CAVEATS
Arthas modifies the bytecode of the target application and uses the javaagent technology, it introduces some performance overhead and might have compatibility issues with certain Java frameworks or libraries. Use with caution in production environments. Requires appropriate permissions to access and modify the target Java process.
KEY FEATURES
Dashboard: Provides a real-time overview of the JVM's health, including CPU usage, memory usage, thread activity, and GC statistics.
Thread: Displays thread information, including thread stacks, CPU usage, and blocked threads.
Watch: Allows you to monitor the execution of specific methods, logging their parameters, return values, and thrown exceptions.
Trace: Traces the execution path of a method, showing the time spent in each step.
Stack: Prints the stack trace of a specific method or thread.
Sc: Searches for classes loaded in the JVM.
Sm: Searches for methods within a class.
Redefine: Hot-swaps the bytecode of a class without restarting the application. (Experimental)
ClassLoader: Manages and inspects classloaders within the JVM.
INSTALLATION
Arthas is typically installed by downloading the `arthas-boot.jar` file from the official repository or a trusted source. To start Arthas, run `java -jar arthas-boot.jar` in your terminal, and then select the PID of the Java process you want to diagnose.
HISTORY
Arthas was developed by Alibaba Group and later open-sourced. It addresses the need for a robust and non-intrusive way to diagnose Java applications in complex production environments. Over time, it has gained significant popularity and has been continuously improved and extended with new features and capabilities by the open-source community.