Profiling & Performance analysis

Profiling & Performance analysis

Introduction


The following article will focus on tools, best practices, base knowledge helful for working out performance optimizations.


Content

  1. User CPU / System CPU, CPU load average
  2. Network kb load
  3. top, sar, network sniffing (tcpflow/dump),
  4. req/sec tomcat
  5. Apache Bench, JMeter (client,server,graph)
  6. jstack, jmap, hprof
  7. Metrics, Java Melody
  8. JProfiler, YJP, VisualVM
  9. htop, hiostat

The project

Lets first create a small project, we will use it as an example server we are going to profile.
Our project will sit on top of tomcat, a standard restful service, accepting requests, performing actions, returning json results.

CPU

User CPU / System CPU


top
1 to show multiple cpu
SHIFT-H to show threads info
cd ~/tmp;javac -J-agentlib:hprof=cpu=samples Hello.java


CPU Load Average


sar -q 1 2000


CPU


When you profile a server in a search of high cpu consumption areas you should first understand which cpu consumption are you looking at.  Using the tools shown below note that its possible to check out the user cpu and system cpu.  Its important to understand the differences between the two.  The user cpu is the cpu as directly consumed by apps running on linux, some of the app calls would be directed into the kernel for kernel services and operations.  The cpu used by the kernel is called system cpu.

lets start by running sar command to check out the cpu on a linux machine.  (I will describe further in more details the sar command, for now, flow with me..)

I'm going to use the following servlet app on tomcat7 for tests:



Comments