Sunday, March 27, 2011

Caching Solutions in Java

Introduction

Data caching is a very important consideration for J2EE applications. Data caching limits the number of remote invocations in distributed applications and improves performance of web applications by reducing the number of calls to the persistent data stores. Even though caching improves performance and makes your architecture work, it can, in fact, complicate design and introduce such complexities as concurrent code and cluster-wide synchronization.
Once it has been decided that data caching is an integral part of the architecture, choosing the right caching solution can prove to be difficult. There is always an option to implement a caching solution from scratch. This approach can have its advantages, but will inevitably affect the project's cost and timeline. Another solution is to choose one of the open-source caching products. When choosing a caching solution, the following questions should be considered:
  1. Does caching solution provide easy integration with an ORM product?
    It should be easy to integrate the caching product with some of the popular ORM products such as Hibernate or Toplink. The domain objects are POJOS map to RDBMS entities and cached in memory, thereby reducing network traffic to the RDBMS.
  2. Does caching solution provide presentation layer caching?
    The cache product should provide HTTP response/JSP caching on the presentation layer.
  3. Does caching solution allow storage of objects in memory and disk?
    In case the memory capacity is full, the cache product should evict objects to a local disk.
  4. Is it easy to use?
    A cache product should expose minimum API for the client to use.
  5. Does it support distributed cache?
    A cache within each JVM needs to be coordinated in a clustered environment.
  6. Does it allow sharing of objects with a JVM?
    All the application threads within a JVM should be able to access the same instance of an object in a cache.
  7. Is cache invalidation supported?
    The caching product should provide a facility to invalidate a cache or a cache group. Cache invalidation should be coordinated in a distributed cache.
  8. What is the availability level?
    The cache maintains a local copy; some operations can continue even if the original source is unavailable.
  9. Is it scaleable?
    In a distributed cache, multiple copies of a cache are available across processes. Thus, the scalability of the server is improved.
  10. Is it easy to maintain?
    The cache product should have proper logging facilities in order to debug the code.
  11. Does it adherence to standards?
    JCache is the standard; in other words, the JSR 107 caching service was born out of the JCP process. If the cache supports the standard, a client can have unified access to the cache.

Available Open-Source Solutions

Against the backdrop of the requirements mentioned above, you will evaluate the various products that cache Java objects. The most important features of the various products are mentioned below.

http://java-source.net/open-source/cache-solutions


No comments:

Post a Comment