SlideShare a Scribd company logo
1 of 52
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Accelerate your ColdFusion Applications using Caching
S V PAVAN KUMAR
sanniset@adobe.com
October 2014
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Agenda
 Caching Overview
 CF Ehcache Implementation
 CF Cache layout
 Application specific caching
 Query Caching
 ORM Caching
 Template & Object Caching
 Distributed Caching
 <cflogin> cache replication demo
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Cache
During experiments, Many bird
species store peanuts in a cache for
later retrieval. In the wild, these birds
store acorns and insects.
-Wikipedia
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Cache
A Simple Key/Value Pair
Key Value
USA Washington D.C
India New Delhi
England London
Japan Tokyo
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How Cache Works ?
Key Value
Key1 Value1
Key2 Value2
Key3 Value3
Key4 Value4
Application
Cache
Hit
Database ComputationNetwork
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How Cache Works ?
Miss
Key Value
Key1 Value1
Key2 Value2
Key3 Value3
Key4 Value4
Application
Cache
Database ComputationNetwork
Cache -
Aside
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
How Cache Works ?
Miss Key Value
Key1 Value1
Key2 Value2
Key3 Value3
Key4 Value4
Application
Cache
Database ComputationNetwork
Read -
Through
Sync/ Async
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Simply
Sacrifice memory for latency
reduction
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Eviction Strategies
 Manually deleting
 Expiration
 Expire after 2 Hours
 Expire at Oct 18th, 2014
 When Cache memory is Full
 Delete using FIFO | LRU | LFU
 Spill to Disk
EhCache does not remove expired elements immediately from
memory.
i
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Cache Bootstrapping
 How to pre-load the cache on startup
 From Disk store
 From a peer cache node
 From a central Cache server (e.g. Terracotta Server)
 Start Empty, fill later (Cold Cache)
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Cache Efficiency
Caches are not a panacea.
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ColdFusion Caches
 Query Cache
 ORM Cache
 Session level
 2nd Level Cache
 Template
 Page
 Fragment
 Object Cache
 <Cflogin> Cache
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Overview
 Industry Standard Caching Provider
 Default cache provider for ColdFusion since CF 9
 Various cache algorithms FIFO, LRU and LFU
 Better control over cache through config
 Disk persistence
 Cache replication
 Distributed caching support
 Monitoring
 Thread Safe
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
CF Cache layout
Server Level Cache ManagerApplication level Cache Manager
Application level Cache
Manager
Application level Cache Manager
QUERY
TEMPLATE
OBJECT
QUERY
TEMPLATE
OBJECT
QUERY
TEMPLATE
OBJECT
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Application Specific Caching
 Added in CF 10
 If enabled, caching is done at application level
 Set this.cache.configfile in Application.cfc
 Absolute: this.cache.configfile = "c:/myApp/ehcache.xml"
 Relative to Application.cfc: this.cache.configfile = "ehcache.xml"
 Server level Ehcache configuration file ehcache.xml can be found at
<Install_location><Instance name>lib
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Default Cache Regions
 TEMPLATE
 OBJECT
 QUERY
 Default cache names will be prefixed with applicationName (when app
specific caching is not enabled)
 <App Name>TEMPLATE
 <App Name>OBJECT
 <App Name>QUERY
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Custom Cache Regions
 Using ehcache.xml in <CF Instance Name>/lib (Hard Coding)
 cacheRegionNew() to create on-fly cache regions
 All the caches supporting cacheRegion
 All the cache functions supporting region argument
 Custom cache region can contain any type of Data
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Cache Region Properties
 Cache region properties
 retrieved using cacheGetProperties()
 set using cacheSetProperties()
<cache
name=“myCache"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="720"
timeToLiveSeconds="720"
overflowToDisk="true"
maxElementsOnDisk="100000"
diskPersistent="true"
memoryStoreEvictionPolicy="LRU"
/>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Cache Regions: CRUD
 CacheRegionNew()
 CacheRegionExists()
 CacheRegionRemove(
)
 CacheGetProperties()
 CacheSetProperties()
