1 copyright © 2012, oracle and/or its affiliates. all rights reserved. · 2012-11-12 · jax-rs...

51
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1

Upload: buihanh

Post on 08-Nov-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1

Page 2: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

The dark art of performance tuning or how to become a performance hero without spending a penny on tools. Leonid Igolnik Vice President of Product Development

Page 3: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 3

Housekeeping

Twitter @JDD_Krakow http://twitter.com/JDD_Krakow Twitter hashtag #JDD_Krakow Facebook https://www.facebook.com/JDDconf Follow me at @ligolnik

Page 4: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 4

Agenda

About me

About you

Performance tuning and related concepts

Live demos and debugging

Further reading, talks etc

Page 5: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 5

About me

Page 6: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 6

Page 7: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 7

Page 8: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 8

Page 9: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 9

Page 10: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 10

Page 11: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 11

Page 12: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 12

In the next 90 minutes

We will process 4,853,000 transactions or about 898/sec 720 new jobs will be posted 29,500 job applications will be submitted 726 people will be hired

Page 13: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 13

About you

Page 14: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 14

Are you a:

Developer Team/Lead technical lead Manager Architect Executive

Page 15: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 15

I build products that:

Are built in Java Are not built in Java Are not built in Java but run on the JVM Are assembled from different technologies including Java Power a business Are web based applications Have to scale and run fast

Page 16: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 16

My development workstation runs

Windows Linux OS X Other

Page 17: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 17

My applications are deployed on

Windows Linux Other Unix flavor Mac OS X ????? Other

Page 18: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 18

Applications I build are used by:

100’s of users every day 1000’s of users every day 10,000’s of users every day 100,000’s of users every day 1,000,000’s of users every day I don’t know

Page 19: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 19

Performance tuning

Page 20: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 20

Performance Tuning http://en.wikipedia.org/wiki/Performance_tuning

“Performance tuning is the improvement of system performance. The motivation for such activity is called a performance problem, which can be real or anticipated. Most systems will respond to increased load with some degree of decreasing performance. A system’s ability to accept higher load is called scalability, and modifying a system to handle a higher load is synonymous to performance tuning.”

Page 21: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 21

Performance Tuning http://en.wikipedia.org/wiki/Performance_tuning

“Performance tuning is the improvement of system performance. The motivation for such activity is called a performance problem, which can be real or anticipated. Most systems will respond to increased load with some degree of decreasing performance. A system’s ability to accept higher load is called scalability, and modifying a system to handle a higher load is synonymous to performance tuning.”

Page 22: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 22

Performance Tuning http://en.wikipedia.org/wiki/Performance_tuning

“Performance tuning is the improvement of system performance. The motivation for such activity is called a performance problem, which can be real or anticipated. Most systems will respond to increased load with some degree of decreasing performance. A system’s ability to accept higher load is called scalability, and modifying a system to handle a higher load is synonymous to performance tuning.”

Page 23: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 23

Page 24: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 24

Establish acceptable behavior

Measure system performance

Identify critical parts aka

bottlenecks Modify the

system

Measure the performance

after the change

Systematic tuning typically uses following steps:

Page 25: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 25

Establish acceptable behavior

Measure system performance

Identify critical parts aka

bottlenecks Modify the

system

Measure the performance

after the change

Systematic tuning typically uses following steps:

Page 26: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 26

Measuring performance

Page 27: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 27

Establish acceptable behavior

Measure system performance

Identify critical parts aka

bottlenecks Modify the

system

Measure the performance

after the change

Systematic tuning typically uses following steps:

Page 28: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 28

Know your tools

Page 29: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 29

Know your OS Establis

h accepta

ble behavior Measure

system perform

ance

Identify critical parts aka

bottlenecks

Modify the

system

Measure the

performance

after the change

Page 30: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 30

Know you’re app server Establis

h accepta

ble behavior Measure

system perform

ance

Identify critical parts aka

bottlenecks

Modify the

system

Measure the

performance

after the change

Page 31: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 31

Know your runtime environment Establis

h accepta

ble behavior Measure

system perform

ance

Identify critical parts aka

bottlenecks

Modify the

system

Measure the

performance

after the change

Page 32: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 32

Unix tools - TOP

DESCRIPTION top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes. It can sort the tasks by CPU usage, memory usage and runtime. can be better configured than the standard top from the procps suite. Most features can either be selected by an interactive command or by specifying the feature in the personal or system-wide configuration file.

