Java performance tuning

March 2nd, 2006
Filed under: Java | Huibert @ 7:53 pm

I have spent most of the week working closely with a customer who was complaining about their J2EE application performance. Normally it goes like this. The customer calls their sales rep and starts complaining about their application server performance. They usually threaten to move to application server from company A or company B if we do not fix the problem immediately. The fact is that since I have been working with J2EE application servers, in 100% of the cases, it is the application that is responsible for the performance problems, not the application server.

IBM has published some very good documents that explain what needs to be done to obtain the best performance from a J2EE application server. Although those documents focus on WebSphere Application Server, most recomendations apply to all J2EE servers. Go to http://www.redbooks.ibm.com and search for “websphere performance”.

However, if you do not have time to read a full book, you should at least read the article “10 (more or less) J2EE best practices“.

My own recommendation, on top of what the article lists, is to limit the creation of new objects in your code. Always check if there are no other alternatives, such as object reuse. My recommendation is to always apply strict scrutiny when new objects are created and always assume there is another way to do it. Use static methods when possible, but make sure that junior programmers are not instantiating objects in order to execute the static methods (a very common mistake).

Advanced Java IDEs such as Rational Application Developer will automatically detect these problems and mark them with warnings. Do not ignore them just because they are not errors that will prevent the code from running properly. Make a habit to produce code that is totally bug and warnings free. That is the best way to avoid all kind of problems.

Comments are closed.