• No results found

Evidence based performance tuning of

N/A
N/A
Protected

Academic year: 2021

Share "Evidence based performance tuning of"

Copied!
50
0
0

Loading.... (view fulltext now)

Full text

(1)

Evidence based performance tuning

of

enterprise Java applications

enterprise Java applications

By Jeroen Borgers

(2)

Evidence based performance tuning

of

enterprise Java applications

By Jeroen Borgers

[email protected]

(3)
(4)

Bad performance: hard to fix

• Call center agent took 20 minutes to work through five screens with customer

– Customer un-friendly – High cost

• Speedup needed before rush of number porting

4

• Speedup needed before rush of number porting

– Major app redesign was needed

• Result

– very slow system when up, mostly system down – damage to company image

– loss of thousands of customers and $100,000,000 – company crash

(5)

Goal

Provide an answer to the question:

(6)

Who is Jeroen Borgers?

• sr. consultant with Xebia

• helps customers on enterprise Java performance issues

• instructs Java performance tuning courses • instructs Java performance tuning courses • doing Java since 1996

• various roles in several industries

– developer, architect, team lead, quality officer, auditor, performance tester and tuner

(7)

Who is Xebia?

• international IT organization

– NL, FR, IN

• specialized in enterprise Java

• consultancy and projects

• consultancy and projects

• 5 years old

• ±100 employees and growing

• share knowledge

(8)

Agenda

• Big picture architecture vs. implementation

• How to achieve bad performance

• Evidence based tuning for high speed

• Tools overview

8

• Tools overview

• Largest Dutch web shop case

• Conclusions

(9)

Enterprise Java performance

big picture

• Java is not slow anymore

• Importance how you do it: algorithms

• Typical enterprise app: most time spent in calls out of Java process

– Remote calls – Remote calls

– Database access

for (int i = 0; i < size; i++) { order = orderDao.getOrder(i);

(10)

Architecture enables performance

and scalability

• Key choices

– Application distribution

– Persistent data access approach: O-R mapping – Data conversion: XML, encodings

– Presentation tier technologies

10

– Presentation tier technologies

– Use of proprietary features of db, app server – Data caching

• It is all about:

– Remote calls

– Database access

(11)

Architecture enables,

implementation makes it happen

• Minimize remote calls and other I/O

• Speed-up data conversion

• Code optimizations involving remote calls and data conversion

(12)

Architecture enables,

implementation makes it happen

• Minimize remote calls and other I/O

– Direct JDBC: use of batch updates – Hibernate: use of query caching

• Speed-up data conversion

– XML usage: use JiBX instead of JAXB

12

– XML usage: use JiBX instead of JAXB

– URL encoding: use commons codec instead of java.net

• Code optimizations involving remote calls and data conversion

– Algorithms, collections

(13)

Architecture enables performance

& scalability

(14)

Architecture enables performance

& scalability

• The architecture is scalable

14

(15)

Architecture enables performance

& scalability

• The architecture is scalable

(16)

Architecture enables performance

& scalability

• How one implements the architecture makes a difference

16

• But the requirement of 120 km/h will never be met!

(17)

Architecture enables performance

& scalability

(18)

Architecture enables performance

& scalability

• More demanding requirements can be met with the right implementation

• Bugatti EB Veyron 16.4 18 16.4 • Top 407 km/h • 0-300 in 14 s.

(19)

How to achieve bad performance

• Many JavaEE apps have hard to solve

performance problems

• How to achieve this?

– Architecture not suitable for requirements – Architecture not suitable for requirements – Ignore the problems too long

– Don’t follow best practices

(20)

Architecture not suitable

• Architect: “Most important is a pure, flexible, scalable architecture: we distribute our

application components and loosely couple with XML and web services.”

20

• Nonsense!

– Those who pay the bill care about efficient working, not purity;

– Speed is traded for scalability: remote calls and data conversion can be killing;

(21)

Ignore problems too long

• Project leader: “First we get the functionality

right, then we start worrying about performance.” • Performance is often ignored until the final test,

a week before production, or later!

• To meet requirements you may need a major • To meet requirements you may need a major

re-design: costly • Solved by:

– Verify the architecture in a POC: test a vertical slice – Test performance continuously

(22)

How to achieve bad performance

• How to achieve this?

– Architecture not suitable for requirements – Ignore the problems too long

– Don’t follow best practices

22

– Don’t follow best practices – Optimize counterproductively

(23)

Don’t follow best practices

• Best practices are like:

– Use Map instead of List for lookups – Use I/O buffering: InputStreamBuffer – Use SQL batch updates

– Use SQL batch updates – Use db table indexes

(24)

Don’t follow best practices

• Best practices are like:

– Use Map instead of List for lookups – Use I/O buffering: InputStreamBuffer – Use SQL batch updates

24

– Use SQL batch updates – Use db table indexes

– Use StringBuffer for String concatenation?

• Be aware: a best practice may not work in

your situation

(25)

Best practices can be premature

optimizations with trade-offs

• Developer: “String performs badly, we use StringBuffer for concatenation everywhere.”

Many books: “use StringBuffer for

toString() { return “[“ + getName() + “]”; }

faster is

toString() {

StringBuffer buf = new StringBuffer(“[“); buf.append(getName()).append(“]”);

buf.append(getName()).append(“]”); return buf.toString();

}

• However: same bytecode!

Maintainability and developer time is traded for an assumed,

non-existing performance gain

(26)

Optimize counterproductively

