Sunday 10 December 2017

Importance of the Java heap size In WebSphere Application Server

Introduction

Java heap is the area of memory that is used by the Java virtual machine (JVM) for storing Java objects. Optimal Java heap size is application and use dependent. Setting the JVM heap size is directly related to the number of server instances that needs to be started on a specific node and the total RAM available on the machine. The maximum heap should be incremented not to exceed 50% of overall physical memory. The Java heap memory is used by the applications that are deployed and the component running in WebSphere Application Server. It is extremely important to monitor for Java heap size usage, which can be done by enabling verbose Garbage Collection. Every WebSphere Application Server instance runs in its own JVM. The default JVM setting for the initial heap, which is 50 MB, and the maximum heap, which is 256 MB, are usually good enough for very small volume applications. However, they are not good for a live production environment.

The following list describes Java Heap Size issues that I have seen in numerous common Java Virtual Machine problems throughout my technical support years. Most of these issues can easily be prevented by taking simple precautionary steps. So, if you are a WebSphere Application Server administrator, this is your must-read!


Why does the JVM heap size setting need to be tuned?

JVM heap size settings will likely need to be tuned to support a combination of the following scenarios:

A very large application is deployed.
A large number of applications are deployed.
A high volume of transactions need to be handled concurrently and a large size request.

What is the importance of setting the Java heap size to a larger value?

Allows more objects to be created.
Takes longer to fill.
Allows the application to run longer between Garbage Collection events.


What issues occur when you set the Java heap size to a smaller value?

Holds fewer objects.
Fills more quickly.
Garbage collected more frequently.
May lead to an out-of-memory error.

What are the two main areas to watch for when it comes to JVM heap size?

How quickly does the heap size grow?
How long does it takes to perform Garbage Collection?


What are the common Java heap size issues in WebSphere Application Server?

A common issue with Low heap size is an out-of-memory error. If you are deploying a very large application using the administrative console, it can fail with out-of-memory error. In this case, you need to increase the maximum Java heap size value of the Deployment Manager and the Node Agent.
DRS uses the High Availability Manager to transfer data from one server to the other server. An out-of-memory error can happen on the server that cannot handle large objects. The solution is to increase the Java heap size on the failing server.
Installing a large application using a wsadmin script will throw an out-of-memory error. The solution is to increase the Java Heap in the wsadmin script. See the following blog for information on how to edit the wsadmin script.
https://www.ibm.com/developerworks/community/blogs/timdp/entry/avoiding_java_lang_outofmemoryerror_when_installing_application_with_wsadmin35


What needs to be done if you see an out-of-memory error with the default Java Heap Size?

If you are seeing a Java heap out-of-memory error and you are using the default or a small heap size, the first step is to increase the heap size. Sometimes this approach resolves the problem as it was just the application needing more memory than was configured. Other times, you will still see the out-of-memory error, but with the larger heap size. There is more of a potential for leaking objects, which makes them easier to find in a heap dump. With a small heap, there will not be many leaking objects, which makes them hard to find.


How do you determine that the maximum heap size is too large or too small for your application?

If garbage collection takes a long time to clean up objects with a large heap, you can reduce the maximum heap size. If garbage collection frequency is too high, the heap might be too small for the application and garbage collection needs to run frequently. Thus, you might increase the maximum heap size.


How do you change the Java heap size settings?

The JVM heap size settings can be changed from the administrative console using these steps:
Expand Servers > Server Types > WebSphere application servers and click your server name.
Click Java and process management > Process definition > Java virtual machine.
The JVM Heap size can be adjusted by using the Xms: Initial Java Heap Size and Xmx: Maximum Java Heap Size command-line parameters.

No comments:

Post a Comment