Showing posts with label Cache. Show all posts
Showing posts with label Cache. Show all posts

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”

Wednesday, December 25, 2013

Webshere Commerce - Data Cache (Part 3) - wc-server.xml


Populating data in CacheIVL: <WCD>\schema\db2\wcs.cacheivl.trigger.sql will do the job of copulating cache table when ever there is a add,delete and update.

Configure wc-server.xml:
Ensure that you have the following element in wc-server.xml under instanceProperties element

<CrossTransactionCache
            clearCacheOnMaxInvalidationIdsPerTransaction="false"
            clearUserDataCacheOnLogoff="false" clearUserOnLogoff="true"
            commandCaching="default" defaultResultSizeThreshold="8"
            enabled="true" maxInactivityTime="86400"
            maxInvalidationIdsPerTransaction="100000"
            maxTimeToLive="172800" reduceInvalidationIds="false" reduceMemory="false">
            <WCSystemDistributedMapCache enabled="true"
                maxInactivityTime="86400" maxTimeToLive="172800" reduceMemory="false"/>
            <com.ibm.commerce.user.objsrc.OrganizationCache enabled="true"/>
            <com.ibm.commerce.taxation.objsrc.CountryCache enabled="true"/>
            <com.ibm.commerce.taxation.objsrc.StateProvinceCache enabled="true"/>
            <com.ibm.commerce.user.objsrc.MemberGroupCache enabled="true"/>
            <com.ibm.commerce.user.objsrc.RoleCache enabled="true"/>
            <com.ibm.commerce.fulfillment.objsrc.ShippingModeCache enabled="true"/>

            <com.ibm.commerce.fulfillment.objsrc.ShippingModeDescriptionCache enabled="true"/>
            <com.ibm.commerce.common.objsrc.StoreEntityDescriptionCache enabled="true"/>
            <com.ibm.commerce.common.objsrc.CurrencyCache enabled="true"/>
            <com.ibm.commerce.common.objsrc.CurrencyDescriptionCache enabled="true"/>
            <com.ibm.commerce.common.objsrc.LanguageCache enabled="true"/>
            <com.ibm.commerce.common.objsrc.LanguageDescriptionCache enabled="true"/>
            <com.ibm.commerce.catalog.objsrc.CatalogCache enabled="true"/>
            <com.ibm.commerce.catalog.objsrc.CatalogDescriptionCache enabled="true"/>
            <com.ibm.commerce.common.objsrc.SupportedLanguageCache enabled="true"/>
            <com.ibm.commerce.fulfillment.objsrc.FulfillmentCenterCache enabled="true"/>

            <com.ibm.commerce.attachment.beansrc.AttachmentRelationUsageCache enabled="true"/>

            <com.ibm.commerce.attachment.beansrc.AttachmentRelationUsageDescriptionCache enabled="true"/>

            <com.ibm.commerce.infrastructure.facade.server.commands.CreateAttachmentUsageConfigurationCmdImpl enabled="true"/>
            <com.ibm.commerce.user.beansrc.PolicyAccountCache enabled="true"/>
            <com.ibm.commerce.user.beansrc.PolicyAccountLockoutCache enabled="true"/>
            <com.ibm.commerce.user.beansrc.PolicyPasswordCache enabled="true"/>
            <WCSessionDistributedMapCache enabled="true"
                maxInactivityTime="900" maxTimeToLive="172800" reduceMemory="false"/>

            <com.ibm.commerce.component.contextservice.commands.ContextDataSerValueCacheCmdImpl enabled="true"/>
            <WCContractDistributedMapCache enabled="true"
                maxInactivityTime="86400" maxTimeToLive="172800" reduceMemory="false"/>
            <com.ibm.commerce.contract.beansrc.BusinessPolicyCache enabled="true"/>
            <com.ibm.commerce.contract.beansrc.PolicyDescriptionCache enabled="true"/>
            <WCPromotionDistributedMapCache enabled="true"
                maxInactivityTime="86400" maxTimeToLive="172800" reduceMemory="false"/>
            <com.ibm.commerce.fulfillment.objsrc.CalculationCodeCache enabled="true"/>

            <com.ibm.commerce.fulfillment.objsrc.CalculationCodeDescriptionCache enabled="true"/>

            <com.ibm.commerce.tools.epromotion.objimpl.CalculationCodePromotionCache enabled="true"/>

            <com.ibm.commerce.marketing.promotion.AbstractPromotionSessionBeanPersistenceManager enabled="true"/>

            <com.ibm.commerce.marketing.promotion.group.PromotionGroupSessionBeanPersistenceManager enabled="true"/>

            <com.ibm.commerce.marketing.promotion.policy.PromotionPolicySessionBeanPersistenceManager enabled="true"/>

            <com.ibm.commerce.marketing.promotion.runtime.ShopcartDrivenAgendaBuilder.SHOPCART enabled="true"/>

            <com.ibm.commerce.marketing.promotion.runtime.ShopcartDrivenAgendaBuilder enabled="true"/>
            <WCMarketingDistributedMapCache enabled="true"
                maxInactivityTime="86400" maxTimeToLive="172800" reduceMemory="false"/>

            <com.ibm.commerce.tools.campaigns.CampaignInitiativeEvaluateCmdImpl enabled="true"/>

            <com.ibm.commerce.marketing.commands.elements.DisplayMerchandisingAssociationActionTaskCmdImpl.MASSOCCECE enabled="true"/>

            <com.ibm.commerce.marketing.commands.elements.DisplayMerchandisingAssociationActionTaskCmdImpl enabled="true"/>
            <com.ibm.commerce.marketing.dialog.util.MarketingUtilCatalog enabled="true"/>
            <WCUserDistributedMapCache enabled="true"
                maxInactivityTime="900" maxTimeToLive="172800" reduceMemory="false"/>

            <com.ibm.commerce.membergroup.commands.ListMemberGroupsForUserCmdImpl enabled="true"/>
            <com.ibm.commerce.user.objsrc.DemographicsCache enabled="true"/>
            <com.ibm.commerce.dynacache.commands.MemberGroupsCache enabled="true"/>
            <com.ibm.commerce.user.objsrc.MemberGroupMemberCache enabled="true"/>
            <com.ibm.commerce.user.objsrc.MemberRelationshipsCache enabled="true"/>

            <com.ibm.commerce.user.beansrc.MemberRelationshipsExtendedCache enabled="true"/>
            <com.ibm.commerce.user.objsrc.MemberRoleCache enabled="true"/>
            <com.ibm.commerce.user.objsrc.MemberCache enabled="true"/>
            <com.ibm.commerce.user.objsrc.UserCache enabled="true"/>
            <com.ibm.commerce.user.objsrc.UserRegistryCache enabled="true"/>

            <com.ibm.commerce.accesscontrol.policymanager.CommandLevelAuthorizationCache enabled="true"/>

            <com.ibm.commerce.accesscontrol.policymanager.ParentOrganizationCache enabled="true"/>

            <com.ibm.commerce.marketing.promotion.runtime.PromotionArgumentSessionBeanPersistenceManager enabled="true"/>
            <WCCatalogGroupDistributedMapCache enabled="true"
                maxInactivityTime="86400" maxTimeToLive="172800" reduceMemory="false"/>
            <com.ibm.commerce.catalog.objsrc.CatalogGroupCache enabled="true"/>

            <com.ibm.commerce.catalog.objsrc.CatalogGroupDescriptionCache enabled="true"/>
            <com.ibm.commerce.catalog.beansrc.CatalogGroupRelationCache enabled="true"/>
            <WCCatalogEntryDistributedMapCache enabled="true"
                maxInactivityTime="86400" maxTimeToLive="172800" reduceMemory="false"/>

            <com.ibm.commerce.fulfillment.objsrc.CatalogEntryShippingCache enabled="true"/>
            <com.ibm.commerce.catalog.objsrc.CatalogEntryCache enabled="true"/>

            <com.ibm.commerce.catalog.objsrc.CatalogEntryDescriptionCache enabled="true"/>
            <com.ibm.commerce.catalog.objsrc.ItemCache enabled="true"/>
            <com.ibm.commerce.catalog.objsrc.ProductCache enabled="true"/>
            <com.ibm.commerce.catalog.util.CatalogHelperCache enabled="true"/>

            <com.ibm.commerce.catalog.beansrc.CatalogGroupCatalogEntryRelationCache enabled="true"/>
            <WCPriceDistributedMapCache enabled="true"
                maxInactivityTime="86400" maxTimeToLive="172800" reduceMemory="false"/>
            <com.ibm.commerce.catalog.beansrc.ListPriceCache enabled="true"/>
            <com.ibm.commerce.order.objsrc.OfferCache enabled="true"/>
            <com.ibm.commerce.order.objsrc.OfferPriceCache enabled="true"/>
            <com.ibm.commerce.price.commands.RetrievePricesCmdImpl enabled="true"/>
        </CrossTransactionCache>


