Sun Microsystems Sun GlassFish Enterprise Server 2.1 Tuning Manual
Sun Microsystems Sun GlassFish Enterprise Server 2.1 Tuning Manual

Sun Microsystems Sun GlassFish Enterprise Server 2.1 Tuning Manual

Performance tuning guide
Hide thumbs Also See for Sun GlassFish Enterprise Server 2.1:
Table of Contents

Advertisement

Sun GlassFish Enterprise Server
2.1 Performance Tuning Guide
Sun Microsystems, Inc.
4150 Network Circle
Santa Clara, CA 95054
U.S.A.
Part No: 820–4343–10
January 2009

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Sun GlassFish Enterprise Server 2.1 and is the answer not in the manual?

Questions and answers

Summary of Contents for Sun Microsystems Sun GlassFish Enterprise Server 2.1

  • Page 1 Sun GlassFish Enterprise Server 2.1 Performance Tuning Guide Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054 U.S.A. Part No: 820–4343–10 January 2009...
  • Page 2 Etats-Unis et dans d'autres pays; elle est licenciée exclusivement par X/Open Company, Ltd. Sun, Sun Microsystems, le logo Sun, le logo Solaris, le logo Java Coffee Cup, docs.sun.com, OpenSolaris, Java et Solaris sont des marques de fabrique ou des marques déposées de Sun Microsystems, Inc., ou ses filiales, aux Etats-Unis et dans d'autres pays.
  • Page 3: Table Of Contents

    Contents Preface ..............................13 Overview of Enterprise Server Performance Tuning ..............17 Process Overview ..........................17 ▼ Performance Tuning Sequence ....................18 Understanding Operational Requirements ..................19 Application Architecture ......................19 Security Requirements ........................ 21 Hardware Resources ........................22 Administration ..........................23 General Tuning Concepts ........................
  • Page 4 Contents Tuning Tips for Specific Types of EJB Components ............... 42 JDBC and Database Access ......................46 Tuning Message-Driven Beans ....................47 Tuning the Enterprise Server ......................49 Deployment Settings ........................... 49 Disable Auto-deployment ......................50 Use Pre-compiled JavaServer Pages ................... 50 Disable Dynamic Application Reloading ..................
  • Page 5 Contents Improving ORB Performance with Java Serialization ............. 75 Thread Pool Settings ........................... 76 Tuning Thread Pools (Unix /Linux only) ................. 76 Resources .............................. 77 JDBC Connection Pool Settings ....................77 Connector Connection Pool Settings ..................80 Tuning the Java Runtime System ...................... 83 Java Virtual Machine Settings ......................
  • Page 6 Contents Disk I/O Settings ........................102 TCP/IP Settings .......................... 102 Tuning UltraSPARC T1–Based Systems ..................103 Tuning Operating System and TCP Settings ................103 Disk Configuration ........................105 Network Configuration ......................105 Start Options ..........................105 Tuning for High-Availability ......................107 Tuning HADB ............................
  • Page 7 Figures Java EE Application Model ..................20 FIGURE 1–1...
  • Page 9 Tables Performance Tuning Roadmap ................17 TABLE 1–1 Factors That Affect Performance ................24 TABLE 1–2 Bean Type Pooling or Caching ................53 TABLE 3–1 EJB Cache and Pool Settings ..................56 TABLE 3–2 Tunable ORB Settings ....................71 TABLE 3–3 Connection Pool Sizing ....................
  • Page 11 Examples Heap Configuration on Solaris ................89 EXAMPLE 4–1 Heap Configuration on Windows ................90 EXAMPLE 4–2...
  • Page 13: Preface

    Preface The Performance Tuning Guide describes how to get the best performance with Enterprise Server. This preface contains information about and conventions for the entire Sun GlassFish Enterprise Server documentation set. Sun GlassFish Enterprise Server Documentation Set Books in the Enterprise Server Documentation Set TABLE P–1 Book Title Description...
  • Page 14 Preface Books in the Enterprise Server Documentation Set (Continued) TABLE P–1 Book Title Description High Availability Administration Setting up clusters, working with node agents, and using load balancers. Guide Administration Reference Editing the Enterprise Server configuration file, domain.xml. Performance Tuning Guide Tuning the Enterprise Server to improve performance.
  • Page 15: Typographic Conventions

    Preface Typographic Conventions The following table describes the typographic changes that are used in this book. Typographic Conventions TABLE P–3 Typeface Meaning Example The names of commands, files, and Edit your .login file. AaBbCc123 directories, and onscreen computer Use ls -a to list all files. output machine_name% you have mail.
  • Page 16: Sun Welcomes Your Comments

    Preface Symbol Conventions (Continued) TABLE P–4 Symbol Description Example Meaning → File → New → Templates Indicates menu item From the File menu, choose New. selection in a graphical user From the New submenu, choose interface. Templates. Documentation, Support, and Training The Sun web site provides information about the following additional resources: Documentation (http://www.sun.com/documentation/) ■...
  • Page 17: Overview Of Enterprise Server Performance Tuning

    C H A P T E R Overview of Enterprise Server Performance Tuning You can significantly improve performance of the Sun GlassFish Enterprise Server and of applications deployed to it by adjusting a few deployment and server configuration settings. However, it is important to understand the environment and performance goals. An optimal configuration for a production environment might not be optimal for a development environment.
  • Page 18: Performance Tuning Sequence

    Process Overview Performance Tuning Roadmap (Continued) TABLE 1–1 Step Description of Task Location of Instructions Installation: If you are using HADB for session Installation Guide persistence, ensure that the HADB software is installed. Deployment: Install and run your applications. Application Deployment Guide Familiarize yourself with how to configure and Administration Guide administer the Enterprise Server.
  • Page 19: Understanding Operational Requirements

    Understanding Operational Requirements Understanding Operational Requirements Before you begin to deploy and tune your application on the Application Server, it is important to clearly define the operational environment. The operational environment is determined by high-level constraints and requirements such as: “Application Architecture”...
  • Page 20 Understanding Operational Requirements Client-Side Server-Side Server-Side Enterprise Presentation Presentation Business Logic Information System Browser Server Container Pure HTML Java Applet Desktop Java Java Application Servlet Other Device J2EE J2EE J2EE Client Platform Platform Java EE Application Model FIGURE 1–1 Moderately complex enterprise applications can be developed entirely using servlets and JSP technology.
  • Page 21: Security Requirements

    Understanding Operational Requirements Security Requirements Most business applications require security. This section discusses security considerations and decisions. User Authentication and Authorization Application users must be authenticated. The Application Server provides three different choices for user authentication: file-based, LDAP, and Solaris. The default file based security realm is suitable for developer environments, where new applications are developed and tested.
  • Page 22: Hardware Resources

    Understanding Operational Requirements What is the nature of the applications with respect to security? Do they encrypt all or only a ■ part of the application inputs and output? What percentage of the information needs to be securely transmitted? Are the applications going to be deployed on an application server that is directly connected ■...
  • Page 23: Administration

    General Tuning Concepts Administration A single Application Server installation on a server can encompass multiple instances. A group of one or more instances that are administered by a single Administration Server is called a domain. Grouping server instances into domains permits different people to independently administer the groups.
  • Page 24: Capacity Planning

    General Tuning Concepts Factors That Affect Performance TABLE 1–2 Concept In practice Measurement Value sources User Load Concurrent Transactions Per Minute (TPM) (Max. number of concurrent users) * (expected response time) / sessions at (time between clicks) Web Interactions Per Second peak load (WIPS) Example:...
  • Page 25: User Expectations

    General Tuning Concepts ▼ To Determine Capacity Determine performance on a single CPU. First determine the largest load that a single processor can sustain. You can obtain this figure by measuring the performance of the application on a single-processor machine. Either leverage the performance numbers of an existing application with similar processing characteristics or, ideally, use the actual application and workload in a testing environment.
  • Page 26: Further Information

    Further Information fraction of them are logged in and performing business transactions. A common mistake during capacity planning is to use the total size of customer population as the basis and not the average and peak numbers for concurrent users. The number of concurrent users also may exhibit patterns over time.
  • Page 27: Tuning Your Application

    C H A P T E R Tuning Your Application This chapter provides information on tuning applications for maximum performance. A complete guide to writing high performance Java and Java EE applications is beyond the scope of this document. This chapter discusses the following topics: “Java Programming Guidelines”...
  • Page 28 Java Programming Guidelines String str = "testing"; str = str + "abc"; The compiler translates this code as: String str = "testing"; StringBuffer tmp = new StringBuffer(str); tmp.append("abc"); str = tmp.toString(); Therefore, copying is inherently expensive and overusing it can reduce performance significantly.
  • Page 29: Java Server Page And Servlet Tuning

    Java Server Page and Servlet Tuning Declare Method Arguments final Declare method arguments final if they are not modified in the method. In general, declare all variables final if they are not modified after being initialized or set to some value. Synchronize Only When Necessary Do not synchronize code blocks or methods unless synchronization is required.
  • Page 30: Suggested Coding Practices

    Java Server Page and Servlet Tuning Suggested Coding Practices This section provides some tips on coding practices that improve servlet and JSP application performance. General Guidelines Follow these general guidelines to increase performance of the presentation tier: Minimize Java synchronization in servlets. ■...
  • Page 31 Java Server Page and Servlet Tuning Configuration and Deployment Tips Follow these configuration tips to improve performance. These tips are intended for production environments, not development environments. To improve class loading time, avoid having excessive directories in the server CLASSPATH. ■...
  • Page 32: Ejb Performance Tuning

    EJB Performance Tuning EJB Performance Tuning The Enterprise Server’s high-performance EJB container has numerous parameters that affect performance. Individual EJB components also have parameters that affect performance. The value of individual EJB component’s parameter overrides the value of the same parameter for the EJB container.
  • Page 33 EJB Performance Tuning asadmin get --user admin --host e4800-241-a --port 4848 -m specjcmp.application.SPECjAppServer.ejb-module. supplier_jar.stateful-session-bean.BuyerSes.bean-cache.* The following is a sample of the monitoring output: resize-quantity = -1 cache-misses = 0 idle-timeout-in-seconds = 0 num-passivations = 0 cache-hits = 59 num-passivation-errors = 0 total-beans-in-cache = 59 num-expired-sessions-removed = 0 max-beans-in-cache = 4096...
  • Page 34 EJB Performance Tuning collection is happening too frequently, and the pool size is growing, but the cache hit rate is small, then the pool-idle-timeout-in-seconds can be reduced to destroy the instances. Specifying a max-pool-size of zero (0) means that the pool is unbounded. The pooled Note –...
  • Page 35: General Guidelines

    EJB Performance Tuning To find the possible objects (applications, modules, beans, and methods) and object attributes that can be monitored, use the Admin Console. For more information, see Chapter 18, “Monitoring Components and Services, ” in Sun GlassFish Enterprise Server 2.1 Administration Guide.
  • Page 36: Using Local And Remote Interfaces

    EJB Performance Tuning Cache EJB resources: Use setSessionContext() or ejbCreate() to cache bean resources. ■ This is again an example of using bean lifecycle methods to perform application actions only once where possible. Remember to release acquired resources in the ejbRemove() method. Use the Appropriate Stubs The stub classes needed by EJB applications are generated dynamically at runtime when an EJB client needs them.
  • Page 37 EJB Performance Tuning Prefer Local Interfaces An EJB component can have remote and local interfaces. Clients not located in the same application server instance as the bean (remote clients) use the remote interface to access the bean. Calls to the remote interface require marshalling arguments, transportation of the marshalled data over the network, un-marshaling the arguments, and dispatch at the receiving end.
  • Page 38: Improving Performance Of Ejb Transactions

    EJB Performance Tuning semantics. See “Value Added Features” in Sun GlassFish Enterprise Server 2.1 Developer’s Guide for more details about the pass-by-reference flag. To specify that an EJB component will use pass by reference semantics, use the following tag in the sun-ejb-jar.xml deployment descriptor: <pass-by-reference>true</pass-by-reference>.
  • Page 39: Using Special Techniques

    EJB Performance Tuning source are going to be involved in a transaction. If a database participates in some distributed transactions, but mostly in local or single database transactions, it is advisable to register two separate JDBC resources and use the appropriate resource in the application. Configure JDBC Resources as One-Phase Commit Resources To improve performance of transactions involving multiple resources, the Application Server uses last agent optimization (LAO), which allows the configuration of one of the resources in a...
  • Page 40 EJB Performance Tuning Use version consistency to improve performance while protecting the integrity of data in the database. Since the application server can use multiple copies of an EJB component simultaneously, an EJB component’s state can potentially become corrupted through simultaneous access.
  • Page 41 EJB Performance Tuning </cmp-field-mapping> <consistency> <check-version-of-accessed-instances> <column-name>OrderTable.VC_VERSION_NUMBER</column-name> </check-version-of-accessed-instances> </consistency> </entity-mapping> In addition, you must establish a trigger on the database to automatically update the version column when data in the specified table is modified. The Application Server requires such a trigger to use version consistency.
  • Page 42: Tuning Tips For Specific Types Of Ejb Components

    EJB Performance Tuning For example, enable threadpools named priority-1 and priority-2 to the <orb> element as follows: <orb max-connections="1024" message-fragment-size="1024" use-thread-pool-ids="thread-pool-1,priority-1,priority-2"> Include the threadpool ID in the use-thread-pool-id element of the EJB component’s sun-ejb-jar.xml deployment descriptor. For example, the following sun-ejb-jar.xml deployment descriptor for an EJB component named “TheGreeter”...
  • Page 43 EJB Performance Tuning to the steady load of users), beans would be frequently passivated and activated, causing a negative impact on the response times, due to CPU intensive serialization and deserialization as well as disk I/O. Another important variable for tuning is cache-idle-timeout-in-seconds where at periodic intervals of cache-idle-timeout-in-seconds, all the beans in the cache that have not been accessed for more than cache-idle-timeout-in-seconds time, are passivated.
  • Page 44 EJB Performance Tuning Database rows represented by the bean do not change. ■ The application can tolerate using out-of-date values for the bean. ■ For example, an application might use a read-only bean to represent a list of best-seller books. Although the list might change occasionally in the database (say, from another bean entirely), the change need not be reflected immediately in an application.
  • Page 45 EJB Performance Tuning For example, you have this relationship defined in the ejb-jar.xml file: <relationships> <ejb-relation> <description>Order-OrderLine</description> <ejb-relation-name>Order-OrderLine</ejb-relation-name> <ejb-relationship-role> <ejb-relationship-role-name> Order-has-N-OrderLines </ejb-relationship-role-name> <multiplicity>One</multiplicity> <relationship-role-source> <ejb-name>OrderEJB</ejb-name> </relationship-role-source> <cmr-field> <cmr-field-name>orderLines</cmr-field-name> <cmr-field-type>java.util.Collection</cmr-field-type> </cmr-field> </ejb-relationship-role> </ejb-relation> </relationships> When a particular Order is loaded, you can load its related OrderLines by adding this to the sun-cmp-mapping.xml file for the application: <entity-mapping>...
  • Page 46: Jdbc And Database Access

    EJB Performance Tuning Pre-fetching generally improves performance because it reduces the number of database accesses. However, if the business logic often uses Orders without referencing their OrderLines, then this can have a performance penalty, that is, the system has spent the effort to pre-fetch the OrderLines that are not actually needed.
  • Page 47: Tuning Message-Driven Beans

    EJB Performance Tuning Reduce the database transaction isolation level when appropriate. Reduced isolation levels reduce work in the database tier, and could lead to better application performance. However, this must be done after carefully analyzing the database table usage patterns. Set the database transaction isolation level with the Admin Console on the Resources >...
  • Page 48 EJB Performance Tuning Cache Bean-Specific Resources Use the setMessageDrivenContext() or ejbCreate() method to cache bean specific resources, and release those resources from the ejbRemove() method. Limit Use of JMS Connections When designing an application that uses JMS connections make sure you use a methodology that sparingly uses connections, by either pooling them or using the same connection for multiple sessions.
  • Page 49: Tuning The Enterprise Server

    C H A P T E R Tuning the Enterprise Server This chapter describes some ways to tune the Enterprise Server for optimum performance, including the following topics: “Deployment Settings” on page 49 ■ “Logger Settings” on page 50 ■ “Web Container Settings”...
  • Page 50: Disable Auto-Deployment

    Logger Settings Disable Auto-deployment Enabling auto-deployment will adversely affect deployment, though it is a convenience in a development environment. For a production system, disable auto-deploy to optimize performance. If auto-deployment is enabled, then the Reload Poll Interval setting can have a significant performance impact.
  • Page 51: General Settings

    Web Container Settings General Settings In general, writing to the system log slows down performance slightly; and increased disk access (increasing the log level, decreasing the file rotation limit or time limit) also slows down the application. Also, make sure that any custom log handler doesn’t log to a slow device like a network file system since this can adversely affect performance.
  • Page 52: Manager Properties: Reap Interval

    Web Container Settings Manager Properties: Reap Interval Modifying the reap interval can improve performance, but setting it without considering the nature of your sessions and business logic can cause data inconsistency, especially for time-based persistence-frequency. For example, if you set the reap interval to 60 seconds, the value of session data will be recorded every 60 seconds.
  • Page 53: Ejb Container Settings

    EJB Container Settings EJB Container Settings The EJB Container has many settings that affect performance. As with other areas, use monitor the EJB Container to track its execution and performance. Monitoring the EJB Container Monitoring the EJB container is disabled by default. Enable monitoring with the Admin Console under Configurations >...
  • Page 54 EJB Container Settings If you develop and deploy your EJB components using Sun Java Studio, then you need to Note – edit the individual bean descriptor settings for bean pool and bean cache. These settings might not be suitable for production-level deployment. Tuning the EJB Pool A bean in the pool represents the pooled state in the EJB lifecycle.
  • Page 55 EJB Container Settings Pool Idle Timeout: the maximum time that a stateless session bean, entity bean, or ■ message-driven bean is allowed to be idle in the pool. After this time, the bean is destroyed if the bean in case is a stateless session bean or a message driver bean. This is a hint to server. The default value is 600 seconds.
  • Page 56: Ejb Cache And Pool Settings

    Max Cache Size Max Cache Size Maximum number of beans in the cache. Make this setting greater than one. The default value is 512. A value of zero indicates the cache is unbounded, which means the size of the cache is governed by Cache Idle Timeout and Cache Resize Quantity.
  • Page 57 Refresh period EJB Cache and Pool Settings (Continued) TABLE 3–2 Cache Settings Pool Settings cache- idle- refresh- cache- timeout- removal- victim- period- pool- max- pool-idle- Type of resize- max- cache- timeout- in- selection- steady- resize- pool- timeout-in- Bean quantity size seconds seconds policy...
  • Page 58: Java Message Service Settings

    Java Message Service Settings than cache misses, then option B is an appropriate choice. You might still have to change the max-cache-size and cache-resize-quantity to get the best result. If the cache hits are too low and cache misses are very high, then the application is not reusing the bean instances and hence increasing the cache size (using max-cache-size) will not help (assuming that the access pattern remains the same).
  • Page 59: Tuning The Transaction Service

    Transaction Service Settings asadmin get -m serverInstance.transaction-service.* The following statistics are gathered on the transaction service: total-tx-completed Completed transactions. ■ total-tx-rolled-back Total rolled back transactions. ■ total-tx-inflight Total inflight (active) transactions. ■ isFrozen Whether transaction system is frozen (true or false) ■...
  • Page 60: Http Service Settings

    HTTP Service Settings Recover On Restart (Automatic Recovery) To set the Recover on Restart attribute with the Admin Console, go to Configurations > config-name > Transaction Service. Click the Recover check box to set it to true (checked, the default) or false (un-checked). You can also set automatic recovery with asadmin, for example: asadmin set server1.transaction-service.automatic-recovery=false When Recover on Restart is true, the server will always perform transaction logging, regardless...
  • Page 61 HTTP Service Settings With asadmin, use the following command to list the monitoring parameters available: list --user admin --port 4848 -m server-instance-name.http-service.* where server-instance-name is the name of the server instance. Use the following command to get the values: get --user admin --port 4848 -m server.http-service.parameter-name.* where parameter-name is the name of the parameter to monitor.
  • Page 62 HTTP Service Settings HitRatio The hit ratio is the number of cache hits divided by the number of cache lookups. This setting is not tunable. If you turn off DNS lookups on your server, host name restrictions will not work and IP Note –...
  • Page 63 HTTP Service Settings File Cache Information (file-cache) The file cache caches static content so that the server handles requests for static content quickly. The file-cache section provides statistics on how your file cache is being used. For information on tuning the file cache, see “HTTP File Cache”...
  • Page 64: Connection Queue

    HTTP Service Settings Connection Queue Total Connections Queued: Total connections queued is the total number of times a ■ connection has been queued. This includes newly accepted connections and connections from the keep-alive system. Average Queuing Delay: Average queueing delay is the average amount of time a connection ■...
  • Page 65 HTTP Service Settings Request Timeout ■ Buffer Length ■ Thread Count The Thread Count parameter specifies the maximum number of simultaneous requests the server can handle. The default value is 5. When the server has reached the limit or request threads, it defers processing new requests until the number of active requests drops below the maximum amount.
  • Page 66: Keep Alive

    HTTP Service Settings Buffer Length The size (in bytes) of the buffer used by each of the request processing threads for reading the request data from the client. Adjust the value based on the actual request size and observe the impact on performance. In most cases the default should suffice.
  • Page 67 HTTP Service Settings Time Out Time Out determines the maximum time (in seconds) that the server holds open an HTTP keep alive connection. A client can keep a connection to the server open so that multiple requests to one server can be serviced by a single network connection. Since the number of open connections that the server can handle is limited, a high number of open connections will prevent new clients from connecting.
  • Page 68 HTTP Service Settings Max Files Count Max Files Count determines how many files are in the cache. If the value is too big, the server caches little-needed files, which wastes memory. If the value is too small, the benefit of caching is lost.
  • Page 69: Tuning Http Listener Settings

    HTTP Service Settings Tuning HTTP Listener Settings Change HTTP listener settings in the Admin Console under Configurations > config-name > HTTP Service > HTTP Listeners > listener-name. Network Address For machines with only one network interface card (NIC), set the network address to the IP address of the machine (for example, 192.18.80.23 instead of default 0.0.0.0).
  • Page 70: Orb Settings

    ORB Settings ORB Settings The Enterprise Server includes a high performance and scalable CORBA Object Request Broker (ORB). The ORB is the foundation of the EJB Container on the server. Overview The ORB is primarily used by EJB components via: RMI/IIOP path from an application client (or rich client) using the application client ■...
  • Page 71: Tuning The Orb

    ORB Settings set serverInstance.iiop-service.orb.system.monitoringEnabled=true reconfig serverInstance Connection Statistics The following statistics are gathered on ORB connections: total-inbound-connections Total inbound connections to ORB. ■ total-outbound-connections Total outbound connections from ORB. ■ Use this command to get ORB connection statistics: asadmin get --monitor serverInstance.iiop-service.orb.system.orb-connection.* Thread Pools The following statistics are gathered on ORB thread pools:...
  • Page 72 ORB Settings Tunable ORB Settings (Continued) TABLE 3–3 RMI/ IIOP from ORB to Enterprise Server communication steady-thread-pool-size, max-thread-pool-size, infrastructure, thread idle-thread-timeout-in-seconds pool RMI/ IIOP from a vendor ORB parts of communication steady-thread-pool-size, max-thread-pool-size, infrastructure, thread idle-thread-timeout-in-seconds pool In-process thread pool steady-thread-pool-size, max-thread-pool-size, idle-thread-timeout-in-seconds Tunable ORB Parameters...
  • Page 73 ORB Settings Minimum Pool Size: The minimum number of threads in the ORB thread pool. Set to the ■ average number of threads needed at a steady (RMI/ IIOP) load. Maximum Pool Size: The maximum number of threads in the ORB thread pool. ■...
  • Page 74: Thread Pool Sizing

    ORB Settings Load Balancing For information on how to configure RMI/IIOP for multiple application server instances in a cluster, Chapter 9, “RMI-IIOP Load Balancing and Failover, ” in Sun GlassFish Enterprise Server 2.1 High Availability Administration Guide. When tuning the client ORB for load-balancing and connections, consider the number of connections opened on the server ORB.
  • Page 75: Improving Orb Performance With Java Serialization

    ORB Settings ++++++++++++++++++++++++++++++ Message(Thread[ORB Client-side Reader, conn to 192.18.80.118:1050,5,main]): createFromStream: type is 4 < MessageBase(Thread[ORB Client-side Reader, conn to 192.18.80.118:1050,5,main]): Message GIOP version: 1.2 MessageBase(Thread[ORB Client-side Reader, conn to 192.18.80.118:1050,5,main]): ORB Max GIOP Version: 1.2 Message(Thread[ORB Client-side Reader, conn to 192.18.80.118:1050,5,main]): createFromStream: message construction complete.
  • Page 76: Thread Pool Settings

    Thread Pool Settings ▼ To Enable Java Serialization You must set this property on all servers that you want to use JSG. In the tree component, expand the Configurations node. Expand the desired node. Select the JVM Settings node In the JVM Settings page, choose the JVM Options tab. Click Add JVM Option, and enter the following value: -Dcom.sun.CORBA.encoding.ORBEnableJavaSerialization=true Click Save...
  • Page 77: Resources

    Resources is not offered in a Unix/Linux user interface. However, it is possible to edit the OS-scheduled thread pools and add new thread pools, if needed, using the Admin Console. Resources “JDBC Connection Pool Settings” on page 77 ■ “Connector Connection Pool Settings” on page 80 ■...
  • Page 78: Connection Pool Sizing

    Initial and Mimimum Pool Size “Timeout Settings” on page 78 ■ “Isolation Level Settings” on page 79 ■ “Connection Validation Settings” on page 79 ■ Pool Size Settings The following settings control the size of the connection pool: Initial and Size of the pool when created, and its minimum allowable size.
  • Page 79 Pool Resize Quantity Idle Timeout: Maximum time in seconds that a connection can remain idle in the pool. ■ After this time, the pool can close this connection. This property does not control connection timeouts on the database server. Keep this timeout shorter than the database server timeout (if such timeouts are configured on the database), to prevent accumulation of unusable connection in Enterprise Server.
  • Page 80: Connector Connection Pool Settings

    Connection Validation Required Connection If true, the pool validates connections (checks to find out if they are usable) before providing them to an Validation application. Required If possible, keep the default value, false. Requiring connection validation forces the server to apply the validation algorithm every time the pool returns a connection, which adds overhead to the latency of getConnection().
  • Page 81 Close All Connections On Any Failure asadmin> create-connector-connection-pool --raname jdbcra --connectiondefinition javax.sql.DataSource -transactionsupport LocalTransaction TESTPOOL Chapter 3 • Tuning the Enterprise Server...
  • Page 83: Tuning The Java Runtime System

    C H A P T E R Tuning the Java Runtime System This chapter discusses the following topics: “Java Virtual Machine Settings” on page 83 ■ “Managing Memory and Garbage Collection” on page 84 ■ “Further Information” on page 91 ■...
  • Page 84: Managing Memory And Garbage Collection

    Managing Memory and Garbage Collection Managing Memory and Garbage Collection The efficiency of any application depends on how well memory and garbage collection are managed. The following sections provide information on optimizing memory and allocation functions: “Goals” on page 32 ■...
  • Page 85: Additional Information

    Managing Memory and Garbage Collection When the new generation fills up, it triggers a minor collection in which the surviving objects are moved to the old generation. When the old generation fills up, it triggers a major collection which involves the entire object heap. Both HotSpot and Solaris JDK use thread local object allocation pools for lock-free, fast, and scalable object allocation.
  • Page 86: Tracing Garbage Collection

    Managing Memory and Garbage Collection Tracing Garbage Collection The two primary measures of garbage collection performance are throughput and pauses. Throughput is the percentage of the total time spent on other activities apart from GC. Pauses are times when an application appears unresponsive due to GC. Two other considerations are footprint and promptness.
  • Page 87: Tuning The Java Heap

    Managing Memory and Garbage Collection Although applications can explicitly invoke GC with the System.gc() method, doing so is a bad idea since this forces major collections, and inhibits scalability on large systems. It is best to disable explicit GC by using the flag -XX:+DisableExplicitGC. The Enterprise Server uses RMI in the Administration module for monitoring.
  • Page 88 Managing Memory and Garbage Collection memory structures. The difference between the maximum address space and the total of those values is the amount of memory that can be allocated to the heap. You can improve performance by increasing your heap size or using a different garbage collector.
  • Page 89: Rebasing Dlls On Windows

    Managing Memory and Garbage Collection Decide the total amount of memory you can afford for the JVM. Accordingly, graph your ■ own performance metric against young generation sizes to find the best setting. Make plenty of memory available to the young generation. The default is calculated from ■...
  • Page 90 Managing Memory and Garbage Collection To prevent load address collisions, set preferred base addresses with the rebase utilty that comes with Visual Studio and the Platform SDK. Use the rebase utility to reassign the base addresses of the Application Server DLLs to prevent relocations at load time and increase the available process memory for the Java heap.
  • Page 91: Further Information

    Further Information Further Information For more information on tuning the JVM, see: Java HotSpot VM Options ■ Frequently Asked Questions About the Java HotSpot Virtual Machine ■ Performance Documentation for the Java HotSpot VM ■ Java performance web page ■ Monitoring and Management for the Java Platform (J2SE 5.0) ■...
  • Page 93: Tuning The Operating System And Platform

    C H A P T E R Tuning the Operating System and Platform This chapter discusses tuning the operating system (OS) for optimum performance. It discusses the following topics: “Server Scaling” on page 93 ■ “Solaris 10 Platform-Specific Tuning Information” on page 95 ■...
  • Page 94: Memory

    Server Scaling the relative amount of time it spends in I/O versus CPU activity. Studies have shown that doubling the number of CPUs increases servlet performance by 50 to 80 percent. Memory See the section Hardware and Software Requirements in the Sun Java System Application Server Release Notes for specific memory recommendations for each supported operating system.
  • Page 95: Solaris 10 Platform-Specific Tuning Information

    Tuning for the Solaris OS Solaris 10 Platform-Specific Tuning Information Solaris Dynamic Tracing (DTrace) is a comprehensive dynamic tracing framework for the Solaris Operating System (OS). You can use the DTrace Toolkit to monitor the system. The DTrace Toolkit is available through the OpenSolaris project from the DTraceToolkit page (http://www.opensolaris.org/os/community/dtrace/dtracetoolkit/).
  • Page 96 Tuning for the Solaris OS Tuning Parameters for Solaris (Continued) TABLE 5–1 Parameter Scope Default Tuned Value Comments 1024 tcp_conn_req_max_q ndd /dev/tcp 1024 4096 tcp_conn_req_max_q0 ndd /dev/tcp 480000 60000 tcp_ip_abort_interval ndd /dev/tcp 7200000 900000 For high traffic web sites, lower this tcp_keepalive_interval ndd /dev/tcp value.
  • Page 97: File Descriptor Setting

    Linux Configuration File Descriptor Setting On the Solaris OS, setting the maximum number of open files property using ulimit has the biggest impact on efforts to support the maximum number of RMI/IIOP clients. To increase the hard limit, add the following command to /etc/system and reboot it once: set rlim_fd_max = 8192 Verify this hard limit by using the following command: ulimit -a -H...
  • Page 98: Tuning For Solaris On X86

    Tuning for Solaris on x86 echo 262143 > /proc/sys/net/core/rmem_default #above configuration for 2.4.X kernels echo 4096 131072 262143 > /proc/sys/net/ipv4/tcp_rmem echo 4096 13107262143 > /proc/sys/net/ipv4/tcp_wmem #disable "RFC2018 TCP Selective Acknowledgements," and "RFC1323 TCP timestamps" echo 0 > /proc/sys/net/ipv4/tcp_sack echo 0 > /proc/sys/net/ipv4/tcp_timestamps #double maximum amount of memory allocated to shm at runtime echo "67108864"...
  • Page 99: File Descriptors

    Tuning for Solaris on x86 Some of the values depend on the system resources available. After making any changes to /etc/system, reboot the machines. File Descriptors Add (or edit) the following lines in the /etc/system file: set rlim_fd_max=65536 set rlim_fd_cur=65536 set sq_max_size=0 set tcp:tcp_conn_hash_size=8192 set autoup=60...
  • Page 100: Tuning For Linux Platforms

    Tuning for Linux platforms Tuning for Linux platforms To tune for maximum performance on Linux, you need to make adjustments to the following: “File Descriptors” on page 100 ■ “Virtual Memory” on page 101 ■ “Network Interface” on page 102 ■...
  • Page 101: Virtual Memory

    Tuning for Linux platforms cputime unlimited filesize unlimited datasize unlimited stacksize 8192 kbytes coredumpsize 0 kbytes memoryuse unlimited descriptors 1024 memorylocked unlimited maxproc 8146 openfiles 1024 The openfiles and descriptors show a limit of 1024. To increase the limit to 65535 for all users, edit /etc/security/limits.conf as root, and modify or add the nofile setting (number of file) entries: soft...
  • Page 102: Network Interface

    Tuning for Linux platforms Network Interface To ensure that the network interface is operating in full duplex mode, add the following entry into /etc/rc.local: mii-tool -F 100baseTx-FD eth0 where eth0 is the name of the network interface card (NIC). Disk I/O Settings ▼...
  • Page 103: Tuning Ultrasparc T1-Based Systems

    Tuning UltraSPARC® T1–Based Systems Add the following to /etc/sysctl.conf # Disables packet forwarding net.ipv4.ip_forward = 0 # Enables source route verification net.ipv4.conf.default.rp_filter = 1 # Disables the magic-sysrq key kernel.sysrq = 0 net.ipv4.ip_local_port_range = 1204 65000 net.core.rmem_max = 262140 net.core.rmem_default = 262140 net.ipv4.tcp_rmem = 4096 131072 262140 net.ipv4.tcp_wmem = 4096 131072 262140 net.ipv4.tcp_sack = 0...
  • Page 104: Tuning 64-Bit Systems For Performance Benchmarking

    Tuning UltraSPARC® T1–Based Systems Tuning 64–bit Systems for Performance Benchmarking TABLE 5–2 Parameter Scope Default Value Tuned Value Comments 65536 260000 Process open file descriptors limit; rlim_fd_max /etc/system should account for the expected load (for the associated sockets, files, pipes if any).
  • Page 105: Disk Configuration

    Tuning UltraSPARC® T1–Based Systems Disk Configuration If HTTP access is logged, follow these guidelines for the disk: Write access logs on faster disks or attached storage. ■ If running multiple instances, move the logs for each instance onto separate disks as much ■...
  • Page 106 Tuning UltraSPARC® T1–Based Systems To start the 32–bit Enterprise Server with 4–Mbyte pages, use the following options: ■ LD_PRELOAD_32=/usr/lib/mpss.so.1 ; export LD_PRELOAD_32; export MPSSHEAP=4M; ./bin/startserv; unset LD_PRELOAD_32; unset MPSSHEAP To start the 64–bit Enterprise Server with 4–Mbyte pages, use the following options: ■...
  • Page 107: Tuning For High-Availability

    C H A P T E R Tuning for High-Availability This chapter discusses the following topics: “Tuning HADB” on page 107 ■ “Tuning the Enterprise Server for High-Availability” on page 116 ■ “Configuring the Load Balancer” on page 120 ■ Tuning HADB The Application Server uses the high-availability database (HADB) to store persistent session state data.
  • Page 108 Tuning HADB If the database runs out of device space, the HADB returns error codes 4593 or 4592 to the Enterprise Server. See Sun Java System Application Server Error Message Reference for more information Note – on these error messages. HADB also writes these error messages to history files.
  • Page 109: Memory Allocation

    Tuning HADB hadbm does not add data devices to a running database instance. Note – Placing HADB files on Physical Disks For best performance, data devices should be allocated on separate physical disks. This applies if there are nodes with more than one data device, or if there are multiple nodes on the same host. Place devices belonging to different nodes on different devices.
  • Page 110: Performance

    Tuning HADB Performance For best performance, all HADB processes (clu_xxx_srv) must fit in physical memory. They should not be paged or swapped. The same applies for shared memory segments in use. You can configure the size of some of the shared memory segments. If these segments are too small, performance suffers, and user transactions are delayed or even aborted.
  • Page 111 Tuning HADB FreeSize: free size in MB. ■ Usage: percent used. ■ Use the hadbm resourceinfo command to monitor resource usage, for example the following command displays data buffer pool information: %hadbm resourceinfo --databuf NodeNo Avail Free Access Misses Copy-on-write 205910260 8342738 400330...
  • Page 112 Tuning HADB The log records remain in the buffer until they are processed locally and shipped to the mirror node. The log records are kept until the outcome (commit or abort) of the transaction is certain. If the HADB node runs low on tuple log, the user transactions are delayed, and possibly timed out.
  • Page 113 Tuning HADB Large BLOBs necessarily allocate many disk blocks, and thus create a high load on the node internal log. This is normally not a problem, since each entry in the nilog is small. Tuning InternalLogbufferSize Begin with the default value. Look out for HIGH LOAD informational messages in the history files. The relevant messages contain nilog, and a description of the internal resource contention that occurred.
  • Page 114 Tuning HADB Calculating the number of locks To calculate the number of locks needed, estimate the following parameters: Number of concurrent users that request session data to be stored in HADB (one session ■ record per user) Maximum size of the BLOB session ■...
  • Page 115 Tuning HADB For example, the output displayed by this command might look something like this: Node No. Avail Free Waits 50000 50000 50000 50000 Avail: Number of locks available. ■ Free: Number of locks in use. ■ Waits: Number of transactions that have waited for a lock.“na” (not applicable) if all locks ■...
  • Page 116: Operating System Configuration

    Tuning the Enterprise Server for High-Availability For more information on configuring the load balancer plug-in, see “Configuring the HTTP Load Balancer” in Sun GlassFish Enterprise Server 2.1 High Availability Administration Guide. HADB timeouts The sql_client time out value may affect performance. Operating System Configuration If the number of semaphores is too low, HADB can fail and display this error message: No space left on device...
  • Page 117: Tuning Session Persistence Frequency

    Tuning the Enterprise Server for High-Availability Tuning Session Persistence Frequency The Enterprise Server provides HTTP session persistence and failover by writing session data to HADB. You can control the frequency at which the server writes to HADB by specifying the persistence frequency.
  • Page 118: Session Persistence Scope

    Tuning the Enterprise Server for High-Availability Session Persistence Scope You can specify the scope of the persistence in addition to persistence frequency on the same page in the Admin Console where you specify persistence frequency, Configurations > config-name > Availability Service (Web Container Availability). For detailed description of different persistence scopes, see Chapter 7, “Configuring High Availability Session Persistence and Failover, ”...
  • Page 119: Checkpointing Stateful Session Beans

    Tuning the Enterprise Server for High-Availability It is important to pay attention while determining the HTTP session size. If you are creating large HTTP session objects, calculate the HADB nodes as discussed in “Tuning HADB” on page 107. Checkpointing Stateful Session Beans Checkpointing saves a stateful session bean (SFSB) state to the HADB so that if the server instance fails, the SFSB is failed over to another instance in the cluster and the bean state recovered.
  • Page 120: Configuring The Load Balancer

    Configuring the Load Balancer For optimal performance, use a pool with eight to 16 connections per node. For example, if you have four nodes configured, then the steady-pool size must be set to 32 and the maximum pool size must be 64. Adjust the Idle Timeout and Pool Resize Quantity values based on monitoring statistics.
  • Page 121 Configuring the Load Balancer interval-in-seconds: Specifies the interval at which health checks of instances occur. The ■ default is 30 seconds. timeout-in-seconds: Specifies the timeout interval within which a response must be ■ obtained for a listener to be considered healthy. The default is 10 seconds. If the typical response from the server takes n seconds and under peak load takes m seconds, then set the timeout-in-seconds property to m + n, as follows: <health-checker...
  • Page 123: Index

    Index caching (Continued) servlet results, 31 Acceptor Threads, 69 capacity planning, 24 access log, 64 AddrLookups, 62 checkpointing, 43, 119 application class variables, shared, 30 architecture, 19 Client ORB Properties, 73-74 scalability, 24 Close All Connections On Any Failure, JDBC tuning, 27 Connection Pool, 80 arrays, 27...
  • Page 124: Sun Glassfish Enterprise Server 2.1 Performance Tuning Guide • January

    Index deployment finalizers, avoiding, 28 settings, 49 footprint, 86 tips, 31 fragmented messages, 75 deserialization, 27-29 disabling network interrupts, 105 disk configuration, 105 disk I/O performance, 102 Garbage Collector, 84-85 disk space, 94 generational object memory, 84 distributed transaction logging, disabling, 59 DNS cache, 61-62 DNS lookups, 62, 67 dynamic reloading, disabling, 50...
  • Page 125 Index JSP files, 29 HTTP Service (Continued) tuning, 64 pre-compiling, 50 HTTP sessions, 30 reloading, 52 tuning, 29-31 jvmstat utility, 85 idle timeout EJB cache, 56 EJB pool, 55 keep-alive IIOP Client Authentication Required, 72 max connections, 66 IIOP messages, 74-75 settings, 66 Initial Thread Count, HTTP Service, 65 statistics, 63...
  • Page 126 Index monitoring (Continued) processors, 93 programming guidelines, 27-29 transaction service, 58 promptness, 86 NameLookups, 62 Network Address, 69 read-only beans, 43-44 network configuration, 105 refresh period, 44, 56 network interface, 102 reap interval, 52 network interrupts, disabling, 105 recover on restart, 60 NewRatio, 88 refresh period NewSize, 88...
  • Page 127 Index session (Continued) thread pool timeout, 51 sizing, 74 Small/Medium File Size, HTTP file cache, 68 statistics, 71 SOAP attachments, 29 tuning, 76 Solaris throughput, 86 JDK, 85 timeouts, HADB, 115 TCP/IP settings, 95 Total Connections, ORB, 72 tuning for performance benchmarking, 104 Total Connections Queued, 64 version 9, 31 transactions...
  • Page 128 Index x86, 98 XA-capable data sources, 38-39 -Xms, 88 -Xmx, 88 +DisableExplicitGC, 87 MaxHeapFreeRatio, 88 MaxPermSize, 86 MinHeapFreeRatio, 88 Sun GlassFish Enterprise Server 2.1 Performance Tuning Guide • January 2009...

Table of Contents