Page 33: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 33

Unix tools - VMSTAT

DESCRIPTION vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. The first report produced gives averages since the last reboot. Addi- tional reports give information on a sampling period of length delay. The process and memory reports are instantaneous in either case..

Page 34: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 34

Unix tools - IOSTAT

Description The iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates. The iostat command generates reports that can be used to change system configuration to better balance the input/output load between physical disks. The first report generated by the iostat command provides statistics concerning the time since the system was booted. Each subsequent report covers the time since the previous report. All statistics are reported each time the iostat command is run. The report consists of a CPU header row followed by a row of CPU statistics. On multiprocessor systems, CPU statistics are calculated system-wide as averages among all processors. A device header row is displayed followed by a line of statistics for each device that is configured. When option -n is used, an NFS header row is displayed followed by a line of statistics for each network filesystem that is mounted.

Page 35: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 35

JDK tools

Page 36: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 36

JDK tools JINFO

DESCRIPTION jinfo prints Java configuration information for a given Java process or core file or a remote debug server. Configuration information includes Java Systemproperties and Java virtual machine command line flags.

Page 37: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 37

JDK tools JMAP

DESCRIPTION jmap prints shared object memory maps or heap memory details of a given process or core file or remote debug server. NOTE - This utility is unsupported and may or may not be available in future versions of the J2SE SDK. jmap is not currently available on Windows platforms or on the Linux Itanium platform.

Page 38: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 38

JDK tools JSTACK

DESCRIPTION jstack prints Java stack traces of Java threads for a given Java process or core file or a remote debug server. For each Java frame, the full class name, method name, 'bci' (byte code index) and line number, if available, are printed. With the -m option, jstack prints both Java and native frames of all threads along with the 'pc' (program counter). For each native frame, the closest native sym- bol to 'pc', if available, is printed. C++ mangled names are not demangled. To demangle C++ names, the output of this command may be piped to c++filt.

Page 39: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 39

Establish acceptable behavior

Measure system performance

Identify critical parts aka

bottlenecks Modify the

system

Measure the performance

after the change

Systematic tuning typically uses following steps:

Page 40: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 40

Looking for bottlenecks

Page 41: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 41

“The "dominating consumer" is a term I coined to help describe a way to identify the fundamental performance problems that an application is facing. Generally, what I find is that no matter how many performance problems are buried in an application, there is one problem that will express itself more prominently than any of the others. Also, performance problems will all express themselves in the hardware, in some manner. So, the purpose of the term "dominating consumer" is to help one identify the underlying nature of the performance problem. My definition for "dominating consumer" is "that activity that is controlling how the CPU is being utilized””.

Kirk Pepperdine http://java.dzone.com/kirk-dominating-consumer

Page 42: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 42

Demo

Page 43: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 43

WeakHashMap<K,V>

A hashtable-based Map implementation with weak keys. An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use. More precisely, the presence of a mapping for a given key will not prevent the key from being discarded by the garbage collector, that is, made finalizable, finalized, and then reclaimed. When a key has been discarded its entry is effectively removed from the map, so this class behaves somewhat differently from other Map implementations.

Page 44: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 44

Additional reading

Kirk Pepperdine and his blog http://kirk.blog-city.com/ Attila Szegedi - Everything I Ever Learned about JVM Performance

Tuning @twitter at http://http://www.infoq.com/presentations/JVM-Performance-Tuning-twitter Java Performance book by: Charlie Hunt and

Binu John

Page 45: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 45

Q&A

Page 46: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 46

RESTful Java with JAX-RS 2.0 and Jersey

JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web services in Java.

In this presentation i will guide you through the major additions

introduced in the specification that will be brought into Java EE 7 (client API, filters and interceptors, asynchronous processing, data validation, server side content negotiation, hypermedia) and when suitable will show live demos using project Jersey 2.0, the reference implementation of JAX-RS 2.0.

Jakub Podlesak

Page 47: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 47

We are hiring

Page 48: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 48

We are hiring

Page 49: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 49

We are hiring

Managers Tech leads Software Engineers (All levels) QA Automation QA

Page 50: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 50

Page 51: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · 2012-11-12 · JAX-RS 2.0 (JSR-339) is the next version of a successful Java API for building RESTful web

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 51