Youtkit - Java Profiler
"Yourkit" is a useful profiler for Java based applications. The "Yourkit" is not a free product but it does come with a free trial of one month or so when writing this article. Its worth to give a hands on trial with this tool :
You can read more on "Yourkit" profiler itself here : https://www.yourkit.com/
As a developer, one important factor to consider while writing your code is how well your application handles stress/load, latencies, memory foot prints, CPU usage etc.
The main goal of this article is to show how to use YOURKIT profiler and debug performance of applications (typically JAVA - atleast what I have tried so far..)
You can read more on "Yourkit" profiler itself here : https://www.yourkit.com/
As a developer, one important factor to consider while writing your code is how well your application handles stress/load, latencies, memory foot prints, CPU usage etc.
The main goal of this article is to show how to use YOURKIT profiler and debug performance of applications (typically JAVA - atleast what I have tried so far..)
Lets go through some basics of Yourkit agents. There exists a "yourkit" agent on server side which we can directly attach to a running JAVA process. One thing to note its awesomeness is that there is no need to re-run/stop the JAVA process for attaching this debugging agent (aka Yourkit agent) on fly. On client side, Yourkit comes with a rich UI that will be able to connect to remote agent which will grab performance stats for us. Enough of theory and lets get on our hands trying ...
In this example, I would show steps to attach profiler to your already running java process on a remote server (B). And then you can start viewing the profiled statistics (CPU + memory + Others ) by connection to remote machine from your developer instance.
- You need to install yourkit both on local development machine and remote machine that you wish to profile
- On local dev machine (Launch UI) :
- cd to bin and then execute ./yjp.sh -> This will open a console to debug
- On Remote server (On host where you wish to profile)
- scp the yjp.tar file to remote machine. Untar it
- cd to bin directory and attach the yourkit agent to the process you want to profile
- This can be done : ./yjp.sh -attach -> And then select the process id you want to attach. That’s it
- Or other way is ./yjp.sh -attach <PID>
- Open the specific port on which yjp agent is listening. Not the one application is listening (Usually the ports will be ranging from 10001 or so..)
To open the port that yourkit agent is listening to, [This step is not necessary if ports are already opened]
iptables -A INPUT -p tcp --dport <yourkit_port/10001> -j ACCEPT
service iptables restart
- On local dev machine - yourkit application, click on "Connect to remote application"
Enter
<hostIPaddress>:<port#ofYJP>
That’s
it !! Profiler is now attached and you can start debugging and analyzing performance:)
References :
- You can download yourkit from here.
Comments
Post a Comment