Measuring J2EEâ„¢ Technology-based Application Performance via EcPerf

Document Sample
Measuring J2EEâ„¢ Technology-based Application Performance via EcPerf Powered By Docstoc
					                                                 Agenda

                                                  • Measuring J2EE Platform-based
             Performance Analysis                   application performance via EcPerf
           and Tuning of the Java™ 2
           Platform, Enterprise Edition           • Performance tuning of J2EE platform
                     (J2EE™)                      • EJB performance improvement
                                                    programming tips

                           Sang Shin
                       sang.shin@sun.com
                      Sun Microsystems, Inc.

     Session 1108                                                                                                                                     2




                                                 Typical J2EE Application Structure
                                                                                     J2EE Server


                    Measuring J2EE™               HTTP
                                                  Client
                                                                             Servlet                      EJB1


                    Technology-based
                       Application                                                                        EJB2                            DB
                     Performance via
                          EcPerf               t rountrip = thttp - call ? t servlet ? t ejb1- precall ? t ejb1- call ? t ejb2- precall
                                                      ? t ejb2- call? t db- call? t db? t db- return ? tejb2 - return ? t ejb1 - return ? t http-   return



     Session 1108                                                                                                                                     4




                                                 The ECperf™ Benchmark—
Metrics for Measuring Performance
                                                 A Performance Tool
• Determine metrics for your application          • Standard workloads provide valuable
  – Number of users/connections                     advantages
  – Throughput                                          – A mechanism to compare different platforms
  – Response time                                       – A tool for J2EE platform-enabled server
  – Something else?                                       vendors to help improve performance of
                                                          their products
• Implement a benchmark to compute
ECperf Benchmark
Domain Interactions

          newCustomer                            hasSufficientCredit
          newOrder                               getPercentDiscount
          changeOrder
          getCustomerStatus
          getOrderStatus
                                   Orders                               Corp               Performance Tuning
                                                                                                   of
Driver




          findLargeOrder                createLargeOrder
          scheduleWorkOrder
          updateWorkOrder
          completeWorkOrder                       addInventory
                                                                                              J2EE Platform
          cancelWorkOrder       Manufacturing                          Supplier

                                                  add
                                                  buyComponents


                                                                               7         Session 1108




Our Tuning Results                                                                 How to Approach J2EE Tuning
                                                                                   The application is a small piece of the puzzle
         % improvement in benchmark results
         250                                                                       • Measure and tune everything
         200
                                                                                      – Disk I/O
                                                                                      – Network traffic and latency
         150
                                                                                      – CPU usage
         100                                                     Starting Score
                                                                 Ending Score
                                                                                      – VM garbage collection statistics
          50
                                                                                      – Application server behavior
           0
                 Servlet               EJB                                            – Peak usage and steady-state usage
                 Benchmark             Benchmark                                   • Compare application performance
                                                                                     against a variety of tunings
                                                                               9                                                    10




Tuning of J2EE Platform
                                                                                   Entity Bean BMP vs. CMP
Components

                                                                                   • Conventional wisdom
                          The Java Software Stack
                                                                                      – Use CMP for ease of programming
                      1        Java Application                                         and revert to BMP for performance
                      4        Application Server                                  • Good CMP engines will always win
                      3       Java Virtual Machine                                    – Slightly worse on ejbStore()
Effect of Good CMP Optimizations                                       Call by Value vs. Call by Reference

                                                                       • EJB™ components pass all objects by
   28                                                                    value
   24                                                                    Point p = new Point(1, 2);
                                                                         myEJB.foo(p);
   20                                                                                                     Inter-VM Call
   16                                                                                                      public void foo(Point p) {
   12                                                Simple BMP                                                p.x = 3;
                                                     Optimized BMP                                         }
       8                                             CMP                 System.out.println(p.x);
       4                                                                 // Prints 1
       0
           Benchmark Score     # of Database Calls
                                                                       This can have a 25% performance penalty


                                                                  13                                                                         14




Tuning the OS                                                          Network Latency Is Important

 • Network latency vs. network bandwidth
 • Java DataBase Connectivity™ (JDBC™) API                             15mb/second data transfer
                                                                        10
   Driver Issues                                                                                                          Avg. EJB
                                                                                                                          transaction
                                                                         8
 • Thread Model                                                                                                           time
                                                                         6

                 1      Java Application                                 4

                 4     Application Server                                2

                 3   Java Virtual Machine                                0
                                                                                 100BaseT           1000BaseT
                 2    Operating System
                             Hardware
                                                                  15                                                                         16