After configuring distirbutedMap on server. You should see following logging statements in sysouts

ResourceMgrIm I   WSVR0049I: Binding WCUserDistributedMapCache as services/cache/WCUserDistributedMapCache
ResourceMgrIm I   WSVR0049I: Binding WCSessionDistributedMapCache as services/cache/WCSessionDistributedMapCache
ResourceMgrIm I   WSVR0049I: Binding WCCatalogEntryDistributedMapCache as services/cache/WCCatalogEntryDistributedMapCache
ResourceMgrIm I   WSVR0049I: Binding WCCatalogGroupDistributedMapCache as services/cache/WCCatalogGroupDistributedMapCache
 This means all the configured distirbutedMaps are active now.


This will ensure all the settings regarding the data cache is completed. Still i have to find if WC is considering cacheivl? is the invalidation schedule job provided by the IBM is working? why i ask this question is simple. Trigger ran twice for catalog table and there is double data in cacheivl. when i ran invalidation job. data was not removed from cacheivl. If any one know more on this please share.

Tuesday, December 24, 2013

Webshere Commerce - Data Cache (Part 2) - Enabling and configuring distributedMap

 There are two ways to configure data cache

  • By creating cacheinstance.properties
  • By configuring on application server.  This is discussed below

    Step By Step setup:

  • Step 1: Click on Object Cache instances
  • Step 2: Click New
  • Step 3: Get the distributed Map you want configure (here)
  • Step 4: Here i am setting properties for a single JVM . JNDI has to be services/cache/distributedMapName ( you will get that from Step 3)

Friday, December 20, 2013

Caching intro


Well .. before i started going through the websphere commerce caching features. I was under assumption only JSPs, Static content only can be cached for easy access.

IBM Websphere commerce cache almost everything like JSP, Sevlets, Commerce commands.
What are other features IBM WC provides for caching?
  • IBM WC verifies if content of cache is valid . And this validation is run on rule based, time based , group based(What is this? got to find out)  and programmatic.
  • If you have multiple servers it can replicate caching on all the servers.
  • When you are restarting server large chunk of cache will be preserved to reused after restart. ( this is really news to me. Most of the time we restart server to ensure there is no cache is present on server. IBM WC does a smart saving of cache) So next time if you are still seeing old data after restart remember to clear cache using cache monitor.

Now question is how are we going to enable above features and where. Here is the answer cachespec.xml

Based on type of content some content of data can be cached at browser level , If data is more secured then cache data at server level ( more secure) . IBM WC can cache full page or partial page based on what you define.

I will cover Cachespec.xml and how to utilize better caching.