Practical J2EE Application Architecture

A typical enterprise application spans multiple tiers and may be distributed over several machines. Data may be accessed from any of these tiers based on the application design. For example, in a multi-tiered J2EE application, data from the persistent store will usually be accessed in the EJB tier. An application with high transaction volume and with a need to provide short response time to the clients may have multiple machines in the EJB tier accessing a single data store. In such applications, access to the data store can become very expensive because generally the backend data stores run on high-performance expensive hardware and software. Even when expensive hardware and software is used, the system may not easily scale when more users and information are added to the data store since the amount of information to be retrieved could grow exponentially. In order to provide a scalable solution, a cache should be incorporated in the enterprise applications. A cache provides the following benefits:

Common solutions offered today include the following:

Application Data Caching

J2EE technology provides infrastructure support to enable developers to build multi-tiered, distributed applications using EJBs. In most multi-tiered applications, the most expensive resource from a price and access perspective is a data source such as an RDBMS. In such applications, it is beneficial to architect and design an application-level data cache.

Note

It is most beneficial if an architect adheres to Java standards such as JCACHE when designing and implementing a cache.

Most application being built today have two types of data access needs:

Transactional data does not lend itself well to caching. Generally, the frequency of changes to data causes too many cache invalidations. The frequency of updates also does not allow for a stable cache. This results in too many cache misses and defeats the purpose of caching. Thus, it is not a good practice to have a cache of transactional data. This is also true for any data where the frequency of updates can be measured in seconds and minutes rather than hours and days. In this scenario, the services offered by a J2EE container and the contracts specified for a container-managed persistence bean will be adequate. In cases where data is read-only, or it is updated less frequently, caching application data can provide good benefits. Resources permitting, read-only data is a prime candidate for caching in memory.

Категории