Network Latency:
                                                                        Effect of Database Drivers
The Java™ Servlet API

% Improvement in score                                                       Effect of JDBC driver vs. # CPUs
 125

 100

  75

                                                     100 Base T                                                              Type 4 Driver
  50
                                                     1000 Base T                                                             Type 2 Driver
The Solaris™ OE
                                                           Effect of Thread Model
Thread Models
                                                             % score improvements by # of CPUs
• The Solaris 8 OE has a new thread library
                                                                     Servlet Benchmark               EJB Benchmark
  – LD_LIBRARY_PATH=/usr/lib/lwp                             175                                     150
                                                                                                                        Std. Libthread
  – Becomes the default in Solaris 9                         150                                     125                Alt. Libthread
                                                             125
• Can approximate this in the Solaris 7 OE:                  100
                                                                                                     100

                                                                                                      75
  – -Xboundthreads -XX:+UseLWPSynchronization                 75
                                                                                                      50
                                                              50

                                                              25                                      25

                                                              0                                        0
                                                                     2         3      4     6               8




                                                      19                                                                           20




Tuning the VM                                              Getting the Right Compiler

• Getting the right JIT
• JDK™ 1.3.1 technology vs.                                        % improvement with different compilers
                                                                   150
  JDK™ 1.4.0 technology                                            125

• Tuning GC                                                        100
                                                                     75                                                  -client
                                                                                                                         -server
            1      Java Application                                  50
                                                                     25
            4     Application Server
                                                                     0
            3   Java Virtual Machine                                            Servlet              EJB
                                                                                Benchmark            Benchmark
            2     Operating System
                      Hardware
                                                      21                                                                           22




Getting the Right Compiler                                 Choosing the Right VM

                                                           • Java Development Kit (JDK) 1.4.0 software has
• Procedure varies by appserver:                             significant performance fixes
  – BEA Weblogic
      • Edit the startWebLogic.sh script and change                            % Score Improvement
                                                                         350
        -hotspot to -server                                                                                          JDK 1.3.1
  – Borland Application Server                                           300                                         JDK 1.4.0

      • Defaults to -server                                              250
                                                                         200
  – iPlanet™ Application Server
                                                                         150
Why the JDK 1.4 Release Is Faster                Effect of Tuning GC

• Reflection: More than 20 times faster           % score improvement           1: -Xmx1000m -Xms1000m

• Java Native Interface (JNI)                      140
                                                                                2: -Xmx3500m -Xms3500m
                                                   120
  – 78% faster to call native code
                                                   100                          3: -Xmx3500m -Xmx3500m
  – 38% for C code to call Java code
                                                   80                              -XX:NewSize=1400m
• Serialization: 30–300% faster                    60                              -XX:MaxNewsize=1400m
                                                   40
• Better GC sizing out of the box                  20                           4: -XX:AggressiveHeap
                                                                                   -Xmx3500m -Xms3500m
• JIT Improvements                                     0
                                                                                   -XX:NewSize=3072m
                                                           1   2        3   4
  – Array bounds check eliminations, more                                          -XX:MaxNewSize=3072m
    loop optimization, better inlining


                                            25                                                          26




Tuning GC                                        Where to Tune GC

                                                 • BEA Weblogic
• App servers size their heap too small
                                                    – Change JAVA_OPTIONS in
• App servers don’t size eden correctly               startWebLogic.sh
  – Particularly in 1.3.1                        • Borland Application Server
• Reasonable arguments to use:                      – Change vmoptions in ias.config
  – -XX:AgressiveHeap -Xmx3500m -Xms3500m        • iPlanet™ Application Server
    -XX:NewSize=3072m                               – Add the arguments to jvm12.conf
    -XX:MaxNewSize=3072m
                                                 • IBM Websphere
• More information:
                                                    – Use the advanced configuration panel
   – http://java.sun.com/docs/hotspot/gc
                                                      of the administration client
                                            27                                                          28




Tuning the AppServer                             Effect of Thread Pool Sizes

                                                 % of Best Score
• Thread pool sizes                              110
                                                 100
                                                  90