• CacheGet()
• CacheGetAllIds()
• CachePut()
• CacheRemove()
• CacheRemoveAll()
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Cache Metadata
 CacheGetMetadata(): to get cache meta data for cache entry
cache_hitcount Number of hits
cache_misscount Number of misses
createdtime Creation time
Name Cache region Name
idletime time to idle for an element before it expires
lasthit last hit timestamp
Lastupdated last modified timestamp
size Cached Object size in bytes
timespan time to live for an element before it expires.
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Query Cache - cachedwithin
<cfquery
name="GetParks" datasource="cfdocexamples"
cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#“
cacheRegion=“statewideParks”>
SELECT PARKNAME, REGION, STATE FROM Parks
ORDER BY ParkName, State
</cfquery>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Query Cache
 Backed by Ehcache by default from CF10.
 Internal cache fallback
 Server level setting Caching -> Use internal cache to store queries
 Application level specify
this.cache.useinternalquerycache=true|false
 Query limit
 Server level setting Caching -> Maximum number of cached queries default 100
 Application level specify
this.cache.querysize = 150
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Query Cache
 Datasource name, the actual SQL statement itself, and the parameters
passed to the SQL statement will be used to pull out from the cache if
cache id not defined
 dbtype=query" and "CachedWithin" are mutually Exclusive
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ORM Session Level Cache
 Entities loaded from DB cached in ORM session
 Short living exists as long as session is open
 Caches persistent Objects
 EntityLoad function
 For the first time hits DB gets the entity.
 For the second time retrieves from ORM session
 Should use EntityReload to force retrieval from DB
 ORMClearSession() clears session level cache
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ORM Second level Caching
 CF uses EHCache as the default secondary cache provider from CF 9
 Caches
 Persistent Object
 Persistent Object Associations
 Results of Queries
 Long lived
 Supports Application specific Cache
 Absolute: this.ormsettings.cacheConfig = "c:/myApp/ehcache.xml"
 Relative to Application.cfc: this.ormsettings.cacheConfig = "ehcache.xml"
 Can Scale in clustered environment
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ORM Cache Hierarchy
Database
ColdFusion
Application
Session Level Cache
Secondary Cache
(Ehcache)
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ORM Second level Caching Example
 Application.cfc
<cfset this.name="Caching_Example">
<cfset this.datasource="cfartgallery">
<cfset this.ormenabled="true">
<cfset this.ormsettings.secondarycacheEnabled=true>
<cfset this.ormsettings.cacheProvider= "ehcache">
<cfset this.ormsettings.cacheConfig="ehcache.xml">
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ORM Second level Caching Example
 CArtist.cfc
<cfcomponent persistent="true" schema="APP" table="Artists"
cachename="artist" cacheuse="read-only">
<cfproperty name="artistid" fieldtype="id"/>
<cfproperty name="firstname"/>
<cfproperty name="lastname"/>
<cfproperty name="state"/>
<cfproperty name="art" fieldtype="one-to-many"
cfc="CArt" fkcolumn="ArtID" cachename="ArtistArts"
cacheuse="read-only">
</cfcomponent>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ORM Second level Caching Example
 CArt.cfc
<cfcomponent persistent="true" schema="APP" table="Art">
<cfproperty name="artid" generator="identity"
fieldtype="id"/>
<cfproperty name="artname"/>
<cfproperty name="issold"/>
</cfcomponent>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ORM Second level Caching Example
<cfscript>
//This will cache the Artist Component and also the
association. It wouldn't cache the Art objects.
artistObj = EntityLoad("CArtists", 3, true);
//This will cache the query.
availableArts = ORMExecuteQuery("from CArt where issold=0",
{}, false, {cacheable=true,
cachename="availableArtsCache"});
</cfscript>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ORM Cache Access Strategies
 Read Only
 Nonstrict-read-write
 Read-write
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ORM Cache: Eviction
 ORMEvictEntity("<entity_name>", [primarykey])
 ORMevictcollection("<entity_name>", "<association_name>",
[primarykey])
 ORMEvictQueries(cachename, datasource)
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Template Cache: Pages
 Both server- side and client-
side caching
 Cache an entire page
 Single <cfcache> at top of
page
 No need of closing tag
