petek, 11. december 2015

Jmeter and JavavisualVM

Writing test cases in on file can be very used but it can have negative influence of test execution. One of the important thing   is memory consumption. IT is known that Jmeter uses a lot of memory that can lead to Out of memory, consumes a lot of CPU.  Jmeter can handle much more than 100 threads and when this oversized then another performance tool should be used.

JavavisualVM

JavavisualVM is tool found in %javahome%bin directory. Tool help us to see how much thready, CPU memory is used when test is running.

Picture below shows GUI of JavavisualVM:

Picture upper show graph for
  • CPU usage
  • Classes 
  • Memory - hoe many momory is alocated for java on how much is used
  • Threads - how may thread are executing on host in specific test
Be aware this tool have also big impact on you system, use only when you need to identify how many memory you use for test and how many threads is possible to run on the computer.

Picture below shows test execution:
  •  CPU is very high 90 %
  •  Memory is used 1 GB
  • Treads running 2000.



This machine is not capable to run 2000 thread. This will have impact on response times, because of CPU switching and test may not affect a real picture of system under test. Normally 2 CPU machine can handle around 700 thread ( mostly read on jmeter web site or forums).

Jmeter performance tips


To improve performance of jmeter test keep in mind important things:
  • use non GUI run
  • remove all listeners
  • save file in CSV
  • use regular expression
  • avoid using xpath
  • JSR223 + Groovy scripting
  • generate reports after test are finished ( check other blogs)

Memory increase


Memory can be increased in jmeter.bat file. Search for text set HEAP:

-          set HEAP=- Xms1024 –Xmx1024m


I normally leave system around 1,5 GB, everything else is reserved  for java. It recommended to have machines with 4GB and more.

The definition of heap is:

       set HEAP= -Xms<initial heap size> -Xmx<maximum heap size>

 Summary

When creating tests always keep in mind to write optimized code, avoid listeners, run in nongui. Before start testing identify machines how much memory is reserved for java and how much are used when test is running. If machines are overheaded results can not give correct picture of system under tests, in this situation is better to add few more machines or search for optimal load.
One of the important thing which you should keep in mind is size of .jmx file. The size can have impact on memory consumption. If file have 8 MBytes or more you can used all reserved memory with 100 threads. So always enable only one test in use. On the internet there is a lot of help setting and tuning jmeter.

1 komentar:

  1. Find a Casino Hotel Near you and Get a $5000 - DRMCD
    Discover 제주 출장샵 a Casino Hotel near you and get a $5000 casino 여주 출장안마 bonus. You can also use these 군산 출장마사지 free casino deals to play free slots online 삼척 출장샵 like 광명 출장마사지 Mega

    OdgovoriIzbriši