Skip to main content
07 Aug 2012
What is Cache and Why is it required?
 
Wiktionary defines a cache as a store of things that will be required in future, and can be retrieved rapidly. That is the nub of it. Cache is a temporary data which duplication of some actual data somewhere else.
 
In various situation like, high amount of data, high amount of pages or more concurrent users, you will face performance problems and if you find that there is no way you improve performance in current implementation due to various reasons, cache service will work like a miracle. Adding a caching layer on top of application will definitely satisfy end user with faster access and makes the application light weight.
 
While the focus for caching is on improving performance, it it also worth realizing that it reduces load. The time it takes something to complete is usually related to the expense of it. So, caching often reduces load on scarce resources.
 
One of the most important benefit of adding cache server is, even if the main application is down cache server can keep serving with cached data. Until IT team fixes the production issue or make the application up and running again, cache server will server all the pages to end users.
 
What are the options?
 
Option 1, Cache Service;
Implement cache service on the application it self, which means same box. One of the most powerful cache framework in Java is ehCache. EhCache provides powerful APIs to implement cache service.
Benefit:
   1. Fast response.
   2. Reduces the processes on Application server.
   3. Performance benefits.
 
Option 2, Cache Server;
Add a Cache Server in the architecture, which will sit on different physical box. This option mostly follows RESTful or SOA architecture.It is responsible for below:
   1. Communicate to actual application pages.
   2. Cache the pages.
   3. Serve the end users.
Benefit:
   1. All the benefit of Option 1.
   2. Serves the end users even if the main application is down.
   3. Performance benefit on main application as it will reduce the number of request overall.
 
Test Results:
  • Though test results highly depends on the hardware specification of Cache Server box, but on various test it has been found 80-90% faster response to the end users.
  • Excellent improvement in main application performance, as it reduces the frequency of processing logic.
How to make cache server more powerful?
Don't cache less frequently accessed URLs.
  • Initialize complete cache when server get started first time.
  • Persistence the cache which will help in server restarts.
  • Implement efficient refresh mechanism to refresh cache element.
  • Use email mechanism on failure communication between Cache server and main application.
  • On expiry of Cache element, communicate to main application and get the latest page and stop expiry.

  - By
Vipul Dave,
Senior Consultant, CIGNEX India Office.