SlideShare a Scribd company logo
1 of 36
Download to read offline
Distributed Caching
with Java
Kasun Gajasinghe
Senior Software Engineer
WSO2
● What & Why for (Distributed) Caching
● Different types of Caches
● Cache access patterns
● Java JCache specification
● Demo
● Q&A
Agenda
(... but why do I
want to Cache?)
O O O
source: http://no7scramblecross.blogspot.com/2009/04/speaking-of-cats.html
Caching? … Distributed?
Gotcha!!
source: http://matome.naver.jp/odai/2140238539583350401/2140238875587055003
● Application performance - get around
bottlenecks arising from using data that is
expensive to retrieve
○ DB or web service
○ data that is hard to calculate
○ monetary aspects
Why software Caching
● improve the response times by reducing data
access latency
● avoid cost of repeatedly creating objects
● reduces IO overhead
Caching
● limited memory size
● consistency - consistency between cached
data vs actual data
● durability - cache expiration/invalidation
● scalability
Caching considerations
Types of caches
● local cache
● replicated cache
● distributed cache
Local Cache
● Local Cache a cache that is local to
(completely contained within) a particular
cluster node
Local Cache - example
Local Cache - with TTL
Local Cache
Pros:
● simplicity
● performance
● no serialization/deserialization overhead
Cons:
● not fault-tolerant
● scalability
Replicated cache
● a cache that replicates its data to all cluster
nodes
GET in replicated cache
Each cluster node (JVM) accesses the data from its own
memory, i.e. a local read.
PUT in replicated cache
Pushing the new version of the data to all other cluster
nodes
Replicated Cache
Pros:
● best read performance
● fault–tolerant
● linear performance scalability for reads
Cons:
● poor write performance
● memory consumption
● additional network load
● poor and limited scalability for writes
Distributed Cache
a cache that partitions its data among all
cluster nodes
GET in Distributed Cache
Access often must go over the network to another cluster
node
Resolving known limitation of replicated cache:
PUT in Distributed Cache
PUT in Distributed Cache
● the data is being sent to a primary cluster node
and a backup cluster node if backup count is 1
● modifications to the cache are not considered
complete until all backups have acknowledged
receipt of the modification, i.e. slight
performance penalty
● such overhead guarantees that data consistency
is maintained and no data is lost
Failover in Distributed Cache
Failover involves promoting backup data to be
primary storage.
Distributed Cache
Pros:
● linear performance scalability for reads and writes
● fault–tolerant
Cons:
● increased latency of reads (due to network round-trip
and serialization/deserialization expenses)
Cache Access Patterns
● cache aside
● read-through
● write-through
Cache Aside Pattern
● application is responsible of reading and writing to the
storage.
● cache doesn’t interact with storage
● the cache is ‘kept aside’ as a faster and more scalable in-
memory data store
Read-through/Write-through
● application treats the cache as the main data
store, and reads/writes data from/to it
● cache is responsible to read/write the data
into the actual storage.
Java JCache specification
● Standard Java Caching API
● javax.cache.*
● Implementation can be local or distributed
JCache API
● javax.cache.Cache
● javax.cache.CacheManager
● javax.cache.spi.CachingProvider
JCache API
JCache API - Annotations
• Use the cache
JCache API - Annotations
• Put into the cache
JCache API - Annotations
• Remove from the cache
javax.cache.expiry.
● AccessedExpiryPolicy: Expires after a given set of time measured from creation of the cache entry, the expiry timeout is
updated on accessing the key.
● CreatedExpiryPolicy: Expires after a given set of time measured from creation of the cache entry, the expiry timeout is
never updated.
● EternalExpiryPolicy: Never expires, this is the default behavior, similar to ExpiryPolicy to be set to null.
● ModifiedExpiryPolicy
● TouchedExpiryPolicy
JCache API - Expiry Policies
JCache implementations
• Hazelcast
• Oracle Coherence
• Pivotal Gemfire
• Ehcache
• Infinispan
• Gridgain/Ignite
• Couchbase
Q&A
THANK YOU!
1. http://docs.hazelcast.org/docs/latest/manual/html-single/hazelcast-
documentation.html#hazelcast-jcache
2. https://spring.io/blog/2014/04/14/cache-abstraction-jcache-jsr-107-
annotations-support
References

More Related Content

What's hot

Introduction to multi core
Introduction to multi coreIntroduction to multi core
Introduction to multi core
mukul bhardwaj
 
Basic Garbage Collection Techniques
Basic  Garbage  Collection  TechniquesBasic  Garbage  Collection  Techniques
Basic Garbage Collection Techniques
An Khuong
 

What's hot (20)

Cache optimization
Cache optimizationCache optimization
Cache optimization
 
Chapter 5 design of keyvalue databses from nosql for mere mortals
Chapter 5 design of keyvalue databses from nosql for mere mortalsChapter 5 design of keyvalue databses from nosql for mere mortals
Chapter 5 design of keyvalue databses from nosql for mere mortals
 
SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022
SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022
SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022
 
Introduction to multi core
Introduction to multi coreIntroduction to multi core
Introduction to multi core
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
ELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log systemELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log system
 
04 cache memory.ppt 1
04 cache memory.ppt 104 cache memory.ppt 1
04 cache memory.ppt 1
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Mastering GC.pdf
Mastering GC.pdfMastering GC.pdf
Mastering GC.pdf
 
Basic Garbage Collection Techniques
Basic  Garbage  Collection  TechniquesBasic  Garbage  Collection  Techniques
Basic Garbage Collection Techniques
 
Deadlock
DeadlockDeadlock
Deadlock
 
RPC communication,thread and processes
RPC communication,thread and processesRPC communication,thread and processes
RPC communication,thread and processes
 
Distributed file system
Distributed file systemDistributed file system
Distributed file system
 
How to deploy Apache Spark in a multi-tenant, on-premises environment
How to deploy Apache Spark in a multi-tenant, on-premises environmentHow to deploy Apache Spark in a multi-tenant, on-premises environment
How to deploy Apache Spark in a multi-tenant, on-premises environment
 
Stanford CS347 Guest Lecture: Apache Spark
Stanford CS347 Guest Lecture: Apache SparkStanford CS347 Guest Lecture: Apache Spark
Stanford CS347 Guest Lecture: Apache Spark
 
Operating System Structure
Operating System StructureOperating System Structure
Operating System Structure
 
Reshape Data Lake (as of 2020.07)
Reshape Data Lake (as of 2020.07)Reshape Data Lake (as of 2020.07)
Reshape Data Lake (as of 2020.07)
 
Cuda Architecture
Cuda ArchitectureCuda Architecture
Cuda Architecture
 
From distributed caches to in-memory data grids
From distributed caches to in-memory data gridsFrom distributed caches to in-memory data grids
From distributed caches to in-memory data grids
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 

Viewers also liked

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
 
Jug Lugano - Scale over the limits
Jug Lugano - Scale over the limitsJug Lugano - Scale over the limits
Jug Lugano - Scale over the limits
Davide Carnevali
 

Viewers also liked (11)

Caching In Java- Best Practises and Pitfalls
Caching In Java- Best Practises and PitfallsCaching In Java- Best Practises and Pitfalls
Caching In Java- Best Practises and Pitfalls
 
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 ...
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 
Jug Lugano - Scale over the limits
Jug Lugano - Scale over the limitsJug Lugano - Scale over the limits
Jug Lugano - Scale over the limits
 
Data Locality, Latency and Caching: JSR-107 and the new Java JCACHE Standard
Data Locality, Latency and Caching:  JSR-107 and the new Java JCACHE StandardData Locality, Latency and Caching:  JSR-107 and the new Java JCACHE Standard
Data Locality, Latency and Caching: JSR-107 and the new Java JCACHE Standard
 
Redis overview for Software Architecture Forum
Redis overview for Software Architecture ForumRedis overview for Software Architecture Forum
Redis overview for Software Architecture Forum
 
Caching solutions with Redis
Caching solutions   with RedisCaching solutions   with Redis
Caching solutions with Redis
 
Managing user's data with Spring Session
Managing user's data with Spring SessionManaging user's data with Spring Session
Managing user's data with Spring Session
 
Distributed applications using Hazelcast
Distributed applications using HazelcastDistributed applications using Hazelcast
Distributed applications using Hazelcast
 
JCache Using JCache
JCache Using JCacheJCache Using JCache
JCache Using JCache
 
Real time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkReal time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache Spark
 

Similar to Distributed caching with java JCache

Caching principles-solutions
Caching principles-solutionsCaching principles-solutions
Caching principles-solutions
pmanvi
 
Veeam Webinar - Case study: building bi-directional DR
Veeam Webinar - Case study: building bi-directional DRVeeam Webinar - Case study: building bi-directional DR
Veeam Webinar - Case study: building bi-directional DR
Joep Piscaer
 

Similar to Distributed caching with java JCache (20)

Mini-Training: To cache or not to cache
Mini-Training: To cache or not to cacheMini-Training: To cache or not to cache
Mini-Training: To cache or not to cache
 
Anatomy of in memory processing in Spark
Anatomy of in memory processing in SparkAnatomy of in memory processing in Spark
Anatomy of in memory processing in Spark
 
MSE
MSEMSE
MSE
 
Don’t give up, You can... Cache!
Don’t give up, You can... Cache!Don’t give up, You can... Cache!
Don’t give up, You can... Cache!
 
Caching principles-solutions
Caching principles-solutionsCaching principles-solutions
Caching principles-solutions
 
Caching in drupal
Caching in drupalCaching in drupal
Caching in drupal
 
Choose the Right Container Storage for Kubernetes
Choose the Right Container Storage for KubernetesChoose the Right Container Storage for Kubernetes
Choose the Right Container Storage for Kubernetes
 
Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
 
Mow2012 data services
Mow2012 data servicesMow2012 data services
Mow2012 data services
 
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
 
Drupal 7 performance and optimization
Drupal 7 performance and optimizationDrupal 7 performance and optimization
Drupal 7 performance and optimization
 
Massive Storage Engine
Massive Storage EngineMassive Storage Engine
Massive Storage Engine
 
Comparison between zookeeper, etcd 3 and other distributed coordination systems
Comparison between zookeeper, etcd 3 and other distributed coordination systemsComparison between zookeeper, etcd 3 and other distributed coordination systems
Comparison between zookeeper, etcd 3 and other distributed coordination systems
 
Towards User-Defined SLA in Cloud Flash Storage.pptx
Towards User-Defined SLA in Cloud Flash Storage.pptxTowards User-Defined SLA in Cloud Flash Storage.pptx
Towards User-Defined SLA in Cloud Flash Storage.pptx
 
Optimizing Latency-sensitive queries for Presto at Facebook: A Collaboration ...
Optimizing Latency-sensitive queries for Presto at Facebook: A Collaboration ...Optimizing Latency-sensitive queries for Presto at Facebook: A Collaboration ...
Optimizing Latency-sensitive queries for Presto at Facebook: A Collaboration ...
 
IaaS for DBAs in Azure
IaaS for DBAs in AzureIaaS for DBAs in Azure
IaaS for DBAs in Azure
 
Veeam Webinar - Case study: building bi-directional DR
Veeam Webinar - Case study: building bi-directional DRVeeam Webinar - Case study: building bi-directional DR
Veeam Webinar - Case study: building bi-directional DR
 
Webinar: Overcoming the Storage Roadblock to Data Center Modernization
Webinar: Overcoming the Storage Roadblock to Data Center ModernizationWebinar: Overcoming the Storage Roadblock to Data Center Modernization
Webinar: Overcoming the Storage Roadblock to Data Center Modernization
 
J2EE Batch Processing
J2EE Batch ProcessingJ2EE Batch Processing
J2EE Batch Processing
 

More from Kasun Gajasinghe

[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...
[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...
[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...
Kasun Gajasinghe
 
Survey on Frequent Pattern Mining on Graph Data - Slides
Survey on Frequent Pattern Mining on Graph Data - SlidesSurvey on Frequent Pattern Mining on Graph Data - Slides
Survey on Frequent Pattern Mining on Graph Data - Slides
Kasun Gajasinghe
 
Google Summer of Code 2011 Sinhalese flyer
Google Summer of Code  2011 Sinhalese flyer Google Summer of Code  2011 Sinhalese flyer
Google Summer of Code 2011 Sinhalese flyer
Kasun Gajasinghe
 

More from Kasun Gajasinghe (7)

Building Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 ASBuilding Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 AS
 
Building Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 ASBuilding Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 AS
 
[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...
[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...
[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...
 
Siddhi CEP Engine
Siddhi CEP EngineSiddhi CEP Engine
Siddhi CEP Engine
 
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
 
Survey on Frequent Pattern Mining on Graph Data - Slides
Survey on Frequent Pattern Mining on Graph Data - SlidesSurvey on Frequent Pattern Mining on Graph Data - Slides
Survey on Frequent Pattern Mining on Graph Data - Slides
 
Google Summer of Code 2011 Sinhalese flyer
Google Summer of Code  2011 Sinhalese flyer Google Summer of Code  2011 Sinhalese flyer
Google Summer of Code 2011 Sinhalese flyer
 

Recently uploaded

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Recently uploaded (20)

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 

Distributed caching with java JCache