</cfcache>
 Also, <cfcache/>
Header
Naviga
tion
Bar
Content
Footer
<cfcache>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Template Cache: Fragments
 Cache individual fragments of content
 Useful when parts of a page must remain
dynamic or personalized.
 Surround with <cfcache>…</cfcache> tags
 Multiple fragments can be cached in a
single request
 Each fragment can be configured
independently
 No Client side caching
Header
Naviga
tion
Bar
Content
Footer
<cfcache>
</cfcache>
<cfcache> <cfcache>
<cfcache>
</cfcache> </cfcache>
</cfcache>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Template Cache
 Timespan
 The interval until the item is flushed from the cache
 idleTime
 Flushes the cached item if it is not accessed for the specified time span
 Metadata
 Contains cache meta data info such as hit count, miss count created time etc.
 expireURL
 expireURL along with action = ‘flush’ used to flush pages that match the specified URL
or pattern
 Wild card Support
<cfcache action="flush" expireurl="*.cfm?productID=#URL.productID#">
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Template Cache Key
CacheI
d Given
?
Get the
Request URL
useQuer
yString ?
No
Append Query
String from
URL
Compute a hash
from page physical
path and Append
YesNo
Has
End
Tag?
Append Line No
Yes
depend
s on ?
No
Append
dependent
variables
Yes
Template Cache
Key
No
Yes
http://localhost/example/index.cfm_query_themeid=1_pageid:17CF7BD640264F4CB3D507A4
72E0190Bsession.username=JZNKA
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Object Cache
 Application code can take advantage of caching
 Can cache anything (Simple values, Complex Objects like files, images
etc.)
 Cache functions for CRUD operations and to get cache properties
(cfcache)
 Cache keys need to be managed manually. (id is mandatory)
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Distributed Caching
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Standalone
 Pros:
 In Process & faster access
 No serialization of keys and values
 Eventual Consistency local to Application
ColdFusio
n
Cache
JVM
 Cons
 Not Scalable
 Limited by CF JVM memory
 GC pauses
 On 32 Bit huge caches will suffer
 Bootstrapping only from Disk Store.
 Inconsistency on a cluster
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Replicated
ColdFusio
n
Cach
eJVM
Cach
eJVM
Cach
eJVM
Cach
eJVM
Put, Remove,
Remove All,
Bootstrapping (Sync
or Async)
RMI, Jgroup
Protocols
ColdFusio
n
ColdFusio
n
ColdFusio
n
• Pros:
• In Process
• Data Consistency in
Cluster
• Bootstrapping from a
peer node
• Cons:
• GC Pauses
• Serialization overhead
• Limited by CF JVM
Memory
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Centralized
ColdFusion
Cache
(L1)
JVM
ColdFusion
Cache
(L1)
JVM
Big
Memory
(L2
Cache)
JVM
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Demo
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
<cflogin> Auth cache
 Prior to CF9 requires sticky sessions for clustered environment if
loginStorage=cookie
 CF10 onwards auth info is stored in ehcache
 To enable long lived logins or remember me type of functionality
 To provide fail-over and replication support in cluster
 Configuration for cflogin cache can be found at <cf-home>/lib/auth-
ehcache.xml
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Peer Node Discovery
 Automatic Peer Discovery
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProvider
Factory"
properties ="peerDiscovery=automatic,
multicastGroupAddress=230.0.0.1,multicastGroupPort=4446,
timeToLive=32"/>
Automatic addition & deletion of peer nodes
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Peer Node Discovery
 Manual Discovery
 Peers cannot be added or removed at runtime
 Multicast is not supported between the nodes
 Each peer should know about all other peers
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProvid
erFactory"
properties="peerDiscovery=manual,rmiUrls=//server2:40001/sam
pleCache11|//server2:40001/sampleCache12"/>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Peer to Peer Communication
Configure hostname & port to listen for messages from peers
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListen
erFactory"
properties="hostName=localhost, port=40001,
socketTimeoutMillis=2000"/>
*Port must be unique to each peer
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Auth Cache
 Configure replication to auth cache
