Introduction and general comments
This chapter discusses coding best practices for developing WAS based applications that perform well and are scalable and robust. Best practices for general Java coding as well as specific guidelines for Servlets, JavaServer Pages (JSPs), Enterprise JavaBeans (EJBs) and the use of J2EE resources are discussed.
However, a prerequisite is to ensure that your application has a good design and architecture. The techniques and strategies outlined here will assist you in optimizing the performance of your applications. However, they will not compensate for a poorly designed or architected application. The best practices should be applied after verifying that the basic design and architecture are appropriate for the application and are scalable.
It is also important to reuse existing patterns and algorithms where appropriate, rather than "reinventing the wheel". There are established algorithms and approaches for solving many of the commonly encountered problems in computer science, and any decision to use a custom solution in preference to one of these commonly used solutions should be made with caution.
Inefficient code is written for a number of reasons. These include a lack of focus on performance, a limited awareness of performance issues by the developers, or a desire to produce an elegant or highly object-oriented solution. It is important that performance targets are set at the beginning of the project and communicated to all team members involved in development. The implications of these targets on development work should also be analyzed early in the development cycle and made known.
Please note that often there is a trade-off between implementations that are elegant, object oriented, easy to read and maintain, and those that offer higher performance. In these cases, the use of profiling tools such as those included with IBM WebSphere Studio Application Developer described in Chapter 17, Development-side performance and analysis tools can be extremely useful. These tools will indicate which parts of the code are most frequently used, and also where the majority of the execution time is spent. Typically, the majority of the execution time will be spent in a minority of the code, as suggested by the 80/20 rule - 80% of the execution time will be spent in 20% of the code. In many cases, the ratio may be even higher, such as 90/10 or more. Although it is important to be aware of best practices when performing all development work, extra care should be taken to optimize the most frequently used code sections. More information on server-side tools for analyzing usage patterns of components of an application such as servlets and EJBs can be found in Chapter 16, Server-side performance and analysis tools.
In order to optimize performance experienced by the end users, ongoing tuning activities should be undertaken throughout the life cycle. Monitoring of the application during testing can indicate performance problems that are not apparent in the development environment. Additionally, specific testing of performance under simulated loads using a tool such as OpenSTA, Apache JMeter, Mercury LoadRunner, or Rational Robot will also provide insight to where performance optimization work should be targeted. Performance tuning is an iterative process that continues once the coding phase of a project is complete, through the life cycle of the project. Developing a prototype early in the development cycle can provide valuable insight into the expected performance, and will help to ensure that the implementation approach is appropriate and will perform adequately.
Note For more information about stress testing an application, refer to 19.1, Testing the performance of an application.
Prev | Home | Next WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.
IBM is a trademark of the IBM Corporation in the United States, other countries, or both.
Rational is a trademark of the IBM Corporation in the United States, other countries, or both.