• How many VMs should you run                     80
                                                  70
                                                  60
                                                  50                                        Servlet
                                                                                            Benchmark
                                                  40
           1     Java Application                                                           EJB Benchmark
                                                  30
Effect of Multiple VMs

    # CPUs




                                                                         EJB Performance Tips
                                                         1 VM               (Quoted from
                                                                         www.precisejava.com)
                                                         2 VMs
                                                         Ideal


1   2   3   4   5   6   7   8   9 10 11 12 13 14 15 16




                                                            31        Session 1108




Wrap local entity beans with                                     Reduce remote method calls with
session bean                                                     coarse granularity
• Motivation
                                                                 • Motivation
    – Remote calls are expensive
                                                                   – Remote calls are expensive
• Solution
                                                                 • Solution
    – Wrap local entity beans with session bean
                                                                   – Make remote method calls with coarse
    – Session bean is called by remote client
                                                                     granularity
    – Session bean then calls locally residing entity
      beans through local interface                                – Related data gets returned on a single remote
                                                                     call
    – Some EJB 1.1 containors support local interface
      feature                                                    • Related design pattern
• Related design pattern                                           – Value object pattern
    – Facade pattern                                        33                                                  34




Control serialization in remote EJBs                             Cache EJBHome object references

• Motivation                                                     • Motivation
    – When an object get serialized, the total object              – EJBHome object needs to be created
      graph will be serialized, which is expensive                   everytime
• Solution                                                       • Solution
    – Use Transient keyword for attributes that do                 – Cache EJBHome object for repeated use
      not need to be serialized
Control Transaction For Declarative                    Control Serialization in Stateful
Transaction                                            Session Beans

• Motivation                                           • Motivation
  – Transaction context propagation                      – When an instance variable of stateful session
                                                           get serialized in passvation process, the total
• Solution                                                 object graph will be serialized, which is
  – Avoid unnecessary transaction context                  expensive
    propagation by assigning “NotSupported” or
    “Never” to non-transactional methods               • Solution
                                                         – Use Transient keyword for the variables that
• Related design pattern                                   do not need to be serialized


                                                  37                                                        38




Remove Stateful Session Beans                          Use Lazy Loading for BMP (In
Explicitly                                             CMP 2.0, Container does it)

• Motivation                                           • Motivation
  – Maintaining the unwanted stateful session            – Loading dependent objects (in a relationship)
    beans consume resources                                are expensive
• Solution                                             • Solution
  – Client invoke remove() method to explicitly          – Delay loading dependent objects until it is
    remove stateful session bean                           needed




                                                  39                                                        40




Use Dirty Flag (In CMP 2.0,                            Choose Optimal Transaction
Container does it)                                     Isolation Level

• Motivation                                           • Motivation
  – Update database for the unchanged data is            – Choosing incorrect isolation level would result
    waste of time                                          low performance
• Solution                                             • Solution
  – For BMP, update only the data that has been          – Depending on characteristics of your
    changed                                                applications, choose the right isolation level
Use ejbHome() for Global
Operations

• Motivation
  – For global operation (such as getting total
    number of accounts), there is no need to
    assign EJB object to the bean instance
                                                                            Summary &
• Solution
  – Use ejbHOME() methods
                                                                            Resources



                                                  43         Session 1108




Summary                                                Resources

                                                       • The ECperf™ benchmark can be downloaded from:
• Tuning a J2EE™ technology-based                         – java.sun.com/j2ee/ecperf
  application requires looking at the entire           • Information about the ECperf based SPEC benchmarks:
  stack                                                   – www.spec.org/osg/jAppServer
                                                       • Java™ 2 SDK ISM/Big Heap:
• Default configurations for the J2EE
                                                          – java.sun.com/docs/hotspot/ism.html
  platform will likely give inadequate                 • Java 2 SDK Performance FAQ:
  performance                                             – java.sun.com/docs/hotspot/PerformanceFAQ.html
                                                       • Java 2 SDK Description of VM Options:
• The ECperf™ benchmark can be used to
  measure and compare performance of                      – java.sun.com/docs/hotspot/VMOptions.html
                                                       • ECperf Tuning for the Solaris™ OS:
  J2EE technology-based servers
                                                          – www.borland.com/bes/papers
                                                  45                                                       46

				
DOCUMENT INFO
Shared By:
Stats:
views:19
posted:2/1/2010
language:English
pages:8