6.4.2 Determining initial heap size

Starting a WebSphere application with an appropriate heap size can be an important factor in optimizing performance. Running an application on WebSphere Application Server using the default heap size settings is not usually recommended. Processing time is wasted expanding the heap up to the normal operating size. Although the heap size may change greatly during an application's lifetime, it is generally a good idea to set the initial heap size close to the actual size that the application will operate at.

An optimal application would have an initial and maximum heap of the same size; in fact, for performance testing, the initial and maximum heap sizes should be the same. But most applications are dynamic in nature, so a heap that fluctuates in size is expected.

Determining the proper initial heap size for a particular application is subject to interpretation. Starting too small will result in too much time spent in heap expansion. Starting with too large a value may result in a fragmented heap because a collection may not occur until after a long period of time. Remember that a collection only occurs after an allocation failure happens.

To determine an appropriate initial heap size for an application, an administrator will need to know the approximate runtime values of the heap. A test run under normal load in a production-like environment will provide these numbers. The heap size may vary quite a bit, but a good sense of the average range will become apparent. A useful starting point is to set the initial heap size to be at the low end of the range discovered during the test run. This method balances the cost of heap expansion against the possibility of a fragmented heap due to too large a setting.

Because the heap size is so important to WebSphere Application Server, separate fields have been created for the initial and maximum heap size settings for the Process Definition in the Java Virtual Machine settings page. To set the initial heap size using the WebSphere Application Server console, enter the size (in megabytes) into the Initial Heap Size field on the Java Virtual Machine settings page.

Figure 6-3 shows the JVM settings page for the Process Definition of the server known as server1.

Figure 6-3 Java Virtual Machine settings pane for Process Definition