JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle GlassFish Server 3.1 Performance Tuning Guide
search filter icon
search icon

Document Information


1.  Overview of GlassFish Server Performance Tuning

2.  Tuning Your Application

Java Programming Guidelines

Avoid Serialization and Deserialization

Use StringBuilder to Concatenate Strings

Assign null to Variables That Are No Longer Needed

Declare Methods as final Only If Necessary

Declare Constants as static final

Avoid Finalizers

Declare Method Arguments final

Synchronize Only When Necessary

Use DataHandlers for SOAP Attachments

Java Server Page and Servlet Tuning

Suggested Coding Practices

General Guidelines

Avoid Shared Modified Class Variables

HTTP Session Handling

Configuration and Deployment Tips

Optimize SSL

Disable Security Manager

EJB Performance Tuning


Monitoring EJB Components

Monitoring Individual EJB Components

General Guidelines

Use High Performance Beans

Use Caching

Use the Appropriate Stubs

Remove Unneeded Stateful Session Beans

Cache and Pool Tuning Tips

Using Local and Remote Interfaces

Prefer Local Interfaces

Using Pass-By-Reference Semantics

Improving Performance of EJB Transactions

Use Container-Managed Transactions

Do Not Encompass User Input Time

Identify Non-Transactional Methods

Use TX_REQUIRED for Long Transaction Chains

Use Lowest Cost Database Locking

Use XA-Capable Data Sources Only When Needed

Configure JDBC Resources as One-Phase Commit Resources

Use the Least Expensive Transaction Attribute

Using Special Techniques

Version Consistency

Request Partitioning

Tuning Tips for Specific Types of EJB Components

Entity Beans

Stateful Session Beans

Checkpoint only when needed

Stateless Session Beans

Read-Only Entity Beans

Refresh Period

Pre-Fetching Container Managed Relationship (CMR) Beans

JDBC and Database Access

Use JDBC Directly

Encapsulate Business Logic in Entity EJB Components

Close Connections

Minimize the Database Transaction Isolation Level

Tuning Message-Driven Beans

Use getConnection()

Tune the Message-Driven Bean's Pool Size

Cache Bean-Specific Resources

Limit Use of JMS Connections

3.  Tuning the GlassFish Server

4.  Tuning the Java Runtime System

5.  Tuning the Operating System and Platform


Java Server Page and Servlet Tuning

Many applications running on the GlassFish Server use servlets or JavaServer Pages (JSP) technology in the presentation tier. This section describes how to improve performance of such applications, both through coding practices and through deployment and configuration settings.

Suggested Coding Practices

This section provides some tips on coding practices that improve servlet and JSP application performance.

The following topics are addressed here:

General Guidelines

Follow these general guidelines to increase performance of the presentation tier:

Avoid Shared Modified Class Variables

In the servlet multithread model (the default), a single instance of a servlet is created for each application server instance. All requests for a servlet on that application instance share the same servlet instance. This can lead to thread contention if there are synchronization blocks in the servlet code. Therefore, avoid using shared modified class variables because they create the need for synchronization.

HTTP Session Handling

Follow these guidelines when using HTTP sessions:

Configuration and Deployment Tips

Follow these configuration tips to improve performance. These tips are intended for production environments, not development environments.

Optimize SSL

Optimize SSL by using routines in the appropriate operating system library for concurrent access to heap space. The library to use depends on the version of the Solaris Operating System (SolarisOS) that you are using. To ensure that you use the correct library, set the LD_PRELOAD environment variable to specify the correct library file. For more information, refer to the following table.

Solaris OS Version
Setting of LD_PRELOAD Environment Variable

To set the LD_PRELOAD environment variable, edit the entry for this environment variable in the startserv script. The startserv script is located is located in the bin/startserv directory of your domain.

The exact syntax to define an environment variable depends on the shell that you are using.

Disable Security Manager

The security manager is expensive because calls to required resources must call the doPrivileged() method and must also check the resource with the server.policy file. If you are sure that no malicious code will be run on the server and you do not use authentication within your application, then you can disable the security manager.

See Enabling and Disabling the Security Manager in Oracle GlassFish Server 3.1 Application Development Guide for instructions on enabling or disabling the security manager. If using the GlassFish Server Administration Console, navigate to the Configurations->configuration-name->Security node and check or uncheck the Security Manager option as desired. Refer to the Administration Console online help for more information.