slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Jonathan Maron Principal Product Manager Oracle Corporation PowerPoint Presentation
Download Presentation
Jonathan Maron Principal Product Manager Oracle Corporation

Loading in 2 Seconds...

play fullscreen
1 / 42

Jonathan Maron Principal Product Manager Oracle Corporation - PowerPoint PPT Presentation


  • 162 Views
  • Uploaded on

Jonathan Maron Principal Product Manager Oracle Corporation. Tuning J2EE Applications Tier by Tier. Agenda. Background Methodology J2EE Optimizations Performance Monitoring. Agenda. Background Methodology J2EE Optimizations Performance Monitoring. Performance Issues Abound!.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Jonathan Maron Principal Product Manager Oracle Corporation' - bonita


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
agenda
Agenda
  • Background
  • Methodology
  • J2EE Optimizations
  • Performance Monitoring
agenda1
Agenda
  • Background
  • Methodology
  • J2EE Optimizations
  • Performance Monitoring
performance issues abound
Performance Issues Abound!

2003 Wily Benchmark Survey shows

  • 60% of time Java applications fail to meet user expectations
  • Only 42% of applications perform as planned during deployment
  • 57% of application performance spent in data access

2004 Forrester

  • 66% of time developers find out about performance problems from user calls!
j2ee application complexity

Client SidePresentation

Server-SideBusiness Logic

Server-SidePresentation

EJB

Container

Web

Server

Browser

PureHTML

EJB

JSP

JavaApplet

Servlet

EJB

Desktop

JavaApplication

JSP

EJB

Device

J2EEPlatform

J2EEPlatform

J2EEClient

J2EE Application Complexity

EnterpriseInformation Systems

slide7

“Premature optimization is the root of all evil”

- Professor Sir Charles Anthony Richard Hoare

  • “There are two rules for when to optimize:
  • Don't do it.
  • (For experts only) Don't do it yet.”

- Michael Jackson, Principles of Program Design

slide8

“Test driven design can lead to emergent optimization and code that is readily optimizable. If programmers develop test first, many of their upfront concerns about performance can be deferred.”

- Michael Feathers, Emergent Optimization in Test Driven Design

agenda2
Agenda
  • Background
  • Methodology
  • J2EE Optimizations
  • Performance Monitoring
methodical approach to performance evaluation
Methodical approach to performance evaluation

Develop

Identify

Evaluate

Design

Test

approach tuning issues logically and iteratively
Approach Tuning Issues Logically and Iteratively

Component

Applications

Application Server

Java Virtual Machine

Database

Hardware and Operating System

Tuning and debugging are ongoing iterative

processes. There are no magic bullets.

don t forget that there are tools to help
Don’t Forget That There are Tools to Help
  • Profilers
  • Debuggers
  • Code audits and metrics
  • Load testing tools
  • Vendor performance and configuration guidelines
agenda3
Agenda
  • Background
  • Methodology
  • J2EE Optimizations
  • Performance Monitoring
tuning jdbc performance start with the obvious
Tuning JDBC Performance:Start with the Obvious
  • Use connection pooling
    • Connection objects are expensive
    • Tailor min and max connections to your application
  • Avoid cycling physical database connections
    • Look for database connections timing out
  • Tune statement caching
    • Cache distinct SQL statements
no connection pooling

Make connection,do Query

Return resultand disconnect(unless application itself doesconnection pooling)

No Connection Pooling

J2EE Container

RacingFacade

  • create
  • teamOrders
  • . . .
with connection pooling

Application usesavailable connections

With Connection Pooling

J2EE Container

RacingFacade

  • create
  • teamOrders
  • . . .

Connection Pooling

From the Container

tune your sql
Tune Your SQL!
  • Easier said than done
    • What is the real SQL running in CMP EJB?
  • Look at the SQL on the wire
    • Tools like P6Spy, Oracle Enterprise Manager
  • Become good friends with your DBA
    • Tune using traditional techniques
      • Explain plan
      • Tools like SQLPlus and Oracle9i JDeveloper
ejb locking mode and isolation
EJB - Locking-Mode and Isolation
  • Pessimistic locking is generally slower
    • May be required for applications where data collisions are likely
  • Increasing isolation decreases performance
    • Evaluate your data consistency requirements
transactions and performance
Transactions and Performance
  • Entity beans load/store data at transaction boundaries
    • Transactions settings affect how often database is accessed
    • Poor performance can be caused by transaction settings
  • Rules of thumb
    • Always use transactions for entity bean methods
    • Scope the unit of work from a session bean
session bean tx none entity bean tx required

TopicSessionFacade

  • createTopicSet
  • printTopicSet
  • deleteTopicSet

Topic

  • create
  • findBy
  • getTopicId
  • getTopicDesc
  • getTopicName
  • setTopicId
  • setTopicDesc
  • setTopicName
Session Bean - Tx:NoneEntity Bean - Tx:Required

