Tuesday, February 4, 2014

Improve performance through Dynamic Cache – Overview

This content is taken from my company blog written by me
http://blogs.perficient.com/ibm/2014/02/04/improve-performance-through-dynamic-cache-overview/

When you go to restaurant and you came to know you have to wait for a while to get your table, will you wait or will you go to another restaurent where you are aware that there is no wait time and have same quality of food. You would prefer second restaurant to first. You feel like buying a head set for long time, it is one of the item in your must have list. On this intention you went to online store and start browsing for head set. What if that online store took 3 minutes to show the product? Will you wait for product to load or go to another web site that is much quicker to previous one? Second site is winner here.
Faster response time on online store has to be considered as a service provided by the online store and give much importance for better service to customer.
Websphere commerce addressed this faster response by introducing Dynamic Cache. Caching will maximize the performance and minimize the load on server. Let us dive little deep to understand what different types of content are in an online store and high level details configuration elements.
Online store contains static content and dynamic data. Static content consist of HTML,images,CSS and java scripts, Whereas dynamic data contains results that are retrieved from Websphere commands (from database tables ,properties and code). What is the best way to improve performance? Simplest way to ask, is the data I see online is retrieved from nearest place from browser or it is retrieved by passing through several components. For example, When user access head phone product, Server sends images to browser and it is stored in local machine. So on second visit, images will be displayed much faster than first time. Nearer to browser better the performance.
Cache id:
Websphere commerce (WC)saves the every cacheable object in terms of cache id. When I access head phones product , let’s say server requires store id and category id. WC creates a cache id with store id and category id and save the data in cache tables. Next time if any one try to access same product on same store ( same store id and category id) . WC will return the data much faster from cache by cache id.
Cache Invalidation:
Assume every 5 hours image of the head phones is chaging. One of determining for how long we can have the present image in cache for faster response. After 5 hours this cache object will be dropped and new cache id is created with new content. We can invalidate by time,any custom rule or dependency based.You can even invaidate cache manually.
Static Caching:
In WC , we can cache either full page or part of a page. For example, in product display page only content that might be changing is list of products and price of the products. Header,footer and menu will not be changed. In this case we can cache only these three.Where as in login, contact us page or about us page, Entire page can be cacheable.
Dynamic Caching:
Dynamic caching allows to cache servlet caching i.e servlets,jsps,Struts . It allows object caching, which is used to store, distribute and share java objects.
Where will we set the rules or policies to tell WC what have to be cached? Answer is cachespec.xml. cachespec.xml is the place where we can define following information
  • What static/dynamic objects to cached
  • On what bases WC have to cache
  • When to drop the cache object
  • How each Cache entry is related ( dependency cache objects might be present)
By now you understood that WC performance can be improved through caching and basics of caching. What has to be considered for designing caching for a page. To get more details on dynamic caching and configure cachespec.xml you can go through “Mastering DynaCache in Websphere Commerce

No comments:

Post a Comment