- System requirements
- Profiler architecture
- Running the profiler
- Profiler activation
- Start profiling
- IDE integration
- Java server integration wizard
- Attach profiler to a running application
- Remote profiling
- Docker
- Profiling in Docker container with direct connection
- Profiling in Docker container with YourKit Connection Broker
- Enabling profiling manually
- Startup options
- Connect to profiled application
- Profiling troubleshooting
- Profiling overhead: how to reduce or avoid
- Solving performance problems
- CPU profiling
- Threads
- Deadlock detector
- Memory profiling
- Garbage collection
- Monitor profiling
- Exception profiling
- Probes: monitor events of various kinds
- Performance Charts
- Inspections: automatic recognition of typical problems
- Automatically trigger actions on event
- Summary, snapshot annotation, automatic deobfuscation
- Time measurement (CPU time, wall time)
- Filters
- Snapshot directory customization
- Export of profiling results to HTML, CSV, XML, plain text
- Profiler Java API
- Profiler HTTP API
- Command line tool to control profiling
- Settings
- FAQ: How to profile in my scenario?
Profiling in Docker container with direct connection
This article describes how to set up profiling of Java application running in a Docker container.
The container will be configured in such a way, that local port
*:10001
is mapped to the port of the profiler agent
running inside the Docker container.
You will be able to connect profiler UI to this port using
direct discovery method.
On Docker side
1. Add few lines to your Dockerfile
:
-
Install YourKit Java Profiler agents:
RUN wget https://www.yourkit.com/download/docker/YourKit-JavaProfiler-2022.9-docker.zip -P /tmp/ && \ unzip /tmp/YourKit-JavaProfiler-2022.9-docker.zip -d /usr/local && \ rm /tmp/YourKit-JavaProfiler-2022.9-docker.zip
-
Load the agent to the JVM by adding the Java command line option
-agentpath
.For example, if you start your application with
java -jar my-app.jar
...do it like this:
java -agentpath:/usr/local/YourKit-JavaProfiler-2022.9/bin/linux-x86-64/libyjpagent.so=port=10001,listen=all -jar my-app.jar
In this example:
-
The agent is configured to listen port
10001
. The same port should be used in the-p
option when running the container (see below). If you decide to use a different port, please ensure you have changed it everywhere. -
Profiler agent is a Linux 64-bit agent, compiled for glibc. If you run Docker on another platform, please choose appropriate agent path from the table below:
Platform Agent path Linux (glibc) x86, 64-bit /usr/local/YourKit-JavaProfiler-2022.9/bin/linux-x86-64/libyjpagent.so
ARM 64-bit (AArch64) /usr/local/YourKit-JavaProfiler-2022.9/bin/linux-arm-64/libyjpagent.so
ppc64le, 64-bit, little-endian /usr/local/YourKit-JavaProfiler-2022.9/bin/linux-ppc-64le/libyjpagent.so
Alpine Linux (musl) x86, 64-bit /usr/local/YourKit-JavaProfiler-2022.9/bin/linux-musl-x86-64/libyjpagent.so
ARM 64-bit (AArch64) /usr/local/YourKit-JavaProfiler-2022.9/bin/linux-musl-arm-64/libyjpagent.so
Windows x86, 64-bit <profiler directory>\bin\windows-x86-64\yjpagent.dll
ARM 64-bit (AArch64) <profiler directory>\bin\windows-arm-64\yjpagent.dll
Please find detailed description of how to specify
-agentpath
and choose the agent startup options here.
-
The agent is configured to listen port
2. Build the container for the modified Dockerfile
.
3. When running the container, make the agent port visible with the option -p
:
docker run -p 10001:10001 my_container
Connect to the profiled application
When the application is running in the container,
connect to it from the profiler UI
using the direct discovery method.
You will need to specify IP address of your Docker container
and 10001
as a port number.
If you are running Docker locally on your developer machine,
please use localhost
as a container address.
Notes on a special case: a container with restricted home directory
For security reasons, the user home directory in a docker container may not exist or be read-only.
In this case, the agent will use /tmp
instead of <user home>/Snapshots
as the default snapshot directory.
The snapshot directory may be overridden with the startup option
dir
.
The profiler agent log file neither can be created in its normal location <user home>/.yjp/log
.
Should you need the agent log file for troubleshooting purposes, specify a writable
directory for it with the startup option
logdir
.