<cache name="authcache"
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="false"
diskSpoolBufferSizeMB="30"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="3600"
memoryStoreEvictionPolicy="LRU"
clearOnFlush="true">
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Cache Replication
 Enable replication for auth cache
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory
"
properties="replicateAsynchronously=true,
replicatePuts=true, replicateUpdates=true,
replicateUpdatesViaCopy=false, replicateRemovals=true "/>
</cache>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Peer Bootstrapping
 Enable Bootstrapping from peer for auth cache
<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFa
ctory"
properties="bootstrapAsynchronously=false,
maximumChunkSizeBytes=5000000"
propertySeparator="," />
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Monitoring
 Copy ehcache-probe-<version>.jar to lib directory of each peer
 Add the below listener to monitor the cache
<cacheManagerPeerListenerFactory
class="org.terracotta.ehcachedx.monitor.probe.ProbePeerListe
nerFactory"
properties="monitorAddress=localhost, monitorPort=9889,
memoryMeasurement=true" />
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Q & A
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

More Related Content

Viewers also liked

Viewers also liked (16)

Refranes
RefranesRefranes
Refranes
 
Prehistoria
PrehistoriaPrehistoria
Prehistoria
 
Objetos virtuales de aprendizaje
Objetos virtuales de aprendizajeObjetos virtuales de aprendizaje
Objetos virtuales de aprendizaje
 
Evaluación
EvaluaciónEvaluación
Evaluación
 
Ciclo del carbono sofía
Ciclo del carbono sofíaCiclo del carbono sofía
Ciclo del carbono sofía
 
Deber exame 1
Deber exame 1Deber exame 1
Deber exame 1
 
Uso de música e imágenes con derechos de ....ooo
Uso de música e imágenes con derechos de ....oooUso de música e imágenes con derechos de ....ooo
Uso de música e imágenes con derechos de ....ooo
 
Desasorrollo web nivel introduccion (b.b)
Desasorrollo web nivel introduccion (b.b)Desasorrollo web nivel introduccion (b.b)
Desasorrollo web nivel introduccion (b.b)
 
Jaime Orozco-Reconocimiento general de actores
Jaime Orozco-Reconocimiento general de actoresJaime Orozco-Reconocimiento general de actores
Jaime Orozco-Reconocimiento general de actores
 
9.otitis media silenciosa
9.otitis media silenciosa9.otitis media silenciosa
9.otitis media silenciosa
 
Silabo marketing paredes
Silabo marketing paredesSilabo marketing paredes
Silabo marketing paredes
 
Los derechos humanos
Los derechos humanosLos derechos humanos
Los derechos humanos
 
Presentación Final
Presentación FinalPresentación Final
Presentación Final
 
Clara navarini
Clara navariniClara navarini
Clara navarini
 
Exposicion diseño organizacional
Exposicion diseño organizacionalExposicion diseño organizacional
Exposicion diseño organizacional
 
Silla araña
Silla arañaSilla araña
Silla araña
 

Similar to Accelerate your ColdFusion Applications using Caching

Accelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using CachingAccelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using CachingColdFusionConference
 
ASP.NET 4.0 Cache Extensibility
ASP.NET 4.0 Cache ExtensibilityASP.NET 4.0 Cache Extensibility
ASP.NET 4.0 Cache Extensibilityakrakovetsky
 
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusionAdvanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusionColdFusionConference
 
Emc vi pr controller tecnical customer presentation
Emc vi pr controller tecnical customer presentationEmc vi pr controller tecnical customer presentation
Emc vi pr controller tecnical customer presentationxKinAnx
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...ColdFusionConference
 
Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...Shailendra Prasad
 
TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9
TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9
TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9Nuno Godinho
 
IBM SmartCloud Enterprise Storage Demo
IBM SmartCloud Enterprise Storage DemoIBM SmartCloud Enterprise Storage Demo
IBM SmartCloud Enterprise Storage DemoAlex Amies
 
Caching objects-in-memory
Caching objects-in-memoryCaching objects-in-memory
Caching objects-in-memoryMauro Cassani
 
Scale Your Data Tier with Windows Server AppFabric
Scale Your Data Tier with Windows Server AppFabricScale Your Data Tier with Windows Server AppFabric
Scale Your Data Tier with Windows Server AppFabricWim Van den Broeck
 
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...elliando dias
 