System.out.println(“<Create Test>");

for(int i=0;i<3;i++)

{

TopicLocal topic = topicHome.create( new Integer(i),("topic " + i));

topic.setDesc("desc" + i);

}

System.out.println(“</Create Test>");

tx:None

tx:Required

resulting transactional activity

Tx create

Tx create

Tx create

Tx setDesc

Tx setDesc

Tx setDesc

Resulting Transactional Activity

<Create Test>

TopicBean: ejbCreate id = 0

TopicBean: ejbStore id = 0

TopicBean: ejbLoad id = 0

TopicBean: ejbStore id = 0

TopicBean: ejbCreate id = 1

TopicBean: ejbStore id = 1

TopicBean: ejbLoad id = 1

TopicBean: ejbStore id = 1

TopicBean: ejbCreate id = 2

TopicBean: ejbStore id = 2

TopicBean: ejbLoad id = 2

TopicBean: ejbStore id = 2

</Create Test>

Requires:

12 lifecycle

calls

session bean tx required entity bean tx required

TopicSessionFacade

  • createTopicSet
  • printTopicSet
  • deleteTopicSet

Topic

  • create
  • findBy
  • getTopicId
  • getTopicDesc
  • getTopicName
  • setTopicId
  • setTopicDesc
  • setTopicName
Session Bean - Tx:RequiredEntity Bean - Tx:Required

System.out.println(“<Create Test>");

for(int i=0;i<3;i++)

{

TopicLocal topic = topicHome.create( new Integer(i),("topic " + i));

topic.setDesc("desc" + i);

}

System.out.println(“</Create Test>");

tx:Required

tx:Required

resulting transactional activity1
Resulting Transactional Activity

<Create Test>

TopicBean: ejbCreate id = 0

TopicBean: ejbCreate id = 1

TopicBean: ejbCreate id = 2

</Create Test

TopicBean: ejbStore id = 0

TopicBean: ejbStore id = 1

TopicBean: ejbStore id = 2

Same code:

6 lifecycle

calls

Tx : createTopic

take advantage of your ejb container configuration
Take Advantage of Your EJB Container Configuration

ExampleParameter

Type

Performance Characteristic Impacted

call-timeout

Session &Entity

Specifies the maximum time to wait for any resource that the EJB container needs before the container calls the EJB method (excluding DB).

Specifies the number of times to re-try a transaction that was rolled back due to system level failures.

max-tx-retries

Session &Entity

do-select-beforeinsert

CMP

Recommend setting to false to avoid the extra select before insert which checks if the entity already exists before doing the insert. This will then detect a duplicate, if there is one, during the insert.

read-only

CMP

Multiple users can execute the entity bean in parallel. The container does not allow any updates to the bean's state.

update-changedfield-only

CMP

Specifies whether the container updates only modified fields or all fields to when ejbStore is invoked. Default true.

cache-timeout

StatelessSession

Specifies how long to keep stateless sessions cached in the pool.

tuning servlet performance load on startup
Tuning Servlet Performance: Load on Startup
  • Increases application start-up time but decreases first-request latency for servlets
  • How?
    • Add <load-on-startup> sub-element inhttp-website.xmlto load the entire web module on startup
    • Add <load-on-startup> sub-element to the <servlet> element in web.xml to load the servlet on startup
tuning jsp performance pre translation
Tuning JSP Performance: Pre-Translation
  • Pre-compile JSPs into .class files ahead of time
  • In Oracle Application Server, ojspc provides this functionality
    • jsp, and .java
    • Batch compilation of war, jar, ear and zip files

% ojspc -dir /myapp/mybindir -srcdir /myapp/mysrcdir MyPage.sqljsp MyPage2.jsp

% ojspc -deleteSource myapp.war

use httpsession appropriately
Use HTTPSession Appropriately
  • Minimize the objects you store in HTTPSession
    • Takes up memory
    • Expensive serialization/deserialization if you use persistence/replication
    • Use transient variables to reduce serialization overhead
  • Reduce default session timeout by using HttpSession.setMaxInactiveInterval()
  • Remove session objects when no longer in use
  • Use <%@ page session="false"%> in JSP pages where you do not need a session
look for bottlenecks with load testing tools
Look for Bottlenecks with Load Testing Tools
  • Mercury Loadrunner
  • Open source
    • Apache JMeter
    • Grinder
  • Altaworks Panorama
manage application server jvms and requests per application

...

...

HTTPRequests

...

Manage Application Server JVMs and Requests Per Application
  • Load balance across server instances

OC4J Process 1

JVM

OC4J Process 2

JVM

OC4J Instance

threads more aren t necessarily better
Threads – more aren’t necessarily better!
  • The optimum number of threads required will probably vary based on application makeup and load
  • Reduction of thread contention is key
    • Iterative process
      • Don’t get discouraged!
objects be economical
Objects – be economical!
  • Object creation is expensive
    • Especially exceptions
  • Assess whether unnecessary object creation is occurring
jvm tuning
JVM Tuning
  • A number of hotspot VM options are available for tuning
    • -Xms, -Xmx, -Xmn, -XX:SuvivorRatio,…
  • Some platform vendors provide additional options
    • HP: -XX:+ForceMmapReserved
  • Some platforms are not properly tuned out of the box for Java processing
garbage collection
Garbage Collection
  • Change the JVM Heap size
    • java –jar –Xms256m –Xmx256m oc4j.jar
  • Monitor collection cycles
    • verbose:gc
    • Profiling of heap
      • JDK 1.5 Jconsole
      • Intel Vtune
      • HPJtune
      • . . .
agenda4
Agenda
  • Background
  • Methodology
  • J2EE Optimizations
  • Performance Monitoring
performance monitoring
Performance Monitoring
  • Optimization doesn’t end with deployment
  • Monitoring tools key to continued application responsiveness
    • Oracle Enterprise Manager
    • HP OpenView
    • . . .
final thoughts
Final Thoughts
  • Performance tuning is an iterative process
  • An object pool is not always faster
  • Do not add threads haphazardly
  • Exceptions are expensive