• Updating state remotely by sending only delta’s like RemoveAttribute, AddAttribute

– many small objects with much serialization and communication overhead

• Object and thread pooling depending on JVM

26

• Object and thread pooling depending on JVM • Optimizations are very time and environment

dependent

• So: don’t trust your knowledge or intuition, but measure that your optimization solves the

(27)

Bad performance

• Architecture not suitable for requirements

• Ignore the problems too long

• Don’t follow best practices

• Optimize counterproductively

• Optimize counterproductively

(28)

Evidence based tuning for high

speed

• Don’t make assumptions but measure

• Have quantified requirements, prove they are met or not • Prove the architecture performs in a POC

• Continuously test performance during development

– to get a first impression

– for quick feedback on changes

28

– for quick feedback on changes

• Test representatively in a dedicated environment

– with production-like load

– on a production-like environment – with production-like data

• Fix problems when found

• Prove the effect of each optimization

(29)
(30)

Tools for measuring

OS profilers to see resource usage: CPU, memory, I/O, threading • Database analyzers to see query behavior in the database

Network analyzers to see network traffic

App server monitors to see app server resource usage: heap, connection pool, stmt cache,..

J2EE analyzers to see J2EE behavior under load

Instrumentation monitors to see timing at the instrumented

30

Instrumentation monitors to see timing at the instrumented locations

Java profilers to see detailed CPU and memory behavior in JVM • Continuous test tools to quickly get timing feedback of code

changes

Load test tools to generate usage load

(31)
(32)

Case: speeding up a web shop

(33)

Wehkamp TRC architecture

web server: ASP/.Net

Tuxedo DB TRC-appsrv: Java DB Services here DB

(34)

Speedup results at Wehkamp

• Several services optimized to meet requirements • Most expensive: voegKlantToe (addCustomer);

verwerkenNieuweOrder(processNewOrder): from 7 s. to 1.5 s.

• 45% db-queries, 45% tux-calls, 10% java code • Top optimizations:

34

• Top optimizations:

– Reduce number of db queries

– Optimize most expensive db queries – Reduce number of Tux/mainframe calls

– Optimize most expensive Tux/mainframe calls

• App orchestrates: many Java code changes needed for this

(35)

Tools used

• Load test tool: Apache JMeter • App level monitor: JAMon API

• History and trends reporter: JARep

• Continuous test tool: cruisecontrol+maven+JMeter • Java profiler: Quest JProbe

• Java profiler: Quest JProbe

• App server monitor: Tivoli Performance Monitor • J2EE analyzer: Quest PerformaSure

• Database analyzer: Quest Toad, Oracle Statspack • Unix OS profiler: vmstat, nmon

(36)

JMeter for generating load and

black box testing

(37)
(38)

JAMon for monitoring statistics

added

service name

(39)

Instrumenting with JAMon API

(40)

JARep reporting for history

(41)
(42)
(43)
(44)

JVM / app server node 4 JVM / app server node 3

deployment of JARep

your

app jamon.warjamonadmin .jsp

ShowJamon

Counters.jsp DataFetcher

DataPersister

every 5 minutes

JVM / app server node 3 JVM / app server node 2 JVM / app server node 1

www.xebia.com

jamonapi.jar

JVM / off-line box

RDBMS

(45)

PerformaSure for analyses under

load

(46)

Analysis tools compared

• Profiler JProbe

– Pro: High detail: code line level

– Con: High overhead, cannot deal with load

• JAMon API + JARep

– Pro: Low overhead < 1%

46

– Pro: Low overhead < 1%

– Pro: Enables comparing over time, see trends – Con: No call tree, cannot drill down

– Con: Limited to built-in measure points

• PerformaSure

– Pro: reasonable overhead, slick UI, measures all on JVM – Con: not cheap, configuration, wait time

(47)

Conclusions & recommendations

• Architecture and implementation both determine performance

• Consider whole application life cycle: requirements, POC, continuous testing, representative testing, monitoring

representative testing, monitoring • Biggest gains are in

– Remote calls and other I/O

– Database access or other data conversions

(48)

“Meten is weten”

(measuring means knowing)

(49)

References

• http://www.xebia.com • http://blog.xebia.com • http://podcast.xebia.com • http://www.javaperformancetuning.com • http://sourceforge.net/projects/jarep • http://sourceforge.net/projects/jarep • http://www.jamonapi.com • http://jakarta.apache.org/jmeter/ • http://www.quest.com/performance_management

(50)

Q & A

References

Related documents

• This method is a measurement tool which is based on comparison of companies’ performance with the best practices in the same performance assessment area..

Evidence-based medicine is rooted in five linked ideas: firstly, clini- cal decisions should be based on the best available scientific evidence; secondly, the clinical problem

Evidence-based medicine is rooted in five linked ideas: firstly, clini- cal decisions should be based on the best available scientific evidence; secondly, the clinical problem

(R+H) Composite (L+H) Composite CERN - IT Department CH-1211 Genève 23 Switzerland www.cern.ch/i t ( ) p.. Partitioned

Table 5.1 Normalized performance and the best completion time (in parentheses) for static and dynamic MSVs on P10 cluster with 600GB data size.. 44 Table 5.2 Relative comparative

Our review of candidate best practices for PDMPs indicates that several practices, such as collecting prescription information on all schedules of controlled substances,

Before outlining the association’s expectations of its members, the “best practices” begin, “CSAT Members follow these best practices for all Credit Access Business

• Follow email best practices to increase effectiveness. •