Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Verlichte Java Applicaties<br />Oracle Technology Daya – Enterprise Java Performance<br />
Overview<br />What is performance?<br />Where is performance established?<br />Advanced tuning methods<br />ISYITF Method ...
Performance Degradation<br />65 %<br />
Performance Degradation<br />Response time<br />+ 65 %<br />
Performance<br />Who determines in what way the performance<br />Expectations<br />Measure objectively<br />Business Owner...
The Theater manager<br />
Typical Layout of Enterprise Java applicatiONS<br />Performance ≈ Wait for Response<br />Web Browser<br />JEE Application ...
Performance contributors in Enterprise Java applicatiONS<br />Performance ≈ Wait for Response<br />Web Browser<br />Respon...
Advanced Tuning Methods<br />Use StringBuffer rather than plain String concatenation<br />Use SAX for XML parsing instead ...
ISYITF Method for Performance improvement<br />The fastest way to perform a task:<br />DO NOT do it<br />
Prevent unneeded processing<br />  if ( expensiveEvaluation & someFlag) {  ...} <br />  if (someFlag && expensiveEvaluatio...
Prevent unneeded processing<br />log.debug ( “Outcome step 2: ” + resultOfExpensiveProcessing );<br />  if (log.doDebug) l...
The shopping algorithm<br />
The Shopping algorithm<br />shopForItem Item ( String itemName) {driveToShop;  Item item = buyItemAtShop ( itemName);drive...
Get this week’s groceries <br />getGroceries Item[] ( String[] shoppingList) {   Item[] items = new Item[ shoppingList.len...
ISYITF Method for Performance improvement<br />At All<br />At All<br />More often than required<br />DO NOT do it<br />
Sweet memories<br />
Stock management<br />
Stock management<br />
Do not do it…More often than required<br />If it has been produced before…<br />Reuse before re-produce!<br />If it has be...
Do not do it…More often than required<br />Save on network trips, context switches and tiers to cross<br />Save on ‘reprod...
Cookies
 HTML 5 db</li></ul>Edge Cache<br />JEE Application Server<br />Cache<br />Cluster Fail-Over<br />(Session State)<br />Res...
More performance requires parallel<br />
More performance requires parallel<br />
ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<b...
Moore’s law revised: cores law<br />
Do not do it…On your own<br />Parallel means: multiple resources contributing to a task at the same time<br />Leverage mul...
Balance resources to Prevent Clogging<br />
Pancake Party<br />
Better performing Pancake Party<br />
Pipelined Pancake Party: best performance<br />
Pipelined Pancake Party<br />Parallel Pipelined: multiple different resources working on different components of the task ...
Pipelining across the tiers<br />Database: <br />Pipelined Table Functions<br />Pipes and Queues<br />Middle tier:<br />Mu...
The pinnacle of un-performance<br />
Fire and forget<br />
ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<b...
fire and forget in the real world<br />
Do not do it…Immediately (or synchronously)<br />Submit information, file a complaint or request, start a process, trigger...
Do not do it…in BATCH (un-immediately)<br />Batch jobs can put peak load on a system – choking on line applications<br />M...
Don’t call us … we’ll call you<br />
ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<b...
Do not do it…As per request<br />Push has two key advantages over poll<br />Most up to date information<br />Reduction in ...
Bite off more than you can Have to chew<br />
ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<b...
Do not do it…In too big steps<br />Performance perception is often: time until page is displayed and accessible (hourglass...
Do not do it…In too big or too small steps<br />Every network round-trip  and context-switch adds overhead<br />Compare di...
The hard way<br />
a convoluted way<br />
ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<b...
Do not do it…In a convoluted way<br />Pragmatism can overcome theoretical purity (or old dogs’ tricks)<br />With good reas...
Bottleneck / Critical chain<br />
ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<b...
Bottleneck / Critical chain<br />Make sure that the bottleneck resource in your enterprise application is not used (at pea...
Do not do it… LIVE Event processingIn a suboptimal place<br />The league of real time events<br />Continuous stream of a m...
Do not do it… HTML RenderingIn a suboptimal place<br />(X)HTML is not very compact<br />Information density of HTML is ver...
Do not do it…In a suboptimal place<br />Do not perform a task in a resource that is not ideally suited for that task<br />...
Do not do it…In a suboptimal place<br />Leverage database for what it’s good at<br />Data Integrity – Primary Key /Unique ...
ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<b...
Architect For Performance<br />Web Browser<br />JEE Application Server<br />RDBMS<br />
Architect(ure) for performance<br />Services ( Google Maps, Translation, Conversion, Data Feeds<br /><ul><li>JS data (memory)
Cookies
Upcoming SlideShare
Loading in …5
×

Java Enterprise Performance - Unburdended Applications

2,228 views

Published on

Looking at performance may quickly become a tuning exercise, the hunt for the last 2% algorithmic improvement or JVM parameter readjustment. This presentation takes a somewhat more removed look at Enterprise Java performance - taking in the broader picture of the entire multi-tier architecture and applying common sense performance concepts from every day life an applying those to enterprise Java architectures. To serve as an eye opener.

(originally created for the Oracle Technology Day on Java Enterprise Performance, May 2011, The Netherlands)

Published in: Technology

Java Enterprise Performance - Unburdended Applications

  1. 1. Verlichte Java Applicaties<br />Oracle Technology Daya – Enterprise Java Performance<br />
  2. 2. Overview<br />What is performance?<br />Where is performance established?<br />Advanced tuning methods<br />ISYITF Method for Performance Improvement:<br />Do not do it …<br />Architecting Enterprise Java applications for improved performance<br />
  3. 3. Performance Degradation<br />65 %<br />
  4. 4. Performance Degradation<br />Response time<br />+ 65 %<br />
  5. 5. Performance<br />Who determines in what way the performance<br />Expectations<br />Measure objectively<br />Business Owner<br />Business Objectives<br />Process Duration<br />Wait time<br />SLAs<br />What is start and what is end of action<br />Availability ≈ Performance<br />Disappearance Hourglass<br />Response time<br />Meaningful response<br />
  6. 6. The Theater manager<br />
  7. 7. Typical Layout of Enterprise Java applicatiONS<br />Performance ≈ Wait for Response<br />Web Browser<br />JEE Application Server<br />RDBMS<br />
  8. 8. Performance contributors in Enterprise Java applicatiONS<br />Performance ≈ Wait for Response<br />Web Browser<br />Response = Wait + Processing<br />Wait = Network 1 + Response AppServer<br />1<br />JEE Application Server<br />Response = Wait + Processing<br />Wait = Network 2 + Response Database<br />2<br />RDBMS<br />Response = Processing<br />Processing = internal wait (I/O) + CPU<br />
  9. 9. Advanced Tuning Methods<br />Use StringBuffer rather than plain String concatenation<br />Use SAX for XML parsing instead of DOM<br />Carefully select the collection class to use<br />optimize hashcode() in custom Map implementations<br />Use profiling tools to identify hotspots in the Java code<br />Remove Assertions from production code<br />Find optimal JVM switches through trial-and-error<br />Focus on GC, Heap size, thread pools<br />Pool resources and reuse objects rather than recreate<br />Leverage concurrency features in Java to<br />speed up time-to-completion through parallel execution<br />prevent underuse of CPU during I/O operations<br />Optimize algorithms for sorting, pattern matching, iteration, serialization, …<br />
  10. 10. ISYITF Method for Performance improvement<br />The fastest way to perform a task:<br />DO NOT do it<br />
  11. 11. Prevent unneeded processing<br /> if ( expensiveEvaluation & someFlag) { ...} <br /> if (someFlag && expensiveEvaluation) { ...} <br />
  12. 12. Prevent unneeded processing<br />log.debug ( “Outcome step 2: ” + resultOfExpensiveProcessing );<br /> if (log.doDebug) log.debug ( “Outcome step 2: ” + resultOfExpensiveProcessing );<br />
  13. 13. The shopping algorithm<br />
  14. 14. The Shopping algorithm<br />shopForItem Item ( String itemName) {driveToShop; Item item = buyItemAtShop ( itemName);driveHomeFromShop; return item;}<br />
  15. 15. Get this week’s groceries <br />getGroceries Item[] ( String[] shoppingList) { Item[] items = new Item[ shoppingList.length]; for (inti=0; i < shoppingList.length; i++) { items[i] = shopForItem (shoppingList[i]); } return items;}<br />
  16. 16. ISYITF Method for Performance improvement<br />At All<br />At All<br />More often than required<br />DO NOT do it<br />
  17. 17. Sweet memories<br />
  18. 18. Stock management<br />
  19. 19. Stock management<br />
  20. 20. Do not do it…More often than required<br />If it has been produced before…<br />Reuse before re-produce!<br />If it has been shipped before…<br />Reuse instead of re-ship<br />… provided it is still fresh<br />Web Browser<br />JEE Application Server<br />RDBMS<br />
  21. 21. Do not do it…More often than required<br />Save on network trips, context switches and tiers to cross<br />Save on ‘reproducing’ same results<br />Web Browser<br /><ul><li>JS data (memory)
  22. 22. Cookies
  23. 23. HTML 5 db</li></ul>Edge Cache<br />JEE Application Server<br />Cache<br />Cluster Fail-Over<br />(Session State)<br />Result Store<br />Write Behind<br />Client Result Cache<br />RDBMS<br />Result Cache<br />Materialized View<br />
  24. 24. More performance requires parallel<br />
  25. 25. More performance requires parallel<br />
  26. 26. ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<br />
  27. 27. Moore’s law revised: cores law<br />
  28. 28. Do not do it…On your own<br />Parallel means: multiple resources contributing to a task at the same time<br />Leverage multi-core CPU<br />Achieve scalability and performance with a Cluster<br />Introduce parallellism into your application<br />Java: Concurrency (ThreadPools), WorkManager<br />Database: parallel query and DML , dbms_parallel_execute, dbms_job, parallel table functions<br />Multi threading: on every tier and even across tiers<br />Engage compute grid: multi node processing unit<br />
  29. 29. Balance resources to Prevent Clogging<br />
  30. 30. Pancake Party<br />
  31. 31. Better performing Pancake Party<br />
  32. 32. Pipelined Pancake Party: best performance<br />
  33. 33. Pipelined Pancake Party<br />Parallel Pipelined: multiple different resources working on different components of the task in [potentially] different tiers<br />From batch processing to unit processing => pass the unit on for further processing as soon as part of the task is done – to leverage resources (across tiers) in parallel<br />Instead of baking the entire stack first and only then eating it…<br />… start eating as soon as the first one is done<br />Even the last guest ends earlier than without pipelining provided he eats more than one pancake<br />(he eats his first pancake when it is done, not when the stack is done)<br />The first eater is done much sooner <br />first rows/all rows ≈ first pan cake/all pan cakes<br />
  34. 34. Pipelining across the tiers<br />Database: <br />Pipelined Table Functions<br />Pipes and Queues<br />Middle tier:<br />Multiple threads<br />Queues (JMS)<br />Client tier:<br />AJAX “channels”<br />WebSockets<br />Web Browser<br />RDBMS<br />
  35. 35. The pinnacle of un-performance<br />
  36. 36. Fire and forget<br />
  37. 37. ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<br />immediately<br />
  38. 38. fire and forget in the real world<br />
  39. 39. Do not do it…Immediately (or synchronously)<br />Submit information, file a complaint or request, start a process, trigger interaction<br />No immediate response is required!<br />Asynchronous<br />Start batch job (db) or worker-thread (java)<br />Or fire event<br />Write behind (from grid) (NO SQL)<br />DML Error log<br />
  40. 40. Do not do it…in BATCH (un-immediately)<br />Batch jobs can put peak load on a system – choking on line applications<br />Monthly reporting, quarterly prolongation, yearly calculation, <br />Batch jobs are increasingly unwanted in 24/7<br />When is the “nightly” batch window?<br />Data not current (enough) by today’s standards: “batch has not run yet”<br />Batch jobs used to be desirable or needed as a result of technical limitations – that may not apply anymore<br />Continuous, near real-time operations – leveraging events, decoupling and integration architectures – are a serious alternative<br />
  41. 41. Don’t call us … we’ll call you<br />
  42. 42. ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<br />immediately<br />As per request<br />
  43. 43. Do not do it…As per request<br />Push has two key advantages over poll<br />Most up to date information<br />Reduction in network traffic and load on server<br />Push is available in several flavors<br />Middleware to Browser: comet, ADF Active Data Service, WebLogic Server HTTP Channels, long poll, WebSockets in HTML 5<br />Database to Middleware: JMS/AQ, Database Query Result Change Notification, Table Triggers, utl_http push to servlet<br />“piggy backing” – adding subscribed-to information in regular requests<br />Event driven architecture is based on push (of events) to mediating event handling infrastructure<br />
  44. 44. Bite off more than you can Have to chew<br />
  45. 45. ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<br />immediately<br />As per request<br />In too big or too small steps<br />
  46. 46. Do not do it…In too big steps<br />Performance perception is often: time until page is displayed and accessible (hourglass disappears)<br />Web pages frequently contain much more than is initially visible or even required<br />Tree nodes, inactive tabs, invisible popups, unopened dropdown lists <br />Performance perception can be enhanced by not initially loading what is not required<br />Use AJAX based post-loading to (lazy-)fetch content in subsequent, background round-trips<br />/*+ First Rows */ vs. /*+ All Rows */<br />
  47. 47. Do not do it…In too big or too small steps<br />Every network round-trip and context-switch adds overhead<br />Compare dialing the operator for every digit in the telephone number you want to learn about<br />Bundling up information to reduce the number of round trips can be advantageous for performance<br />Bring all items from the shop in one round trip<br />Leverage collections and types, XML or JSON to retrieve complex, structured object graphs from DB<br />Zipping up multiple web resources in single archive<br />Mashing up icons or images into a single big picture <br />Piggy-back information onto requests<br />
  48. 48. The hard way<br />
  49. 49. a convoluted way<br />
  50. 50. ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<br />immediately<br />As per request<br />In too big or too small steps<br />In a convoluted way<br />
  51. 51. Do not do it…In a convoluted way<br />Pragmatism can overcome theoretical purity (or old dogs’ tricks)<br />With good reason and well documented<br />Have client side Java Script directly access Google Maps – by-passing the application server<br />Have client directly access Database services<br />Use RESTful (JSON, CSV) rather than WS* and XML between browser client and application server<br />Use POJOs (Entities) throughout the application, from JPA to Web Tier – rather than copying/transferring<br />When that suffices, use simple substring i/o parsing big xml in DOM<br />Pass plain CSV/JSON/XML from DB through Java middle tier to Client when that is appropriate<br />
  52. 52. Bottleneck / Critical chain<br />
  53. 53. ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<br />immediately<br />As per request<br />In too big or too small steps<br />In a convoluted way<br />In A suboptimal place<br />
  54. 54. Bottleneck / Critical chain<br />Make sure that the bottleneck resource in your enterprise application is not used (at peak times) for work that is not critical or that can be outsourced<br />Use auxiliary resources – outside critical chain<br />Engage specialized servers, optimized for specific tasks<br />Manage resources in a strict manner<br />Resource manager (DB) or Work manager (WLS)<br />
  55. 55. Do not do it… LIVE Event processingIn a suboptimal place<br />The league of real time events<br />Continuous stream of a multitude of tiny events with hardly any payload, to analyze & aggregate<br />Sent from physical sensors (temperature, pressure, RFID, security gates), process sensors, Twitter, manufacturing equipment, database triggers, web servers, ESBs, stock trade tickers, sport statistics, RSS, network switches, …<br />
  56. 56. Do not do it… HTML RenderingIn a suboptimal place<br />(X)HTML is not very compact<br />Information density of HTML is very low<br />DHTML, JavaScript &AJAX allow for<br />Dynamic HTMLrendering in browser<br />Dynamic, PartialPage Refresh<br />Most HTML presentedby application is pre-defined<br />Dynamic data contentfetched from RDBMSor other services issmall fraction<br />Web Browser<br />JEE Application Server<br />RDBMS<br />
  57. 57. Do not do it…In a suboptimal place<br />Do not perform a task in a resource that is not ideally suited for that task<br />If it directly contributes to overall performance<br />
  58. 58. Do not do it…In a suboptimal place<br />Leverage database for what it’s good at<br />Data Integrity – Primary Key /Unique Key /Foreign Key<br />Aggregation<br />Sorting<br />Data Rule enforcement<br />Bulk DML and Copy data<br />Analytical Functions, Model clause, Rollup<br />Specialized engines for<br />Imaging and Document Processing<br />Match and Search<br />Speech Recognition<br />Cryptography<br />3D <br />….<br />
  59. 59. ISYITF Method for Performance improvement<br />DO NOT do it …<br />At All<br />More often than required<br />On your own<br />immediately<br />As per request<br />In too big or too small steps<br />In a convoluted way<br />In A suboptimal place<br />
  60. 60. Architect For Performance<br />Web Browser<br />JEE Application Server<br />RDBMS<br />
  61. 61. Architect(ure) for performance<br />Services ( Google Maps, Translation, Conversion, Data Feeds<br /><ul><li>JS data (memory)
  62. 62. Cookies
  63. 63. HTML 5 local db</li></ul>Web Browser<br />HTML rendering<br />Validation, Calculation, Parsing<br />“Processing” (image, cryption, compression, SETI)<br />Post load<br />(AJAX)<br />piggy-back<br />Fire&Forget<br />by-pass<br />JEE Application Server<br />
  64. 64. Architect(ure) for performance<br />Services ( Google Maps, Translation, Conversion, Data Feeds<br /><ul><li>JS data (memory)
  65. 65. Cookies
  66. 66. HTML 5 local db</li></ul>Web Browser<br />HTML rendering<br />Validation, Calculation, Parsing<br />“Processing” (image, cryption, compression, SETI)<br />Post load<br />(AJAX)<br />piggy-back<br />push<br />Fire&Forget<br />by-pass<br />Edge Cache<br />Search& Match<br />Load balancer<br />Sticky ip sessions, Throttling<br />CEP<br />Cache<br />CMS<br />JEE AppServerNode<br />JEE AppServerNode<br />Node<br />Cluster Fail-Over<br />(Session State)<br />Result Store<br />Write Behind<br />Compute<br />Grid<br />WorkManager<br />Parallel Threads<br />JMS<br />Crypto<br />Image<br />Print<br />Server<br />
  67. 67. Architect(ure) for performance<br />by-pass<br />Edge Cache<br />Search& Match<br />Load balancer<br />Sticky ip sessions, Throttling<br />CEP<br />CEP<br />Cache<br />CMS<br />CMS<br />JEE AppServerNode<br />JEE AppServerNode<br />Node<br />Cluster Fail-Over<br />(Session State)<br />Result Store<br />Write Behind<br />Compute<br />Grid<br />Compute<br />Grid<br />WorkManager<br />Parallel Threads<br />JMS<br />Crypto<br />Crypto<br />Image<br />Image<br />Print<br />Server<br />Print<br />Server<br />push<br />Client Result Cache<br />Postload<br />Fire&Forget<br />AQ/JMS<br />HTTP Push<br />DB QRCN<br />RDBMS<br />REST API<br />Result Cache<br />Aggregation<br />Filter & Sort<br />Data Integrity<br />Bulk DML<br />Resource Mgt<br />Jobs<br />Pipelining<br />Parallel Processing<br />Materialized View<br />CBO<br />
  68. 68. Services ( Google Maps, Translation, Conversion, Data Feeds<br /><ul><li>JS data (memory)
  69. 69. Cookies
  70. 70. HTML 5 local db</li></ul>Web Browser<br />HTML rendering<br />Validation, Calculation, Parsing<br />“Processing” (image, cryption, compression, SETI)<br />Post load<br />(AJAX)<br />push<br />piggy-back<br />Fire&Forget<br />by-pass<br />Edge Cache<br />Load balancer<br />Sticky ip sessions, Throttling<br />CEP<br />Cache<br />CMS<br />JEE AppServerNode<br />JEE AppServerNode<br />Node<br />Cluster Fail-Over<br />(Session State)<br />Result Store<br />Write Behind<br />Compute<br />Grid<br />WorkManager<br />Parallel Threads<br />JMS<br />Crypto<br />Image<br />Print<br />Server<br />push<br />Client Result Cache<br />Postload<br />Fire&Forget<br />AQ/JMS<br />HTTP Push<br />DB QRCN<br />RDBMS<br />REST API<br />Result Cache<br />Aggregation<br />Filter & Sort<br />Data Integrity<br />Bulk DML<br />Resource Mgt<br />Jobs<br />Pipelining<br />Parallel Processing<br />Materialized View<br />CBO<br />
  71. 71. Summary<br />Performance requirements are derived from measurable and meaningful business objectives<br />Unavailability equals Zero Performance<br />Treat Performance and Availability elements in the same equation<br />Performance should [also] be addressed in a top-down approach, across all tiers and constituent parts<br />Some ISYITF guidelines:<br />Do not do it … [AT ALL | MORE OFTEN THAN REQUIRED | ON YOUR OWN | IMMEDIATELY | AS PER REQUEST | IN TOO BIG OR TOO SMALL STEPS | IN A CONVOLUTED WAY | IN A SUBOPTIMAL PLACE ]<br />

×