SpringOne2GX : Peter Ledbrook’s session on Performance Tuning

21 / Oct / 2010 by Himanshu Seth 0 comments

Peter Ledbrook took an amazing session on tuning your grails Application here at SpringOne2GX in Chicago. In this session Peter talked about tuning the various aspects about in your application starting from server side optimizations to the caching and zipping of static resources.

One of the most important thing that Peter pointed out was to “Avoid Premature Optimizations”. You first have to know that where the bottleneck exists(i.e. if it exists at all). So the first step towards performance tuning is actually profiling the application. So, its Profie then optimize

For profiling, we need to understand and identify where things can be slow. Where can things be slow?

As we can see, the bottleneck can be at any of the layers. We can broadly classify the layers into

  1. Server Side
  2. Client side

Some of the tools that are available on the server side include

  1. The profiler plugin from Peter
  2. Turning on hibernate logging or using P6Spy plugin.
  3. New and shiny Spring Insight: The stats that it provides are truly amazing and informative. Its indeed a thing to look out for. However, being a grails user, the only thing that I didn’t like was that i had to create a war out of my application and deploy it on the Spring TC Server. Will love to see a grails plugin that provides these capabilities :-).

On the client/UI side performance profiling, Peter demoed a couple of tools:

  1. Google’s speed tracer for Google Chrome. Its a client side performance profiling tool for Google Chrome which integrates nicely with Spring Insight to provide all your client side as well as server side performance stats at one place.
  2. YSlow” extension for FireFox (needs firebug) : This is a trusty old partner that actually tells you in clear words what you need to do to improve performance of your application on the UI level.

Once you have diagnosed the problem(s) aka done the profiling, then you need to get down to some dirty (hard) work to fix these issues: For the database performance improvements, Peter explained the various things that can be done like :

  1. Reduce the number of queries
  2. Tune your queries to use indexes or even change the model if the need be
  3. Caching: how to use the hibernate 2nd level cache or using someother caching strategies like Distributed cache (e.g. Terracotta, Gemfire and the likes)
  4. And if the need be, use an Alternative Data Store

For other server side improvements, Peter also pointed out the use of the Spring cache plugin and also how it can be used to cache complete pages or even page fragments.

For improving the performance on the UI level, there are a number of things that can be done such as:

  1. Reduce number of requests (latency)
    1. Expires HTTP
    2. Bundle CSS & Javascript files
    3. Image spriting
  2. Reduce amount of data transferred to browser (bandwidth)
    1. Minify Javascript
    2. Compress data

For doing all these things the grails way, there are plugins like UI Performance, JAWR, Resources et al. available I have worked with UI Performance and now can’t wait to get hold of the awesome Resources plugins family by Marc Palmer after hearing about it from Peter.

Well learnt a lot of new things and some learnings got re-enforced. Really happy to be here among this buzzing and vibrant community.

As someone at the conference said: “These are exciting times :)”

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *