SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
Ehcache Architecture, Features and
Usage Patterns
Greg Luck
Maintainer, ehcache - http://ehcache.sf.net
Member, JSR 107 JCACHE Expert Group
Chief Architect, Wotif.com - http://wotif.com


                             2009 Updated from JavaOne Session 2007 |
Agenda
Introduction
The Theory of Caching
Ehcache Architecture
General Purpose Caching
Web Caching
Java Persistence API (JPA)/Hibernate Caching
Distributed Caching for Clusters
Cache Server
Step-by-Step Coding Demo
                    2009 Updated from JavaOne Session 2007 |   2
Introduction
About Ehcache
    Since 2003
●


    The most widely used Java platform Cache
●


    Apache 2.0 License
●


    Integrated by lots of projects, products
●


    Hibernate Provider implemented 2003
●


    Web Caching 2004
●


    Distributed Caching 2006
●


    JCACHE implementation 2007
●


    Cache Server 2008
●



                        2009 Updated from JavaOne Session 2007 |   3
The Theory of Caching
How much faster will caching make an application?
It depends on a multitude of factors being:
● how many times a cached piece of data can and

   is reused by the application
● the proportion of the response time that is

   alleviated by caching
● In applications that are I/O bound, which is most

   business applications, most of the response time
   is getting data from a database. Therefore the
   speed up mostly depends on how much reuse a
   piece of data gets.

                         2009 Updated from JavaOne Session 2007 |   4
The Theory of Caching
Cache Efficiency
Factors which affect the efficiency of a cache are:
● Required Liveness of Data


● Proportion of total data cached


● Read/Write ratio


● Caching in a single VM versus Caching Clusters




                       2009 Updated from JavaOne Session 2007 |   5
The Theory of Caching
How to calculate entire system speedup: Amdahl's Law
Amdahl's law, after Gene Amdahl, is used to find the
 system speed up from a speed up in part of the
 system.
1/ ((1 - Proportion Sped Up) + Proportion Sped Up / Speed up)



Things to Watch:
   ● For a web application the “system” should

     include browser render time and network
     latency.

                           2009 Updated from JavaOne Session 2007 |   6
The Theory of Caching
Speed up from a Web Page Cache
Uncached page time: 2 seconds
Cache retrieval time: 2ms
Proportion: 100%
The expected server side system speedup is thus:
     1 / ((1 - 1) + 1 / 1000)
     = 1 / (0 + .001)
     = 1000 times system speedup
The to the browser “system” speed up is much less

                       2009 Updated from JavaOne Session 2007 |   7
The Theory of Caching
Speed up from a Database Level Cache
Uncached page time: 2 seconds
Database time: 1.5 seconds
Cache retrieval time: 2ms
Proportion: 75% (1.5/2)
The expected system speedup is thus:
    1 / ((1 - .75) + .75 / (1500/2)))
    = 1 / (.25 + .75/750)
    = 3.98 times system speedup

                        2009 Updated from JavaOne Session 2007 |   8
Architecture




               2009 Updated from JavaOne Session 2007 |   9
General Purpose Caching
Step by Step
1. Add ehcache Java Archive (JAR) to your
   classpath
2. Place configuration in ehcache.xml and add it to
   your classpath
3. Create a CacheManager
  CacheManager manager = CacheManager.create();

4. Reference a Cache
  Ehcache sampleCache = manager.getCache();

5. Use it
  sampleCache.put(new Element(“key”, “value”));
  sampleCache.get(“key”);


                                2009 Updated from JavaOne Session 2007 |   10
Usage - General Purpose Caching
ehcache.xml Configuration
<ehcache>

   <diskStore path=quot;java.io.tmpdirquot;/>

   ...

   <cache name=quot;sampleCache1quot;
           maxElementsInMemory=quot;10000quot;
           maxElementsOnDisk=quot;1000quot;
           eternal=quot;falsequot;
           overflowToDisk=quot;truequot;
           timeToIdleSeconds=quot;300quot;
           timeToLiveSeconds=quot;600quot;
           memoryStoreEvictionPolicy=quot;LFUquot;
            />
</ehcache>
                         2009 Updated from JavaOne Session 2007 |   11
Web Caching
Step by Step
1. Use or Subclass SimpleCachingFilter or
   SimplePageFragmentCachingFilter
2. Configure filter in web.xml
3. Create a mapping in web.xml
4. Configure a cache entry matching the filter name




                      2009 Updated from JavaOne Session 2007 |   12
Web Caching
Example Scenario



  /index.jsp




 /include/footer.jsp




                       2009 Updated from JavaOne Session 2007 |   13
Filter Configuration in web.xml
Full Page Cache
<filter>
   <filter-name>SimplePageCachingFilter</filter-name>
   <filter-class>net.sf.ehcache.constructs.web.filter.
               SimplePageCachingFilter
   </filter-class>
</filter>

<filter-mapping>
     <filter-name>SimplePageCachingFilter</filter-name>
     <url-pattern>/index.jsp</url-pattern>
     <dispatcher>REQUEST</dispatcher>
     <dispatcher>INCLUDE</dispatcher>
     <dispatcher>FORWARD</dispatcher>
 </filter-mapping>

                          2009 Updated from JavaOne Session 2007 |   14
Add Cache to Ehcache Configuration
Full Page Cache
<ehcache>

   <diskStore path=quot;java.io.tmpdirquot;/>

   ...

   <cache name=quot;SimplePageCachingFilterquot;
           maxElementsInMemory=quot;10000quot;
           maxElementsOnDisk=quot;1000quot;
           eternal=quot;falsequot;
           overflowToDisk=quot;truequot;
           timeToIdleSeconds=quot;300quot;
           timeToLiveSeconds=quot;600quot;
           memoryStoreEvictionPolicy=quot;LFUquot;
            />
</ehcache>
                         2009 Updated from JavaOne Session 2007 |   15
Filter Configuration in web.xml
Page Fragment Cache
<filter>
   <filter-name>SimplePageFragmentCache</filter-name>
   <filter-class>net.sf.ehcache.constructs.web.filter.
                    SimplePageFragmentCachingFilter
   </filter-class>
</filter>

<!-- Page Fragment Cache -->
<filter-mapping>
     <filter-name>SimplePageFragmentCachingFilter
</filter-name>
     <url-pattern>/include/Footer.jsp</url-pattern>
</filter-mapping>



                          2009 Updated from JavaOne Session 2007 |   16
JPA/Hibernate Caching
Overview
    Hibernate can either be used directly either or
●

    via the Hibernate Java Persistence API Provider
    in Hibernate 3.2
    Ehcache is a CacheProvider for Hibernate 2.x
●

    and 3.x
Example

        Simple Country persistent
    ●

        object/Entity


                         2009 Updated from JavaOne Session 2007 |   17
JPA/Hibernate Caching
Step by Step
1. Configure Hibernate to use ehcache
2. Configure the Country object's cacheability. This
   can be done in a number of ways.
3. Decide whether to use defaults, or to configure
   specific cache settings for the Country object
   cache in ehcache.xml




                       2009 Updated from JavaOne Session 2007 |   18
JPA/Hibernate Caching
Configure Hibernate to use ehcache


Add the following to hibernate.properties
hibernate.cache.provider_class=net.sf.ehcache.hibernate.EhCacheProvider

<!-- optional configuration file parameter -->
net.sf.ehcache.configurationResourceName=/name_of_configuration_resource




                                2009 Updated from JavaOne Session 2007 |   19
JPA/Hibernate Caching
Native Hibernate Mapping File Configuration
<hibernate-mapping>

<class
    name=quot;com.somecompany.someproject.domain.Countryquot;
    table=quot;ut_Countriesquot;
    dynamic-update=quot;falsequot;
    dynamic-insert=quot;falsequot;
>
    <cache usage=quot;read-write|nonstrict-read-write|read-onlyquot; />
</class>
...
</hibernate-mapping>

<cache
    usage=quot;transactional|read-write|nonstrict-read-write|read-onlyquot;
    region=quot;RegionNamequot;
    include=quot;all|non-lazyquot;
/>

                                2009 Updated from JavaOne Session 2007 |   20
JPA/Hibernate Caching
Entity Configuration with JPA and Hibernate Annotations

@Entity
...
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public Class Country {

    private String name;

    ...

}




                                2009 Updated from JavaOne Session 2007 |   21
Distributed Caching for Clusters
Features
1. Pluggable distribution mechanism.
2. RMI, JGroups and JMS replication modules.
   Terracotta also has an ehcache provider.
3. Multiple “clusters”
4. Replication set per Cache. Options:
   1. Replicate adds
   2. Replicate removes
   3. Replicate update by copy or invalidate
   4. Async or Sync
5. Bootstrapping from existing Caches in a cluster
                          2009 Updated from JavaOne Session 2007 |   22
Distributed Caching for Clusters
Architecture




                 2009 Updated from JavaOne Session 2007 |   23
Distributed Caching for Clusters
RMI Based Replication
1. Multicast Peer Discovery
  <cacheManagerPeerProviderFactory class=
  quot;net.sf.ehcache.distribution.
  RMICacheManagerPeerProviderFactoryquot;
  properties=quot;peerDiscovery=automatic,
     multicastGroupAddress=230.0.0.1,
  multicastGroupPort=4446/>



2. RMI Listener
   <cacheManagerPeerListenerFactory class=
   quot;net.sf.ehcache.distribution.RMICacheManagerPeerLis
   tenerFactoryquot;properties=quot;port=40001quot;/>



                        2009 Updated from JavaOne Session 2007 |   24
Distributed Caching for Clusters
    Set Replication Per Cache
<cache ...>
   <cacheEventListenerFactory
  class=quot;net.sf.ehcache.distribution.RMICacheReplicatorFactoryquot;
      properties=quot;replicateAsynchronously=true,
      replicatePuts=true,
      replicateUpdates=true,
      replicateUpdatesViaCopy=true,
      replicateRemovals=true,
      asynchronousReplicationIntervalMillis=1000quot;/>
      ...
</cache>




                                2009 Updated from JavaOne Session 2007 |   25
Distributed Caching for Clusters
    Set Bootstrapping Per Cache
<cache ...>
       <bootstrapCacheLoaderFactory class=quot;
  net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactoryquot;
   properties=quot;bootstrapAsynchronously=true,
               maximumChunkSizeBytes=5000000quot;/>
</cache>




                               2009 Updated from JavaOne Session 2007 |   26
Cache Server
REST and SOAP APIs
Supports HTTP/1.1 request pipelining
Deployed to a WAR or self-contained with Glassfish
Embedded
Benefits over memcached:
•clients in any language
•may utilise HTTP load balancers
•servers are clustered using ehcache replication



                           2009 Updated from JavaOne Session 2007 |   27
Cache Server
Architecture




               2009 Updated from JavaOne Session 2007 |   28
Cache Server
 Ehcache in-process compared with Memcached
 (Ehcache server would be similar to memcached)
7000

6000

5000
                                                                             ehcache-1.2.4
                                                                             memory
4000
                                                                             ehcache-1.2.4 disk
                                                                             memcached-1.2.1
3000

2000

1000

   0
        put/set        get                         remove/delete
                             2009 Updated from JavaOne Session 2007 |   29
Cache Server
Client coding examples
Scala
import java.net.URL
   import scala.io.Source.fromInputStream

   object ExampleScalaGet extends Application {
     val url = new URL(quot;http://localhost:8080/ehcache/rest/sampleCache2/2quot;)
     fromInputStream(url.openStream).getLines.foreach(print)
   }



PHP
<?php
   $ch = curl_init();
   curl_setopt ($ch, CURLOPT_URL, quot;http://localhost:8080/ehcache/rest/sampleCache2/3quot;);
   curl_setopt ($ch, CURLOPT_HEADER, 0);
   curl_exec ($ch);
   curl_close ($ch);
   ?>




                                        2009 Updated from JavaOne Session 2007 |   30
Summary
    Most apps will benefit from caching
●


    You can calculate the speed up
●


    Ehcache is a modern, modular family of caching
●

    tools
    You can also benefit from ehcache indirectly
●

    through frameworks that use it
    Distributed ehcache is a small configuration step
●


    Cache Server is the new kid on the block
●




                        2009 Updated from JavaOne Session 2007 |   31
For More Information
    Project Website:
●

    http://ehcache.sf.net
    Downloadable Book:
●


    http://www.lulu.com/content/paperback-
●

    book/ehcache-150-guide-reference/3553390
    My Email:
●

    gluck@gregluck.com




                            2009 Updated from JavaOne Session 2007 |   32
Q&A
Greg Luck
gluck@gregluck.com




                                                                33
                     2009 Updated from JavaOne Session 2007 |

Más contenido relacionado

La actualidad más candente

Hudi: Large-Scale, Near Real-Time Pipelines at Uber with Nishith Agarwal and ...
Hudi: Large-Scale, Near Real-Time Pipelines at Uber with Nishith Agarwal and ...Hudi: Large-Scale, Near Real-Time Pipelines at Uber with Nishith Agarwal and ...
Hudi: Large-Scale, Near Real-Time Pipelines at Uber with Nishith Agarwal and ...Databricks
 
Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...
Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...
Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...Ankit Kumar
 
Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3
Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3
Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3Databricks
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express jsAhmed Assaf
 
Hexagonal architecture with Spring Boot [EPAM Java online conference]
Hexagonal architecture with Spring Boot [EPAM Java online conference]Hexagonal architecture with Spring Boot [EPAM Java online conference]
Hexagonal architecture with Spring Boot [EPAM Java online conference]Mikalai Alimenkou
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8Simon Ritter
 
InfluxDB IOx Tech Talks: Query Processing in InfluxDB IOx
InfluxDB IOx Tech Talks: Query Processing in InfluxDB IOxInfluxDB IOx Tech Talks: Query Processing in InfluxDB IOx
InfluxDB IOx Tech Talks: Query Processing in InfluxDB IOxInfluxData
 
Spring Boot—Production Boost
Spring Boot—Production BoostSpring Boot—Production Boost
Spring Boot—Production BoostVMware Tanzu
 
Kv cbsc class 3 hindi paractice set question answares सीबीएसई कक्षा तीसरी हि...
Kv  cbsc class 3 hindi paractice set question answares सीबीएसई कक्षा तीसरी हि...Kv  cbsc class 3 hindi paractice set question answares सीबीएसई कक्षा तीसरी हि...
Kv cbsc class 3 hindi paractice set question answares सीबीएसई कक्षा तीसरी हि...ABHIJEET KHIRE
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js ExpressEyal Vardi
 
Webinar: Front End Web Development - Trendy Web Designs Using HTML5
Webinar: Front End Web Development - Trendy Web Designs Using HTML5Webinar: Front End Web Development - Trendy Web Designs Using HTML5
Webinar: Front End Web Development - Trendy Web Designs Using HTML5Edureka!
 
Splunk as a_big_data_platform_for_developers_spring_one2gx
Splunk as a_big_data_platform_for_developers_spring_one2gxSplunk as a_big_data_platform_for_developers_spring_one2gx
Splunk as a_big_data_platform_for_developers_spring_one2gxDamien Dallimore
 
Changelog Stream Processing with Apache Flink
Changelog Stream Processing with Apache FlinkChangelog Stream Processing with Apache Flink
Changelog Stream Processing with Apache FlinkFlink Forward
 

La actualidad más candente (20)

Hudi: Large-Scale, Near Real-Time Pipelines at Uber with Nishith Agarwal and ...
Hudi: Large-Scale, Near Real-Time Pipelines at Uber with Nishith Agarwal and ...Hudi: Large-Scale, Near Real-Time Pipelines at Uber with Nishith Agarwal and ...
Hudi: Large-Scale, Near Real-Time Pipelines at Uber with Nishith Agarwal and ...
 
Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...
Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...
Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...
 
Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3
Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3
Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
NodeJS
NodeJSNodeJS
NodeJS
 
Hexagonal architecture with Spring Boot [EPAM Java online conference]
Hexagonal architecture with Spring Boot [EPAM Java online conference]Hexagonal architecture with Spring Boot [EPAM Java online conference]
Hexagonal architecture with Spring Boot [EPAM Java online conference]
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 
Express JS
Express JSExpress JS
Express JS
 
InfluxDB IOx Tech Talks: Query Processing in InfluxDB IOx
InfluxDB IOx Tech Talks: Query Processing in InfluxDB IOxInfluxDB IOx Tech Talks: Query Processing in InfluxDB IOx
InfluxDB IOx Tech Talks: Query Processing in InfluxDB IOx
 
Spring Boot—Production Boost
Spring Boot—Production BoostSpring Boot—Production Boost
Spring Boot—Production Boost
 
Avro
AvroAvro
Avro
 
Kv cbsc class 3 hindi paractice set question answares सीबीएसई कक्षा तीसरी हि...
Kv  cbsc class 3 hindi paractice set question answares सीबीएसई कक्षा तीसरी हि...Kv  cbsc class 3 hindi paractice set question answares सीबीएसई कक्षा तीसरी हि...
Kv cbsc class 3 hindi paractice set question answares सीबीएसई कक्षा तीसरी हि...
 
Express JS
Express JSExpress JS
Express JS
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
Angular Observables & RxJS Introduction
Angular Observables & RxJS IntroductionAngular Observables & RxJS Introduction
Angular Observables & RxJS Introduction
 
Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
 
Webinar: Front End Web Development - Trendy Web Designs Using HTML5
Webinar: Front End Web Development - Trendy Web Designs Using HTML5Webinar: Front End Web Development - Trendy Web Designs Using HTML5
Webinar: Front End Web Development - Trendy Web Designs Using HTML5
 
Splunk as a_big_data_platform_for_developers_spring_one2gx
Splunk as a_big_data_platform_for_developers_spring_one2gxSplunk as a_big_data_platform_for_developers_spring_one2gx
Splunk as a_big_data_platform_for_developers_spring_one2gx
 
Changelog Stream Processing with Apache Flink
Changelog Stream Processing with Apache FlinkChangelog Stream Processing with Apache Flink
Changelog Stream Processing with Apache Flink
 
Wind power
Wind powerWind power
Wind power
 

Destacado

Overview of the ehcache
Overview of the ehcacheOverview of the ehcache
Overview of the ehcacheHyeonSeok Choi
 
The new ehcache 2.0 and hibernate spi
The new ehcache 2.0 and hibernate spiThe new ehcache 2.0 and hibernate spi
The new ehcache 2.0 and hibernate spiCyril Lakech
 
Ehcache3 — JSR-107 on steroids
Ehcache3 — JSR-107 on steroidsEhcache3 — JSR-107 on steroids
Ehcache3 — JSR-107 on steroidsAlex Snaps
 
Memcache and Drupal - Vaibhav Jain
Memcache and Drupal - Vaibhav JainMemcache and Drupal - Vaibhav Jain
Memcache and Drupal - Vaibhav JainDrupal Camp Delhi
 
Building High Scalability Apps With Terracotta
Building High Scalability Apps With TerracottaBuilding High Scalability Apps With Terracotta
Building High Scalability Apps With TerracottaDavid Reines
 
Clustering Java applications with Terracotta and Hazelcast
Clustering Java applications with Terracotta and HazelcastClustering Java applications with Terracotta and Hazelcast
Clustering Java applications with Terracotta and Hazelcastb0ris_1
 
Architectural Terracotta History, Composition, Failure, Anchoring, Repair and...
Architectural Terracotta History, Composition, Failure, Anchoring, Repair and...Architectural Terracotta History, Composition, Failure, Anchoring, Repair and...
Architectural Terracotta History, Composition, Failure, Anchoring, Repair and...Patrick J. Morrissey
 
Apache Geode で始める Spring Data Gemfire
Apache Geode で始めるSpring Data GemfireApache Geode で始めるSpring Data Gemfire
Apache Geode で始める Spring Data GemfireAkihiro Kitada
 
Terracotta And Hibernate
Terracotta And  HibernateTerracotta And  Hibernate
Terracotta And HibernateTaylor Gautier
 
SAP Logistics - CS - Standard Process & Configuration document
SAP Logistics - CS - Standard Process & Configuration documentSAP Logistics - CS - Standard Process & Configuration document
SAP Logistics - CS - Standard Process & Configuration documentSubhrajyoti (Subhra) Bhattacharjee
 
Basics of SAP for noobs (dummies)
Basics of SAP for noobs (dummies)Basics of SAP for noobs (dummies)
Basics of SAP for noobs (dummies)vins049
 

Destacado (19)

Overview of the ehcache
Overview of the ehcacheOverview of the ehcache
Overview of the ehcache
 
Eh cache in Kaunas JUG
Eh cache in Kaunas JUGEh cache in Kaunas JUG
Eh cache in Kaunas JUG
 
The new ehcache 2.0 and hibernate spi
The new ehcache 2.0 and hibernate spiThe new ehcache 2.0 and hibernate spi
The new ehcache 2.0 and hibernate spi
 
Ehcache3 — JSR-107 on steroids
Ehcache3 — JSR-107 on steroidsEhcache3 — JSR-107 on steroids
Ehcache3 — JSR-107 on steroids
 
Introduction to JQuery
Introduction to JQueryIntroduction to JQuery
Introduction to JQuery
 
Memcache
MemcacheMemcache
Memcache
 
Real Terracotta
Real TerracottaReal Terracotta
Real Terracotta
 
Memcache and Drupal - Vaibhav Jain
Memcache and Drupal - Vaibhav JainMemcache and Drupal - Vaibhav Jain
Memcache and Drupal - Vaibhav Jain
 
Memcache
MemcacheMemcache
Memcache
 
Refreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notificationRefreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notification
 
Building High Scalability Apps With Terracotta
Building High Scalability Apps With TerracottaBuilding High Scalability Apps With Terracotta
Building High Scalability Apps With Terracotta
 
Clustering Java applications with Terracotta and Hazelcast
Clustering Java applications with Terracotta and HazelcastClustering Java applications with Terracotta and Hazelcast
Clustering Java applications with Terracotta and Hazelcast
 
Architectural Terracotta History, Composition, Failure, Anchoring, Repair and...
Architectural Terracotta History, Composition, Failure, Anchoring, Repair and...Architectural Terracotta History, Composition, Failure, Anchoring, Repair and...
Architectural Terracotta History, Composition, Failure, Anchoring, Repair and...
 
Apache Geode で始める Spring Data Gemfire
Apache Geode で始めるSpring Data GemfireApache Geode で始めるSpring Data Gemfire
Apache Geode で始める Spring Data Gemfire
 
Terracotta And Hibernate
Terracotta And  HibernateTerracotta And  Hibernate
Terracotta And Hibernate
 
SAP Logistics - CS - Standard Process & Configuration document
SAP Logistics - CS - Standard Process & Configuration documentSAP Logistics - CS - Standard Process & Configuration document
SAP Logistics - CS - Standard Process & Configuration document
 
SAP for Beginners
SAP for BeginnersSAP for Beginners
SAP for Beginners
 
Basics of SAP for noobs (dummies)
Basics of SAP for noobs (dummies)Basics of SAP for noobs (dummies)
Basics of SAP for noobs (dummies)
 
Sap plant maintenance
Sap plant maintenanceSap plant maintenance
Sap plant maintenance
 

Similar a Ehcache Architecture, Features And Usage Patterns

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
 
sakdjfhaksjfhaskjh
sakdjfhaksjfhaskjhsakdjfhaksjfhaskjh
sakdjfhaksjfhaskjhelodiaevie
 
askldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdf
askldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdfaskldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdf
askldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdfelodiaevie
 
salkdjfhdjkghdfkjh
salkdjfhdjkghdfkjhsalkdjfhdjkghdfkjh
salkdjfhdjkghdfkjhelodiaevie
 
aksdfhaskdjfhasdjkh
aksdfhaskdjfhasdjkhaksdfhaskdjfhasdjkh
aksdfhaskdjfhasdjkhelodiaevie
 
Introduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationIntroduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationTomcat Expert
 
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
 
Faq websphere performance
Faq websphere performanceFaq websphere performance
Faq websphere performancebudakia
 
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
 
Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applicationselliando dias
 
ASP.NET 4.0 Cache Extensibility
ASP.NET 4.0 Cache ExtensibilityASP.NET 4.0 Cache Extensibility
ASP.NET 4.0 Cache Extensibilityakrakovetsky
 
MySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMark Leith
 

Similar a Ehcache Architecture, Features And Usage Patterns (20)

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 ...
 
awergaezrg
awergaezrgawergaezrg
awergaezrg
 
sakdjfhaksjfhaskjh
sakdjfhaksjfhaskjhsakdjfhaksjfhaskjh
sakdjfhaksjfhaskjh
 
askldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdf
askldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdfaskldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdf
askldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdf
 
sergaerwga
sergaerwgasergaerwga
sergaerwga
 
salkdjfhdjkghdfkjh
salkdjfhdjkghdfkjhsalkdjfhdjkghdfkjh
salkdjfhdjkghdfkjh
 
aergserga
aergsergaaergserga
aergserga
 
aksdfhaskdjfhasdjkh
aksdfhaskdjfhasdjkhaksdfhaskdjfhasdjkh
aksdfhaskdjfhasdjkh
 
Cache is King
Cache is KingCache is King
Cache is King
 
Introduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationIntroduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 Presentation
 
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
 
Faq websphere performance
Faq websphere performanceFaq websphere performance
Faq websphere performance
 
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...
 
Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applications
 
Hackingtomcat
HackingtomcatHackingtomcat
Hackingtomcat
 
Hacking Tomcat
Hacking TomcatHacking Tomcat
Hacking Tomcat
 
ASP.NET 4.0 Cache Extensibility
ASP.NET 4.0 Cache ExtensibilityASP.NET 4.0 Cache Extensibility
ASP.NET 4.0 Cache Extensibility
 
Manual 5
Manual 5Manual 5
Manual 5
 
MySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema Improvements
 

Más de Eduardo Pelegri-Llopart

Pelegri Desarrollando en una nueva era de software
Pelegri   Desarrollando en una nueva era de software Pelegri   Desarrollando en una nueva era de software
Pelegri Desarrollando en una nueva era de software Eduardo Pelegri-Llopart
 
Market trends in IT - exchange cala - October 2015
Market trends in IT - exchange cala - October 2015Market trends in IT - exchange cala - October 2015
Market trends in IT - exchange cala - October 2015Eduardo Pelegri-Llopart
 
The impact of IOT - exchange cala - 2015
The impact of IOT - exchange cala - 2015The impact of IOT - exchange cala - 2015
The impact of IOT - exchange cala - 2015Eduardo Pelegri-Llopart
 
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...Eduardo Pelegri-Llopart
 
What is the Internet of Things and How it Impacts You
What is the Internet of Things and How it Impacts YouWhat is the Internet of Things and How it Impacts You
What is the Internet of Things and How it Impacts YouEduardo Pelegri-Llopart
 

Más de Eduardo Pelegri-Llopart (20)

Juggling at freenome
Juggling   at freenomeJuggling   at freenome
Juggling at freenome
 
Csumb capstone-fall2016
Csumb capstone-fall2016Csumb capstone-fall2016
Csumb capstone-fall2016
 
Digital activitymanagement
Digital activitymanagementDigital activitymanagement
Digital activitymanagement
 
Progress next iot_pelegri
Progress next iot_pelegriProgress next iot_pelegri
Progress next iot_pelegri
 
Pelegri Desarrollando en una nueva era de software
Pelegri   Desarrollando en una nueva era de software Pelegri   Desarrollando en una nueva era de software
Pelegri Desarrollando en una nueva era de software
 
Market trends in IT - exchange cala - October 2015
Market trends in IT - exchange cala - October 2015Market trends in IT - exchange cala - October 2015
Market trends in IT - exchange cala - October 2015
 
The impact of IOT - exchange cala - 2015
The impact of IOT - exchange cala - 2015The impact of IOT - exchange cala - 2015
The impact of IOT - exchange cala - 2015
 
IOT - Presentation to PEP @ Progress
IOT - Presentation to PEP @ ProgressIOT - Presentation to PEP @ Progress
IOT - Presentation to PEP @ Progress
 
Node.js as an IOT Bridge
Node.js as an IOT BridgeNode.js as an IOT Bridge
Node.js as an IOT Bridge
 
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
 
What is the Internet of Things and How it Impacts You
What is the Internet of Things and How it Impacts YouWhat is the Internet of Things and How it Impacts You
What is the Internet of Things and How it Impacts You
 
Community Update 25 Mar2010 - English
Community Update 25 Mar2010 - EnglishCommunity Update 25 Mar2010 - English
Community Update 25 Mar2010 - English
 
GlassFish Community Update 25 Mar2010
GlassFish Community Update 25 Mar2010GlassFish Community Update 25 Mar2010
GlassFish Community Update 25 Mar2010
 
Glass Fish Portfolio C1 West V3.Mini
Glass Fish Portfolio C1 West V3.MiniGlass Fish Portfolio C1 West V3.Mini
Glass Fish Portfolio C1 West V3.Mini
 
Virtual Box Aquarium May09
Virtual Box Aquarium May09Virtual Box Aquarium May09
Virtual Box Aquarium May09
 
Introduction To Web Beans
Introduction To Web BeansIntroduction To Web Beans
Introduction To Web Beans
 
OpenDS Primer Aquarium
OpenDS Primer AquariumOpenDS Primer Aquarium
OpenDS Primer Aquarium
 
Fuji Overview
Fuji OverviewFuji Overview
Fuji Overview
 
Nuxeo 5.2 Glassfish
Nuxeo 5.2 GlassfishNuxeo 5.2 Glassfish
Nuxeo 5.2 Glassfish
 
OpenSSO Deployments
OpenSSO DeploymentsOpenSSO Deployments
OpenSSO Deployments
 

Último

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Último (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

Ehcache Architecture, Features And Usage Patterns

  • 1. Ehcache Architecture, Features and Usage Patterns Greg Luck Maintainer, ehcache - http://ehcache.sf.net Member, JSR 107 JCACHE Expert Group Chief Architect, Wotif.com - http://wotif.com 2009 Updated from JavaOne Session 2007 |
  • 2. Agenda Introduction The Theory of Caching Ehcache Architecture General Purpose Caching Web Caching Java Persistence API (JPA)/Hibernate Caching Distributed Caching for Clusters Cache Server Step-by-Step Coding Demo 2009 Updated from JavaOne Session 2007 | 2
  • 3. Introduction About Ehcache Since 2003 ● The most widely used Java platform Cache ● Apache 2.0 License ● Integrated by lots of projects, products ● Hibernate Provider implemented 2003 ● Web Caching 2004 ● Distributed Caching 2006 ● JCACHE implementation 2007 ● Cache Server 2008 ● 2009 Updated from JavaOne Session 2007 | 3
  • 4. The Theory of Caching How much faster will caching make an application? It depends on a multitude of factors being: ● how many times a cached piece of data can and is reused by the application ● the proportion of the response time that is alleviated by caching ● In applications that are I/O bound, which is most business applications, most of the response time is getting data from a database. Therefore the speed up mostly depends on how much reuse a piece of data gets. 2009 Updated from JavaOne Session 2007 | 4
  • 5. The Theory of Caching Cache Efficiency Factors which affect the efficiency of a cache are: ● Required Liveness of Data ● Proportion of total data cached ● Read/Write ratio ● Caching in a single VM versus Caching Clusters 2009 Updated from JavaOne Session 2007 | 5
  • 6. The Theory of Caching How to calculate entire system speedup: Amdahl's Law Amdahl's law, after Gene Amdahl, is used to find the system speed up from a speed up in part of the system. 1/ ((1 - Proportion Sped Up) + Proportion Sped Up / Speed up) Things to Watch: ● For a web application the “system” should include browser render time and network latency. 2009 Updated from JavaOne Session 2007 | 6
  • 7. The Theory of Caching Speed up from a Web Page Cache Uncached page time: 2 seconds Cache retrieval time: 2ms Proportion: 100% The expected server side system speedup is thus: 1 / ((1 - 1) + 1 / 1000) = 1 / (0 + .001) = 1000 times system speedup The to the browser “system” speed up is much less 2009 Updated from JavaOne Session 2007 | 7
  • 8. The Theory of Caching Speed up from a Database Level Cache Uncached page time: 2 seconds Database time: 1.5 seconds Cache retrieval time: 2ms Proportion: 75% (1.5/2) The expected system speedup is thus: 1 / ((1 - .75) + .75 / (1500/2))) = 1 / (.25 + .75/750) = 3.98 times system speedup 2009 Updated from JavaOne Session 2007 | 8
  • 9. Architecture 2009 Updated from JavaOne Session 2007 | 9
  • 10. General Purpose Caching Step by Step 1. Add ehcache Java Archive (JAR) to your classpath 2. Place configuration in ehcache.xml and add it to your classpath 3. Create a CacheManager CacheManager manager = CacheManager.create(); 4. Reference a Cache Ehcache sampleCache = manager.getCache(); 5. Use it sampleCache.put(new Element(“key”, “value”)); sampleCache.get(“key”); 2009 Updated from JavaOne Session 2007 | 10
  • 11. Usage - General Purpose Caching ehcache.xml Configuration <ehcache> <diskStore path=quot;java.io.tmpdirquot;/> ... <cache name=quot;sampleCache1quot; maxElementsInMemory=quot;10000quot; maxElementsOnDisk=quot;1000quot; eternal=quot;falsequot; overflowToDisk=quot;truequot; timeToIdleSeconds=quot;300quot; timeToLiveSeconds=quot;600quot; memoryStoreEvictionPolicy=quot;LFUquot; /> </ehcache> 2009 Updated from JavaOne Session 2007 | 11
  • 12. Web Caching Step by Step 1. Use or Subclass SimpleCachingFilter or SimplePageFragmentCachingFilter 2. Configure filter in web.xml 3. Create a mapping in web.xml 4. Configure a cache entry matching the filter name 2009 Updated from JavaOne Session 2007 | 12
  • 13. Web Caching Example Scenario /index.jsp /include/footer.jsp 2009 Updated from JavaOne Session 2007 | 13
  • 14. Filter Configuration in web.xml Full Page Cache <filter> <filter-name>SimplePageCachingFilter</filter-name> <filter-class>net.sf.ehcache.constructs.web.filter. SimplePageCachingFilter </filter-class> </filter> <filter-mapping> <filter-name>SimplePageCachingFilter</filter-name> <url-pattern>/index.jsp</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> 2009 Updated from JavaOne Session 2007 | 14
  • 15. Add Cache to Ehcache Configuration Full Page Cache <ehcache> <diskStore path=quot;java.io.tmpdirquot;/> ... <cache name=quot;SimplePageCachingFilterquot; maxElementsInMemory=quot;10000quot; maxElementsOnDisk=quot;1000quot; eternal=quot;falsequot; overflowToDisk=quot;truequot; timeToIdleSeconds=quot;300quot; timeToLiveSeconds=quot;600quot; memoryStoreEvictionPolicy=quot;LFUquot; /> </ehcache> 2009 Updated from JavaOne Session 2007 | 15
  • 16. Filter Configuration in web.xml Page Fragment Cache <filter> <filter-name>SimplePageFragmentCache</filter-name> <filter-class>net.sf.ehcache.constructs.web.filter. SimplePageFragmentCachingFilter </filter-class> </filter> <!-- Page Fragment Cache --> <filter-mapping> <filter-name>SimplePageFragmentCachingFilter </filter-name> <url-pattern>/include/Footer.jsp</url-pattern> </filter-mapping> 2009 Updated from JavaOne Session 2007 | 16
  • 17. JPA/Hibernate Caching Overview Hibernate can either be used directly either or ● via the Hibernate Java Persistence API Provider in Hibernate 3.2 Ehcache is a CacheProvider for Hibernate 2.x ● and 3.x Example Simple Country persistent ● object/Entity 2009 Updated from JavaOne Session 2007 | 17
  • 18. JPA/Hibernate Caching Step by Step 1. Configure Hibernate to use ehcache 2. Configure the Country object's cacheability. This can be done in a number of ways. 3. Decide whether to use defaults, or to configure specific cache settings for the Country object cache in ehcache.xml 2009 Updated from JavaOne Session 2007 | 18
  • 19. JPA/Hibernate Caching Configure Hibernate to use ehcache Add the following to hibernate.properties hibernate.cache.provider_class=net.sf.ehcache.hibernate.EhCacheProvider <!-- optional configuration file parameter --> net.sf.ehcache.configurationResourceName=/name_of_configuration_resource 2009 Updated from JavaOne Session 2007 | 19
  • 20. JPA/Hibernate Caching Native Hibernate Mapping File Configuration <hibernate-mapping> <class name=quot;com.somecompany.someproject.domain.Countryquot; table=quot;ut_Countriesquot; dynamic-update=quot;falsequot; dynamic-insert=quot;falsequot; > <cache usage=quot;read-write|nonstrict-read-write|read-onlyquot; /> </class> ... </hibernate-mapping> <cache usage=quot;transactional|read-write|nonstrict-read-write|read-onlyquot; region=quot;RegionNamequot; include=quot;all|non-lazyquot; /> 2009 Updated from JavaOne Session 2007 | 20
  • 21. JPA/Hibernate Caching Entity Configuration with JPA and Hibernate Annotations @Entity ... @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public Class Country { private String name; ... } 2009 Updated from JavaOne Session 2007 | 21
  • 22. Distributed Caching for Clusters Features 1. Pluggable distribution mechanism. 2. RMI, JGroups and JMS replication modules. Terracotta also has an ehcache provider. 3. Multiple “clusters” 4. Replication set per Cache. Options: 1. Replicate adds 2. Replicate removes 3. Replicate update by copy or invalidate 4. Async or Sync 5. Bootstrapping from existing Caches in a cluster 2009 Updated from JavaOne Session 2007 | 22
  • 23. Distributed Caching for Clusters Architecture 2009 Updated from JavaOne Session 2007 | 23
  • 24. Distributed Caching for Clusters RMI Based Replication 1. Multicast Peer Discovery <cacheManagerPeerProviderFactory class= quot;net.sf.ehcache.distribution. RMICacheManagerPeerProviderFactoryquot; properties=quot;peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446/> 2. RMI Listener <cacheManagerPeerListenerFactory class= quot;net.sf.ehcache.distribution.RMICacheManagerPeerLis tenerFactoryquot;properties=quot;port=40001quot;/> 2009 Updated from JavaOne Session 2007 | 24
  • 25. Distributed Caching for Clusters Set Replication Per Cache <cache ...> <cacheEventListenerFactory class=quot;net.sf.ehcache.distribution.RMICacheReplicatorFactoryquot; properties=quot;replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true, replicateRemovals=true, asynchronousReplicationIntervalMillis=1000quot;/> ... </cache> 2009 Updated from JavaOne Session 2007 | 25
  • 26. Distributed Caching for Clusters Set Bootstrapping Per Cache <cache ...> <bootstrapCacheLoaderFactory class=quot; net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactoryquot; properties=quot;bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000quot;/> </cache> 2009 Updated from JavaOne Session 2007 | 26
  • 27. Cache Server REST and SOAP APIs Supports HTTP/1.1 request pipelining Deployed to a WAR or self-contained with Glassfish Embedded Benefits over memcached: •clients in any language •may utilise HTTP load balancers •servers are clustered using ehcache replication 2009 Updated from JavaOne Session 2007 | 27
  • 28. Cache Server Architecture 2009 Updated from JavaOne Session 2007 | 28
  • 29. Cache Server Ehcache in-process compared with Memcached (Ehcache server would be similar to memcached) 7000 6000 5000 ehcache-1.2.4 memory 4000 ehcache-1.2.4 disk memcached-1.2.1 3000 2000 1000 0 put/set get remove/delete 2009 Updated from JavaOne Session 2007 | 29
  • 30. Cache Server Client coding examples Scala import java.net.URL import scala.io.Source.fromInputStream object ExampleScalaGet extends Application { val url = new URL(quot;http://localhost:8080/ehcache/rest/sampleCache2/2quot;) fromInputStream(url.openStream).getLines.foreach(print) } PHP <?php $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, quot;http://localhost:8080/ehcache/rest/sampleCache2/3quot;); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_exec ($ch); curl_close ($ch); ?> 2009 Updated from JavaOne Session 2007 | 30
  • 31. Summary Most apps will benefit from caching ● You can calculate the speed up ● Ehcache is a modern, modular family of caching ● tools You can also benefit from ehcache indirectly ● through frameworks that use it Distributed ehcache is a small configuration step ● Cache Server is the new kid on the block ● 2009 Updated from JavaOne Session 2007 | 31
  • 32. For More Information Project Website: ● http://ehcache.sf.net Downloadable Book: ● http://www.lulu.com/content/paperback- ● book/ehcache-150-guide-reference/3553390 My Email: ● gluck@gregluck.com 2009 Updated from JavaOne Session 2007 | 32
  • 33. Q&A Greg Luck gluck@gregluck.com 33 2009 Updated from JavaOne Session 2007 |