Who  Is  This  Guy?     Will  Iverson     wiverson@nukio.com     Check  www.nukio.com  for  LinkedIn,  Twitter,  etc.     Java  since  1995     Pascal/C/C++  before  that…     Apple,  Symantec,  Sun,  BEA…     Four  books  on  Java     Hibernate,  Web  Services,  Mac  OS  X  Java,  Jakarta  Commons     Today:  Architect,  Consultant,  Manager,  Coach     All  Star  Directories     Nukio  
The  Setup     IT  has  dead  bodies     What  happened…  and  next  steps?  
Finding  Bodies     Profiler?     Heap  dumps     Thread  dumps     Stack  traces  
 Getting  Heap  Dumps     Built-­‐in  Executables  (available  in  prod)     java  (VM  flag,  dump  on  OOM)     jmap     jconsole  (JMX)     jvisualvm     All  profilers     YourKit,  NetBeans,  Eclipse,  JProbe     Only  available  in  dev  
Getting  Thread  Dumps     Built-­‐in  Executables  (available  in  prod)     jstack     jconsole     Jvisualvm     All  profilers     Only  available  in  dev  
Beat  Patrol     Get  to  know  the  neighborhood  when  nothing    is   going  on…     Heap     Thread  Dump     Profilers  (CPU)  
Cases     Memory  Problem  #1     Memory  Problem  #2     Thread  Dump  #1     Thread  Dump  #2     Thread  Dump  #3     Memory  Problem  #3  
What  about  Serial  Killers?     Really  unique,  horrible  things     Strange  deadlocks     JVM  bugs     Driver  bugs     Avoid  Dark  Alleys     Don’t  write  threading  code  unless  you  need  to…     …and  you  probably  don’t  need  to.     Tip:  try  an  in  memory  database  (HSQLDB  or  db40)     Stateless,  parallel  operations     KISS     More  in  futures  section  
Reconstructing  Crimes     jstack     jmap  (ha!)     Attach  with  Visual  VM     Attach  with  jconsole     Use  Profilers  (skip  jhat)     Cheap,  powerful  
Most  Normal  Web  Apps     Problem  is  with  db/JVM  interaction,  not  JVM     Solution?     P6spy     JDBC  Driver  Shim     Records  database  interaction     Review  in  Excel  or  with  Iron  tools     http://www.cascadetg.com/hibernate/     Fit  to  target     Yes,  I  know  your  1,000,000  TPS  billing  system  required   instruction  counting…  and  you  wound  up  sending  it  out  for   an  ASIC,  etc  etc  etc…  
Tips     Single  user  on  dev  is  a  nice  starting  spot,  but  starve   your  resources.    Allocate  min  to  server.       Should  still  be  fast  as  all  heck.     Memory  or  CPU  on  a  single  page  out  of  bounds  =  total   nightmare  on  server…  think  about  all  other  requests   coming  in.     Know  your  targets     Establish  a  baseline  and  a  simple  scorecard     Know  your  database     All  mainstream  databases  have  great  tools  
Finding  the  Future     Stateless  Services     e.g.  Spring  MVC,  REST     Avoid  Sessions  &  Wizards     Shopping  cart…  that  stays  around  forever?     Key/Value  Datastores     BigTable,  MongoDB,  Amazon  S3     Easy:  play  with  today  for  free  using  Google  AppEngine     Enhance  Your  Platform     Track  CPU/Memory  Usage  for  Page  Views     Response  times  +  browser  rendering  
Tip:  Better  to  NOT  find  in   Production     Solution:  Solid  Automated  Tests,  Good  Perf   Environment     “Can’t  afford  to  automate”     “Can’t  afford  to  ship”  
Shameless  Plug     Agile  Testing     CI,  TDD     Expert  JUnit     DBUnit,  HTMLUnit,  Selenium     Automate  documentation  generation     March  25th  –  26th   www.nukio.com  
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky Problem

