Java and Performance: Biggest Mistakes



80% of development time is spent in bugfixing and yet 80% of software defects that impact performance or scalability are only caused by a handful of architectural problem patterns.

So, why not understand what these problem patterns are by learning from others and make sure to avoid them right from the start?

After a quick intro to the problem of bad quality code itself, we walk through 6 specific examples of applications I've analyzed from a performance, scalability and architectural perspective. Each example highlights the impact of quality, the root cause and the technical metric to look at before checking in code to avoid these problems:

  • #1: Blindly using frameworks such as Hibernate/Spring ending up with too many SQL Roundtrips to query a certain dataset. Metrics: # of SQL Queries
  • #2: Rebuilding an O/R Mapper from scratch loading ALL data into a Hashtable. Metrics: # of Records loaded, # of Same SQL
  • #3: Extreme Thread Parallelization causing bottlenecks in backend services. Metrics: # of Threads, # Calls to an API
  • #4: Deploying different Hibernate and XML Parser versions in production than tested. Metrics: Time Spent in API, # Calls to an API
  • #5: Marketing Idea bad implemented: 434! Images on a Super Bowl Ad Mobile Landing Page. Metrics: # Images, Size of Resources
  • #6: Depending on too many 3rd party components during “peak load”. Metrics: # of 3rd party Domains, Size of Page

The final piece of advice is to verify some sanity checks before checking-in code but more so automating these checks when executing your automated unit-, integration- or functional tests. Most of these problems can be identified with single user tests.

More examples on metrics can be read on our blog – http://blog.dynatrace.com – by following me on @grabnerandi – and by using the Dynatrace Free Trial which stays free after 30 days when analyzing apps running on your local machine.

Andreas Grabner is a Technology Strategist at Dynatrace. This talk was recorded at the San Francisco Java User Group, May 26th 2015, in downtown San Francisco.

Published June 16, 2015