Securing Containers - Sathyajit Bhat - Adobe
Securing Containers - Sathyajit Bhat - AdobeSecuring Containers - Sathyajit Bhat - Adobe
Securing Containers - Sathyajit Bhat - AdobeCodeOps Technologies LLP
 
Extending Java From ColdFusion - CFUnited 2010
Extending Java From ColdFusion - CFUnited 2010Extending Java From ColdFusion - CFUnited 2010
Extending Java From ColdFusion - CFUnited 2010Rupesh Kumar
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsZend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsEnrico Zimuel
 
Custom Buildpacks and Data Services
Custom Buildpacks and Data ServicesCustom Buildpacks and Data Services
Custom Buildpacks and Data ServicesTom Kranz
 
Integrating with Adobe Marketing Cloud - Summit 2014
Integrating with Adobe Marketing Cloud - Summit 2014Integrating with Adobe Marketing Cloud - Summit 2014
Integrating with Adobe Marketing Cloud - Summit 2014Paolo Mottadelli
 

Similar to Accelerate your ColdFusion Applications using Caching (20)

Accelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using CachingAccelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using Caching
 
ColdFusion Internals
ColdFusion InternalsColdFusion Internals
ColdFusion Internals
 
2014 cf summit_clustering
2014 cf summit_clustering2014 cf summit_clustering
2014 cf summit_clustering
 
ASP.NET 4.0 Cache Extensibility
ASP.NET 4.0 Cache ExtensibilityASP.NET 4.0 Cache Extensibility
ASP.NET 4.0 Cache Extensibility
 
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusionAdvanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
 
Emc vi pr controller tecnical customer presentation
Emc vi pr controller tecnical customer presentationEmc vi pr controller tecnical customer presentation
Emc vi pr controller tecnical customer presentation
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...
 
Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...
 
TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9
TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9
TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9
 
IBM SmartCloud Enterprise Storage Demo
IBM SmartCloud Enterprise Storage DemoIBM SmartCloud Enterprise Storage Demo
IBM SmartCloud Enterprise Storage Demo
 
ColdFusion 9 ORM
ColdFusion 9 ORMColdFusion 9 ORM
ColdFusion 9 ORM
 
Caching objects-in-memory
Caching objects-in-memoryCaching objects-in-memory
Caching objects-in-memory
 
Scale Your Data Tier with Windows Server AppFabric
Scale Your Data Tier with Windows Server AppFabricScale Your Data Tier with Windows Server AppFabric
Scale Your Data Tier with Windows Server AppFabric
 
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
 
Securing Containers - Sathyajit Bhat - Adobe
Securing Containers - Sathyajit Bhat - AdobeSecuring Containers - Sathyajit Bhat - Adobe
Securing Containers - Sathyajit Bhat - Adobe
 
Extending Java From ColdFusion - CFUnited 2010
Extending Java From ColdFusion - CFUnited 2010Extending Java From ColdFusion - CFUnited 2010
Extending Java From ColdFusion - CFUnited 2010
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsZend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applications
 
Custom Buildpacks and Data Services
Custom Buildpacks and Data ServicesCustom Buildpacks and Data Services
Custom Buildpacks and Data Services
 
Integrating with Adobe Marketing Cloud - Summit 2014
Integrating with Adobe Marketing Cloud - Summit 2014Integrating with Adobe Marketing Cloud - Summit 2014
Integrating with Adobe Marketing Cloud - Summit 2014
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 

Recently uploaded

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 

Recently uploaded (20)

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