Java Tools and Techniques for Solving Tricky Problem

  • 2.
    Who  Is  This  Guy?     Will  Iverson     wiverson@nukio.com     Check  www.nukio.com  for  LinkedIn,  Twitter,  etc.     Java  since  1995     Pascal/C/C++  before  that…     Apple,  Symantec,  Sun,  BEA…     Four  books  on  Java     Hibernate,  Web  Services,  Mac  OS  X  Java,  Jakarta  Commons     Today:  Architect,  Consultant,  Manager,  Coach     All  Star  Directories     Nukio  
  • 3.
    The  Setup    IT  has  dead  bodies     What  happened…  and  next  steps?  
  • 4.
    Finding  Bodies    Profiler?     Heap  dumps     Thread  dumps     Stack  traces  
  • 5.
     Getting  Heap  Dumps     Built-­‐in  Executables  (available  in  prod)     java  (VM  flag,  dump  on  OOM)     jmap     jconsole  (JMX)     jvisualvm     All  profilers     YourKit,  NetBeans,  Eclipse,  JProbe     Only  available  in  dev  
  • 6.
    Getting  Thread  Dumps     Built-­‐in  Executables  (available  in  prod)     jstack     jconsole     Jvisualvm     All  profilers     Only  available  in  dev  
  • 7.
    Beat  Patrol    Get  to  know  the  neighborhood  when  nothing    is   going  on…     Heap     Thread  Dump     Profilers  (CPU)  
  • 8.
    Cases     Memory  Problem  #1     Memory  Problem  #2     Thread  Dump  #1     Thread  Dump  #2     Thread  Dump  #3     Memory  Problem  #3  
  • 9.
    What  about  Serial  Killers?     Really  unique,  horrible  things     Strange  deadlocks     JVM  bugs     Driver  bugs     Avoid  Dark  Alleys     Don’t  write  threading  code  unless  you  need  to…     …and  you  probably  don’t  need  to.     Tip:  try  an  in  memory  database  (HSQLDB  or  db40)     Stateless,  parallel  operations     KISS     More  in  futures  section  
  • 10.
    Reconstructing  Crimes    jstack     jmap  (ha!)     Attach  with  Visual  VM     Attach  with  jconsole     Use  Profilers  (skip  jhat)     Cheap,  powerful  
  • 11.
    Most  Normal  Web  Apps     Problem  is  with  db/JVM  interaction,  not  JVM     Solution?     P6spy     JDBC  Driver  Shim     Records  database  interaction     Review  in  Excel  or  with  Iron  tools     http://www.cascadetg.com/hibernate/     Fit  to  target     Yes,  I  know  your  1,000,000  TPS  billing  system  required   instruction  counting…  and  you  wound  up  sending  it  out  for   an  ASIC,  etc  etc  etc…  
  • 12.
    Tips     Single  user  on  dev  is  a  nice  starting  spot,  but  starve   your  resources.    Allocate  min  to  server.       Should  still  be  fast  as  all  heck.     Memory  or  CPU  on  a  single  page  out  of  bounds  =  total   nightmare  on  server…  think  about  all  other  requests   coming  in.     Know  your  targets     Establish  a  baseline  and  a  simple  scorecard     Know  your  database     All  mainstream  databases  have  great  tools  
  • 13.
    Finding  the  Future     Stateless  Services     e.g.  Spring  MVC,  REST     Avoid  Sessions  &  Wizards     Shopping  cart…  that  stays  around  forever?     Key/Value  Datastores     BigTable,  MongoDB,  Amazon  S3     Easy:  play  with  today  for  free  using  Google  AppEngine     Enhance  Your  Platform     Track  CPU/Memory  Usage  for  Page  Views     Response  times  +  browser  rendering  
  • 14.
    Tip:  Better  to  NOT  find  in   Production     Solution:  Solid  Automated  Tests,  Good  Perf   Environment     “Can’t  afford  to  automate”     “Can’t  afford  to  ship”  
  • 15.
    Shameless  Plug    Agile  Testing     CI,  TDD     Expert  JUnit     DBUnit,  HTMLUnit,  Selenium     Automate  documentation  generation     March  25th  –  26th   www.nukio.com