Dynamic caching with Trade and WebSphere
The dynamic cache service improves performance by caching the output of servlets, commands, and Java™ Server Pages (JSP) files.
By caching the response from servlets, Web services, JSPs, and WebSphere® Application Server commands, the application server does not have to perform the same computations and back-end queries multiple times. The WebSphere Application Server consolidates several caching activities, including servlets, Web services, and WebSphere commands into one service called the dynamic cache. These caching activities work together to improve application performance and share many configuration parameters, which are set in an application server's dynamic cache service. The dynamic cache works within an application server Java Virtual Machine (JVM) intercepting calls to cacheable objects, for example, through a servlet's service() method or a command's execute() method, and either stores the object's output to or serves the object's content from the dynamic cache. Because J2EE applications likely have high read/write ratios and can tolerate small degrees of latency, the dynamic cache can create an opportunity for significant gains in server response time, throughput, and scalability to make the data current. However, the possible use of dynamic caching technology should be reviewed with application developers and owners so they will design and program to ensure data validity is maintained should WebSphere data caching be activated.
A cache hit is generally served in a fraction of the time of a non-cached request. Significant performance gains are generally achieved with Trade when dynamic caching technology is used.
The only parameter that can be set in the WebSphere Application Server for the dynamic cache service is the size of the cache, which is expressed as the maximum number of entries that the cache can hold. This value is set using the WebSphere Application Server administration console under application servers > server_name > web container services > dynamic cache service. The actual caching service mode is set by each application individually.
WebSphere Application Server V6.0 provides two interfaces, DistributedObjectCache and DistributedMap, by which J2EE applications can cache and share Java objects by storing a reference to the object in the cache. These interfaces expand on the command bean and servlet fragment caching capabilities already provided in previous versions of WebSphere Application Server. By default, the caching capabilities within Trade are disabled. However, the caching type can be modified to use either the DistributedMap interface or command bean caching (Command caching) interface.
- No cache - No caching is used.
- Command caching - This caching feature was added to WebSphere Application Server V5.0 for storing command beans in the dynamic cache service. Support for this feature was added in Trade 3 and carried over to Trade 6.
- DistributedMap - This feature is new in WebSphere Application Server V6.0, providing a general API for storing objects in the dynamic cache service.
For the measurements we took in this study, we used the three caching modes (No cache, Command Caching, DistributedMap caching). See Web.xml for the section of the web.xml file that is modified for dynamic caching.
Dynamic caching requires that the application supply a cachspec.xml file (found in /opt/IBM/WebSphere/AppServer/profiles/default/installedApps/<WebSphere node>/trade.ear/tradeWeb.war/WEB-INF) that defines the caching policies for the application. Cachespec.xml contains the file that was used for all our measurements.