Accelerate your ColdFusion Applications using Caching

  • 1. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Accelerate your ColdFusion Applications using Caching S V PAVAN KUMAR sanniset@adobe.com October 2014
  • 2. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Agenda  Caching Overview  CF Ehcache Implementation  CF Cache layout  Application specific caching  Query Caching  ORM Caching  Template & Object Caching  Distributed Caching  <cflogin> cache replication demo
  • 3. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Cache During experiments, Many bird species store peanuts in a cache for later retrieval. In the wild, these birds store acorns and insects. -Wikipedia
  • 4. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Cache A Simple Key/Value Pair Key Value USA Washington D.C India New Delhi England London Japan Tokyo
  • 5. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. How Cache Works ? Key Value Key1 Value1 Key2 Value2 Key3 Value3 Key4 Value4 Application Cache Hit Database ComputationNetwork
  • 6. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. How Cache Works ? Miss Key Value Key1 Value1 Key2 Value2 Key3 Value3 Key4 Value4 Application Cache Database ComputationNetwork Cache - Aside
  • 7. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. How Cache Works ? Miss Key Value Key1 Value1 Key2 Value2 Key3 Value3 Key4 Value4 Application Cache Database ComputationNetwork Read - Through Sync/ Async
  • 8. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Simply Sacrifice memory for latency reduction
  • 9. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Eviction Strategies  Manually deleting  Expiration  Expire after 2 Hours  Expire at Oct 18th, 2014  When Cache memory is Full  Delete using FIFO | LRU | LFU  Spill to Disk EhCache does not remove expired elements immediately from memory. i
  • 10. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Cache Bootstrapping  How to pre-load the cache on startup  From Disk store  From a peer cache node  From a central Cache server (e.g. Terracotta Server)  Start Empty, fill later (Cold Cache)
  • 11. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Cache Efficiency Caches are not a panacea.
  • 12. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ColdFusion Caches  Query Cache  ORM Cache  Session level  2nd Level Cache  Template  Page  Fragment  Object Cache  <Cflogin> Cache
  • 13. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Overview  Industry Standard Caching Provider  Default cache provider for ColdFusion since CF 9  Various cache algorithms FIFO, LRU and LFU  Better control over cache through config  Disk persistence  Cache replication  Distributed caching support  Monitoring  Thread Safe
  • 14. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. CF Cache layout Server Level Cache ManagerApplication level Cache Manager Application level Cache Manager Application level Cache Manager QUERY TEMPLATE OBJECT QUERY TEMPLATE OBJECT QUERY TEMPLATE OBJECT
  • 15. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Application Specific Caching  Added in CF 10  If enabled, caching is done at application level  Set this.cache.configfile in Application.cfc  Absolute: this.cache.configfile = "c:/myApp/ehcache.xml"  Relative to Application.cfc: this.cache.configfile = "ehcache.xml"  Server level Ehcache configuration file ehcache.xml can be found at <Install_location><Instance name>lib
  • 16. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Default Cache Regions  TEMPLATE  OBJECT  QUERY  Default cache names will be prefixed with applicationName (when app specific caching is not enabled)  <App Name>TEMPLATE  <App Name>OBJECT  <App Name>QUERY
  • 17. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Custom Cache Regions  Using ehcache.xml in <CF Instance Name>/lib (Hard Coding)  cacheRegionNew() to create on-fly cache regions  All the caches supporting cacheRegion  All the cache functions supporting region argument  Custom cache region can contain any type of Data
  • 18. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Cache Region Properties  Cache region properties  retrieved using cacheGetProperties()  set using cacheSetProperties() <cache name=“myCache" maxElementsInMemory="1000" eternal="false" timeToIdleSeconds="720" timeToLiveSeconds="720" overflowToDisk="true" maxElementsOnDisk="100000" diskPersistent="true" memoryStoreEvictionPolicy="LRU" />
  • 19. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Cache Regions: CRUD  CacheRegionNew()  CacheRegionExists()  CacheRegionRemove( )  CacheGetProperties()  CacheSetProperties() • CacheGet() • CacheGetAllIds() • CachePut() • CacheRemove() • CacheRemoveAll()
  • 20. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Cache Metadata  CacheGetMetadata(): to get cache meta data for cache entry cache_hitcount Number of hits cache_misscount Number of misses createdtime Creation time Name Cache region Name idletime time to idle for an element before it expires lasthit last hit timestamp Lastupdated last modified timestamp size Cached Object size in bytes timespan time to live for an element before it expires.
  • 21. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Query Cache - cachedwithin <cfquery name="GetParks" datasource="cfdocexamples" cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#“ cacheRegion=“statewideParks”> SELECT PARKNAME, REGION, STATE FROM Parks ORDER BY ParkName, State </cfquery>
  • 22. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Query Cache  Backed by Ehcache by default from CF10.  Internal cache fallback  Server level setting Caching -> Use internal cache to store queries  Application level specify this.cache.useinternalquerycache=true|false  Query limit  Server level setting Caching -> Maximum number of cached queries default 100  Application level specify this.cache.querysize = 150
  • 23. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Query Cache  Datasource name, the actual SQL statement itself, and the parameters passed to the SQL statement will be used to pull out from the cache if cache id not defined  dbtype=query" and "CachedWithin" are mutually Exclusive
  • 24. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ORM Session Level Cache  Entities loaded from DB cached in ORM session  Short living exists as long as session is open  Caches persistent Objects  EntityLoad function  For the first time hits DB gets the entity.  For the second time retrieves from ORM session  Should use EntityReload to force retrieval from DB  ORMClearSession() clears session level cache
  • 25. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ORM Second level Caching  CF uses EHCache as the default secondary cache provider from CF 9  Caches  Persistent Object  Persistent Object Associations  Results of Queries  Long lived  Supports Application specific Cache  Absolute: this.ormsettings.cacheConfig = "c:/myApp/ehcache.xml"  Relative to Application.cfc: this.ormsettings.cacheConfig = "ehcache.xml"  Can Scale in clustered environment
  • 26. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ORM Cache Hierarchy Database ColdFusion Application Session Level Cache Secondary Cache (Ehcache)
  • 27. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ORM Second level Caching Example  Application.cfc <cfset this.name="Caching_Example"> <cfset this.datasource="cfartgallery"> <cfset this.ormenabled="true"> <cfset this.ormsettings.secondarycacheEnabled=true> <cfset this.ormsettings.cacheProvider= "ehcache"> <cfset this.ormsettings.cacheConfig="ehcache.xml">
  • 28. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ORM Second level Caching Example  CArtist.cfc <cfcomponent persistent="true" schema="APP" table="Artists" cachename="artist" cacheuse="read-only"> <cfproperty name="artistid" fieldtype="id"/> <cfproperty name="firstname"/> <cfproperty name="lastname"/> <cfproperty name="state"/> <cfproperty name="art" fieldtype="one-to-many" cfc="CArt" fkcolumn="ArtID" cachename="ArtistArts" cacheuse="read-only"> </cfcomponent>
  • 29. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ORM Second level Caching Example  CArt.cfc <cfcomponent persistent="true" schema="APP" table="Art"> <cfproperty name="artid" generator="identity" fieldtype="id"/> <cfproperty name="artname"/> <cfproperty name="issold"/> </cfcomponent>
  • 30. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ORM Second level Caching Example <cfscript> //This will cache the Artist Component and also the association. It wouldn't cache the Art objects. artistObj = EntityLoad("CArtists", 3, true); //This will cache the query. availableArts = ORMExecuteQuery("from CArt where issold=0", {}, false, {cacheable=true, cachename="availableArtsCache"}); </cfscript>
  • 31. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ORM Cache Access Strategies  Read Only  Nonstrict-read-write  Read-write
  • 32. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. ORM Cache: Eviction  ORMEvictEntity("<entity_name>", [primarykey])  ORMevictcollection("<entity_name>", "<association_name>", [primarykey])  ORMEvictQueries(cachename, datasource)
  • 33. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Template Cache: Pages  Both server- side and client- side caching  Cache an entire page  Single <cfcache> at top of page  No need of closing tag </cfcache>  Also, <cfcache/> Header Naviga tion Bar Content Footer <cfcache>
  • 34. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Template Cache: Fragments  Cache individual fragments of content  Useful when parts of a page must remain dynamic or personalized.  Surround with <cfcache>…</cfcache> tags  Multiple fragments can be cached in a single request  Each fragment can be configured independently  No Client side caching Header Naviga tion Bar Content Footer <cfcache> </cfcache> <cfcache> <cfcache> <cfcache> </cfcache> </cfcache> </cfcache>
  • 35. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Template Cache  Timespan  The interval until the item is flushed from the cache  idleTime  Flushes the cached item if it is not accessed for the specified time span  Metadata  Contains cache meta data info such as hit count, miss count created time etc.  expireURL  expireURL along with action = ‘flush’ used to flush pages that match the specified URL or pattern  Wild card Support <cfcache action="flush" expireurl="*.cfm?productID=#URL.productID#">
  • 36. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Template Cache Key CacheI d Given ? Get the Request URL useQuer yString ? No Append Query String from URL Compute a hash from page physical path and Append YesNo Has End Tag? Append Line No Yes depend s on ? No Append dependent variables Yes Template Cache Key No Yes http://localhost/example/index.cfm_query_themeid=1_pageid:17CF7BD640264F4CB3D507A4 72E0190Bsession.username=JZNKA
  • 37. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Object Cache  Application code can take advantage of caching  Can cache anything (Simple values, Complex Objects like files, images etc.)  Cache functions for CRUD operations and to get cache properties (cfcache)  Cache keys need to be managed manually. (id is mandatory)
  • 38. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Distributed Caching
  • 39. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Standalone  Pros:  In Process & faster access  No serialization of keys and values  Eventual Consistency local to Application ColdFusio n Cache JVM  Cons  Not Scalable  Limited by CF JVM memory  GC pauses  On 32 Bit huge caches will suffer  Bootstrapping only from Disk Store.  Inconsistency on a cluster
  • 40. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Replicated ColdFusio n Cach eJVM Cach eJVM Cach eJVM Cach eJVM Put, Remove, Remove All, Bootstrapping (Sync or Async) RMI, Jgroup Protocols ColdFusio n ColdFusio n ColdFusio n • Pros: • In Process • Data Consistency in Cluster • Bootstrapping from a peer node • Cons: • GC Pauses • Serialization overhead • Limited by CF JVM Memory
  • 41. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Centralized ColdFusion Cache (L1) JVM ColdFusion Cache (L1) JVM Big Memory (L2 Cache) JVM
  • 42. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Demo
  • 43. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. <cflogin> Auth cache  Prior to CF9 requires sticky sessions for clustered environment if loginStorage=cookie  CF10 onwards auth info is stored in ehcache  To enable long lived logins or remember me type of functionality  To provide fail-over and replication support in cluster  Configuration for cflogin cache can be found at <cf-home>/lib/auth- ehcache.xml
  • 44. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Peer Node Discovery  Automatic Peer Discovery <cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProvider Factory" properties ="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,multicastGroupPort=4446, timeToLive=32"/> Automatic addition & deletion of peer nodes
  • 45. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Peer Node Discovery  Manual Discovery  Peers cannot be added or removed at runtime  Multicast is not supported between the nodes  Each peer should know about all other peers <cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProvid erFactory" properties="peerDiscovery=manual,rmiUrls=//server2:40001/sam pleCache11|//server2:40001/sampleCache12"/>
  • 46. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Peer to Peer Communication Configure hostname & port to listen for messages from peers <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListen erFactory" properties="hostName=localhost, port=40001, socketTimeoutMillis=2000"/> *Port must be unique to each peer
  • 47. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Auth Cache  Configure replication to auth cache <cache name="authcache" maxElementsInMemory="10000" eternal="false" overflowToDisk="false" diskSpoolBufferSizeMB="30" maxElementsOnDisk="10000000" diskPersistent="false" diskExpiryThreadIntervalSeconds="3600" memoryStoreEvictionPolicy="LRU" clearOnFlush="true">
  • 48. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Cache Replication  Enable replication for auth cache <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory " properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=false, replicateRemovals=true "/> </cache>
  • 49. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Peer Bootstrapping  Enable Bootstrapping from peer for auth cache <bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFa ctory" properties="bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000" propertySeparator="," />
  • 50. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Monitoring  Copy ehcache-probe-<version>.jar to lib directory of each peer  Add the below listener to monitor the cache <cacheManagerPeerListenerFactory class="org.terracotta.ehcachedx.monitor.probe.ProbePeerListe nerFactory" properties="monitorAddress=localhost, monitorPort=9889, memoryMeasurement=true" />
  • 51. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Q & A
  • 52. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.