Monday, October 7, 2013

Java Application performance Tuning Overview


Does every application need performance tuning and the answer would be No. The additional efforts need to be exerted when the application is not performing well as expected. No matter what kind of language is used to write the application, expectation cannot be set to get a high performance as soon as you complete debugging or coding. A considerable amount of expertise is needed for tuning the application. Tuning applications varies from application to application based on functionality and different resources used during the execution. To tune an application you would need knowledge on operating system, virtual machines and system architecture. Having the domain knowledge of the application give you an upper hand to successfully tune the application.

Since we are going to focus more on the performance tuning to be done for java application. The java applications run on a java virtual machine (JVM). We need to have the knowledge of JVM internals. Since the JVM is a process running on operating system we need to know how operating system allocates resources for the process. Finally the operating system runs on some hardware so we need to also have some idea of the hardware. 

Our focus is mainly on the java tuning so we need to have considerable knowledge about concurrency, locking, class loading and object creation. Finally integrating all the knowledge one should approach for performance tuning. The performance tuning of an application is a repetitive process until the expected benchmark is derived.

The below figure is the flow chart from the book  “Java Performance” by Charlie Hunt and Binu John. This chart shows the process of java application performance tuning.





Decision Making Process


The JVM distributed model is related to making a decision of operating java application on a single JVM or to operate on multiple JVM. The factors driving to the deciding factor is based on availability, maintainability and responsiveness.

The selection of JVM is the most important part of decision making. A 32-bit JVM or a 64-bit JVM can be used. Now the question raises on the overall performance rating of a 32-bit JVM or a 64-bit JVM, which one is better? The answer would be a 64-bit JVM hosted on 64-bit operating should perform better than a 32-bit JVM on a modern 64-bit operating system. Based on testing performed by red hat it was found that the 64-bit JVM was 3.9% faster than 32-bit JVM using a 2GB of heap size. For a 32-bit JVM the heap size is limited to mostly 2GB. The advantage of using a 64-bit JVM is that a heap size more than 2 GB can be used till 20 GB. Moreover the 64-bit JVM has the concept of compressed ordinary object pointer (OOPs). OOPs implement a compression of the internal memory pointers within JVM for objects reducing the size of the heap. The compression makes 64-bit JVM competitive to 32-bit JVM. Further improvement can be still done by using the feature of JVM and operating system called large page memory.

The decision to derive the output of performance depends on continuous sampling/testing using different memory settings and choice of GC to be used. We need to have the data like Request per second (RPS), Operations per second (OPS).

No comments:

Post a Comment