When developing an application in a web server environment, the ease of use and startup time of the application are crucial elements for best performance. Due to this, the Hot Code Replace (HCR) debugging technique was developed to “facilitate experimental development and to foster iterative trial-and-error coding,” effectively improving application development performance. In brief, HCR allows you to “start a debugging session on a given runtime workbench and change a Java file in your development workbench, and the debugger will replace the code in the receiving VM while it is running.” In essence, no restart is needed.
However, when changing either class signatures or instance variables, HCR will not work; a restart is required for changes to take effect. “Context Reloading”, necessary for changes on configuration or property files to take effect, also requires a restart.
This is where problems arise. The need to restart the application consumes too much time. In my experience, one of my projects takes an average of three (3) minutes to restart. Restarting ten (10) times already uses up 30 minutes of valuable development time.
My current development environment: Mac OS X 10.4.11, Maven 2, Struts 1, Spring 2.0, Hibernate 3, Eclipse Galileo
The following measures below were taken to improve performance. This can serve as guidelines for the enhancement of server startup time.
1. Disable Xdoclet Maven Plugin (for hbm generation) when not needed. This decreased startup time from 2:59 to 2:32.
2. Lazily instantiate beans during development. A major bottleneck in application startup occurs during Spring pre-instantiation of singletons (our project has 677 beans defined in application context) in factory. Set Spring’s “default-lazy-init” to “true”. Startup time decreased from 2:32 to 1:58.
3. Upgrade project execution environment to the latest version of JVM. I upgraded the default Mac OS X default JVM 1.5 to SoyLatte JDK 6, further decreasing startup time from 1:58 to 1:02.
4. Use embedded Jetty instead of Maven Jetty Plug-in or Eclipse Jetty Adapter Plug-in when starting the web server. This lessened startup time even further, from 1:02 to 0:37.
The measures described above effectively shortened the average startup time from 2:59 to 0:37!
So if you want to boost your productivity, try out the guides set above! These tips will definitely make startup time faster and help improve your application development performance.