SlideShare a Scribd company logo
@ljacomet#ehcachedvx
Caching reboot
javax.cache & Ehcache 3
@ljacomet#ehcachedvx
Agenda
@ljacomet#ehcachedvx
Agenda
• Why a cache?
@ljacomet#ehcachedvx
Agenda
• Why a cache?
• JSR-107
• APIs and features
• Provider extensions
@ljacomet#ehcachedvx
Agenda
• Why a cache?
• JSR-107
• APIs and features
• Provider extensions
• Caching in an application
• Cache aside
• Cache through
@ljacomet#ehcachedvx
Agenda
• Why a cache?
• JSR-107
• APIs and features
• Provider extensions
• Caching in an application
• Cache aside
• Cache through
• Resilience strategy
@ljacomet#ehcachedvx
Agenda
• Why a cache?
• JSR-107
• APIs and features
• Provider extensions
• Caching in an application
• Cache aside
• Cache through
• Resilience strategy
• Extras
@ljacomet#ehcachedvx
Who am I?
• Louis Jacomet
• Software engineer, closer to 40 than 20 and still coding!
• Engineer at Terracotta (Software AG) since 2013
• Working on Ehcache OS and EE mostly
• team manager and fiddling in infrastructure
• No idea how to do a (nice) UI - especially a web one
• Enjoys concurrency, thinking hard about APIs, …
Why a cache?
@ljacomet#ehcachedvx
Why a cache?
@ljacomet#ehcachedvx
What were these numbers?
@ljacomet#ehcachedvx
What were these numbers?
• Minute:
• L1$cache$access$$$$$$$$$$$$$$$0,5$s$$$One$heartbeat$
• Branch$misprediction$$$$$$$$$$5$$$s$$$Yawn$
• L2$cache$access$$$$$$$$$$$$$$$7$$$s$$$Long$yawn$
• Mutex$lock/unlock$$$$$$$$$$$$25$$$s$$$Coffee$preparation
@ljacomet#ehcachedvx
What were these numbers?
• Minute:
• L1$cache$access$$$$$$$$$$$$$$$0,5$s$$$One$heartbeat$
• Branch$misprediction$$$$$$$$$$5$$$s$$$Yawn$
• L2$cache$access$$$$$$$$$$$$$$$7$$$s$$$Long$yawn$
• Mutex$lock/unlock$$$$$$$$$$$$25$$$s$$$Coffee$preparation
• Hour:
• RAM$access$$$$$$$$$$$$$$$$$$100$$$s$$$Brushing$your$teeth$
• Compressing$1K$$$$$$$$$$$$$$$50$$$min$One$TV$show$episode
@ljacomet#ehcachedvx
What were these numbers?
• Minute:
• L1$cache$access$$$$$$$$$$$$$$$0,5$s$$$One$heartbeat$
• Branch$misprediction$$$$$$$$$$5$$$s$$$Yawn$
• L2$cache$access$$$$$$$$$$$$$$$7$$$s$$$Long$yawn$
• Mutex$lock/unlock$$$$$$$$$$$$25$$$s$$$Coffee$preparation
• Hour:
• RAM$access$$$$$$$$$$$$$$$$$$100$$$s$$$Brushing$your$teeth$
• Compressing$1K$$$$$$$$$$$$$$$50$$$min$One$TV$show$episode
• Day:
• 2KB$sent$on$1GB$network$$$$$$$5,5$h$$$Your$work$afternoon
@ljacomet#ehcachedvx
What were these numbers?
@ljacomet#ehcachedvx
What were these numbers?
• Week:
• Random$read$SSD$$$$$$$$$$$$$$$$$1,7$d$$$$$$$A$weekNend$
• Sequence$read$1$MB$from$RAM$$$$$2,9$d$$$$$$$A$long$weekNend$
• Round$trip$in$datacenter$$$$$$$$5,8$d$$$$$$$Holidays$
• Sequence$read$1MB$from$SSD$$$$$11,6$d$$$$$$$Two$weeks$delivery
@ljacomet#ehcachedvx
What were these numbers?
• Week:
• Random$read$SSD$$$$$$$$$$$$$$$$$1,7$d$$$$$$$A$weekNend$
• Sequence$read$1$MB$from$RAM$$$$$2,9$d$$$$$$$A$long$weekNend$
• Round$trip$in$datacenter$$$$$$$$5,8$d$$$$$$$Holidays$
• Sequence$read$1MB$from$SSD$$$$$11,6$d$$$$$$$Two$weeks$delivery
• Year:
• Seek$on$rotational$HDD$$$$$$$$$16,5$weeks$$$School$semester$
• Sequence$read$1MB$from$HDD$$$$$$7,8$months$$Almost$a$baby
@ljacomet#ehcachedvx
What were these numbers?
• Week:
• Random$read$SSD$$$$$$$$$$$$$$$$$1,7$d$$$$$$$A$weekNend$
• Sequence$read$1$MB$from$RAM$$$$$2,9$d$$$$$$$A$long$weekNend$
• Round$trip$in$datacenter$$$$$$$$5,8$d$$$$$$$Holidays$
• Sequence$read$1MB$from$SSD$$$$$11,6$d$$$$$$$Two$weeks$delivery
• Year:
• Seek$on$rotational$HDD$$$$$$$$$16,5$weeks$$$School$semester$
• Sequence$read$1MB$from$HDD$$$$$$7,8$months$$Almost$a$baby
• Decade:
• Data$roundNtrip$around$the$world$4,8$years$$PhD$thesis
@ljacomet#ehcachedvx
So what is a cache?
@ljacomet#ehcachedvx
So what is a cache?
• Data structure holding a temporary copy of some data
@ljacomet#ehcachedvx
So what is a cache?
• Data structure holding a temporary copy of some data
• Trade off between higher memory usage for reduced latency
@ljacomet#ehcachedvx
So what is a cache?
• Data structure holding a temporary copy of some data
• Trade off between higher memory usage for reduced latency
• Targets :
• Data which is reused
• Data which is expensive to compute or retrieve
@ljacomet#ehcachedvx
Ehcache (3)
@ljacomet#ehcachedvx
Ehcache (3)
• New version, fully integrated with JSR-107
• Breaks compatibility with 2.x line
@ljacomet#ehcachedvx
Ehcache (3)
• New version, fully integrated with JSR-107
• Breaks compatibility with 2.x line
• Developed in the open
• https://github.com/ehcache/ehcache3
@ljacomet#ehcachedvx
Ehcache (3)
• New version, fully integrated with JSR-107
• Breaks compatibility with 2.x line
• Developed in the open
• https://github.com/ehcache/ehcache3
• Public dev meeting, almost weekly, on hangouts on air
• Recordings available onYoutube
JSR-107 - javx.caching
@ljacomet#ehcachedvx
JSR-107
@ljacomet#ehcachedvx
JSR-107
• Ancient JSR
• Started in 2001
• Approved a year ago (March 2014)
@ljacomet#ehcachedvx
JSR-107
• Ancient JSR
• Started in 2001
• Approved a year ago (March 2014)
• javax.caching API + TCK + reference implementation
• Eases integration of a cache in frameworks
@ljacomet#ehcachedvx
JSR-107
• Ancient JSR
• Started in 2001
• Approved a year ago (March 2014)
• javax.caching API + TCK + reference implementation
• Eases integration of a cache in frameworks
• Ongoing discussions about a version 2.0
• Async API for example
@ljacomet#ehcachedvx
JSR-107 : Features
@ljacomet#ehcachedvx
JSR-107 : Features
•CacheManager / Cache
@ljacomet#ehcachedvx
JSR-107 : Features
•CacheManager / Cache
•Expiration
•Creation/Access/Update
@ljacomet#ehcachedvx
JSR-107 : Features
•CacheManager / Cache
•Expiration
•Creation/Access/Update
•Integration
•CacheLoader / Writer
@ljacomet#ehcachedvx
JSR-107 : Features
•CacheManager / Cache
•Expiration
•Creation/Access/Update
•Integration
•CacheLoader / Writer
•CacheEntryListener
•Created/Updated
•Removed/Expired
•Get old value
@ljacomet#ehcachedvx
JSR-107 : Features
•CacheManager / Cache
•Expiration
•Creation/Access/Update
•Integration
•CacheLoader / Writer
•CacheEntryListener
•Created/Updated
•Removed/Expired
•Get old value
•Entry processor
@ljacomet#ehcachedvx
JSR-107 : Features
•CacheManager / Cache
•Expiration
•Creation/Access/Update
•Integration
•CacheLoader / Writer
•CacheEntryListener
•Created/Updated
•Removed/Expired
•Get old value
•Entry processor
•Annotations
@ljacomet#ehcachedvx
JSR-107 : Features
•CacheManager / Cache
•Expiration
•Creation/Access/Update
•Integration
•CacheLoader / Writer
•CacheEntryListener
•Created/Updated
•Removed/Expired
•Get old value
•Entry processor
•Annotations
•MBeans, exposing
•Configuration
•Statistics
@ljacomet#ehcachedvx
JSR-107 : Features
•CacheManager / Cache
•Expiration
•Creation/Access/Update
•Integration
•CacheLoader / Writer
•CacheEntryListener
•Created/Updated
•Removed/Expired
•Get old value
•Entry processor
•Annotations
•MBeans, exposing
•Configuration
•Statistics
•No capacity control !
@YourTwitterHandle@YourTwitterHandle@ljacomet#ehcachedvx
Demo
@YourTwitterHandle@YourTwitterHandle@ljacomet#ehcachedvx
And my XML??
@ljacomet#ehcachedvx
JSR-107 configuration
• Programmatic only
• Enter the world of provider extensions
• Ehcache 3 expects CacheManager URI to resolve to a
configuration file
• From there, multiple scenarios are possible
@YourTwitterHandle@YourTwitterHandle@ljacomet#ehcachedvx
Demo
Caching in an application
@ljacomet#ehcachedvx
public BusinessObject computeAndWin(String param1,
String param2) {


String key = createKey(param1, param2);

BusinessObject cachedResult = cache.get(key);

if (cachedResult == null) {

cachedResult = loadAndCompute(param1, param2);

cache.put(key, cachedResult);

}

return cachedResult;

}
Cache Aside
@ljacomet#ehcachedvx
Cache Aside : not so easy
@ljacomet#ehcachedvx
Cache Aside : not so easy
• Requires synchronisation between
• cache
• and system of record
@ljacomet#ehcachedvx
Cache Aside : not so easy
• Requires synchronisation between
• cache
• and system of record
• JSR-107 has no locking option
@ljacomet#ehcachedvx
Cache Aside : not so easy
• Requires synchronisation between
• cache
• and system of record
• JSR-107 has no locking option
• Potential to be hairy code quite fast
@ljacomet#ehcachedvx
Cache Aside: options
@ljacomet#ehcachedvx
Cache Aside: options
• Rely on the abstraction of your framework
• Spring Caching
• Hibernate
• …
@ljacomet#ehcachedvx
Cache Aside: options
• Rely on the abstraction of your framework
• Spring Caching
• Hibernate
• …
• Alternatives ?
@ljacomet#ehcachedvx
public BusinessObject computeAndWin(String param1,
String param2) {


return cache.get(createKey(param1, param2));

}
Cache Through
@ljacomet#ehcachedvx
Cache Through
Cache
Application
code
RDBMS
@ljacomet#ehcachedvx
Cache Through
Cache
Application
code
RDBMS
@ljacomet#ehcachedvx
Cache Through
Cache
Application
code
RDBMS
@ljacomet#ehcachedvx
Cache Through
Cache
Application
code
RDBMS
@ljacomet#ehcachedvx
Cache Through
Cache
Application
code
RDBMS
@ljacomet#ehcachedvx
Cache Through
@ljacomet#ehcachedvx
Cache Through
• get* => CacheLoader
• cache miss indicates no data available
@ljacomet#ehcachedvx
Cache Through
• get* => CacheLoader
• cache miss indicates no data available
• put* => CacheWriter
• Each use means writing to the system of record
@ljacomet#ehcachedvx
Cache Through
• get* => CacheLoader
• cache miss indicates no data available
• put* => CacheWriter
• Each use means writing to the system of record
• Constraints:APIs of CacheLoader / CacheWriter
@ljacomet#ehcachedvx
Cache Through : JSR-107
@ljacomet#ehcachedvx
Cache Through : JSR-107
• Peculiar behaviours
@ljacomet#ehcachedvx
Cache Through : JSR-107
• Peculiar behaviours
• putIfAbsent(K key,V value): boolean
@ljacomet#ehcachedvx
Cache Through : JSR-107
• Peculiar behaviours
• putIfAbsent(K key,V value): boolean
• Ignores CacheLoader but not CacheWriter
@ljacomet#ehcachedvx
Cache Through : JSR-107
• Peculiar behaviours
• putIfAbsent(K key,V value): boolean
• Ignores CacheLoader but not CacheWriter
• Ehcache 3 allows to tweak this behaviour through
configuration
@ljacomet#ehcachedvx
Cache Through : JSR-107
• Peculiar behaviours
• putIfAbsent(K key,V value): boolean
• Ignores CacheLoader but not CacheWriter
• Ehcache 3 allows to tweak this behaviour through
configuration
• Behaviour consistent across atomic operations
@ljacomet#ehcachedvx
Cache Through : Write Behind
@ljacomet#ehcachedvx
Cache Through : Write Behind
• Asynchronous writes to the the system of record
• User thread no longer suffers from the latency of the write
@ljacomet#ehcachedvx
Cache Through : Write Behind
• Asynchronous writes to the the system of record
• User thread no longer suffers from the latency of the write
• Introduces its own complexities
• Write queue: persistent or not?
• Mutation guarantee: once and only once? at least once?
• What about cache eviction?
Resilience strategy
@ljacomet#ehcachedvx
Resilience strategy
@ljacomet#ehcachedvx
Resilience strategy
• Proposition:
“A cache level error
should not be the cause for
a user level error “
@ljacomet#ehcachedvx
Resilience strategy
• Proposition:
“A cache level error
should not be the cause for
a user level error “
P.S.This is ongoing development and subject to change
@ljacomet#ehcachedvx
Ehcache 3
@ljacomet#ehcachedvx
Ehcache 3
• Handle errors internally as much as possible
@ljacomet#ehcachedvx
Ehcache 3
• Handle errors internally as much as possible
• In memory cache => No exceptions in the execution thread
@ljacomet#ehcachedvx
Ehcache 3
• Handle errors internally as much as possible
• In memory cache => No exceptions in the execution thread
• Default is to log errors, will be configurable / replaceable
@ljacomet#ehcachedvx
Ehcache 3
• Handle errors internally as much as possible
• In memory cache => No exceptions in the execution thread
• Default is to log errors, will be configurable / replaceable
• Advanced setups (Distributed + write behind for example)
@ljacomet#ehcachedvx
Ehcache 3
• Handle errors internally as much as possible
• In memory cache => No exceptions in the execution thread
• Default is to log errors, will be configurable / replaceable
• Advanced setups (Distributed + write behind for example)
• Force user to think about the use cases where the cache can
become inconsistent
@ljacomet#ehcachedvx
Ehcache 3
• Handle errors internally as much as possible
• In memory cache => No exceptions in the execution thread
• Default is to log errors, will be configurable / replaceable
• Advanced setups (Distributed + write behind for example)
• Force user to think about the use cases where the cache can
become inconsistent
• Will be required to configure a handler for these cases
Ehcache 3 and Terracotta
@ljacomet#ehcachedvx
Offheap solution
@ljacomet#ehcachedvx
Offheap solution
• Solving Garbage Collector pauses on large heaps
@ljacomet#ehcachedvx
Offheap solution
• Solving Garbage Collector pauses on large heaps
• Enables extreme cache scale up
• Multi TerraBytes … as long as your server allows it
@ljacomet#ehcachedvx
Offheap solution
• Solving Garbage Collector pauses on large heaps
• Enables extreme cache scale up
• Multi TerraBytes … as long as your server allows it
• Production tested implementation
• 2.0.0 available on GitHub
• https://github.com/Terracotta-OSS/offheap-store
@ljacomet#ehcachedvx
Clustering solution
@ljacomet#ehcachedvx
Clustering solution
• Sharing of data across multiple JVMs
@ljacomet#ehcachedvx
Clustering solution
• Sharing of data across multiple JVMs
• Terracotta 4.3.0 again has an OpenSource offering
• Integration with Ehcache 2.10.0
@ljacomet#ehcachedvx
Clustering solution
• Sharing of data across multiple JVMs
• Terracotta 4.3.0 again has an OpenSource offering
• Integration with Ehcache 2.10.0
• Ehcache 3 will have clustering option in OpenSource
• Code starting to appear on GitHub
@YourTwitterHandle@YourTwitterHandle@ljacomet#ehcachedvx
Questions ?

More Related Content

PDF
Terracotta's OffHeap Explained
PDF
Ehcache 3: JSR-107 on steroids at Devoxx Morocco
PDF
Ehcache 3 @ BruJUG
KEY
London devops logging
PDF
Australian OpenStack User Group August 2012: Chef for OpenStack
PDF
Integrated Cache on Netscaler
PDF
Advanced Oracle Troubleshooting
PDF
Introduction to Apache ZooKeeper
Terracotta's OffHeap Explained
Ehcache 3: JSR-107 on steroids at Devoxx Morocco
Ehcache 3 @ BruJUG
London devops logging
Australian OpenStack User Group August 2012: Chef for OpenStack
Integrated Cache on Netscaler
Advanced Oracle Troubleshooting
Introduction to Apache ZooKeeper

What's hot (19)

PDF
Scaling Your Cache
PDF
Caching with Memcached and APC
PDF
Use case for using the ElastiCache for Redis in production
PDF
Elasticsearch for Logs & Metrics - a deep dive
PDF
In Memory Database In Action by Tanel Poder and Kerry Osborne
PDF
Empowering developers to deploy their own data stores
KEY
DjangoCon 2010 Scaling Disqus
PDF
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
PDF
Oracle Latch and Mutex Contention Troubleshooting
PDF
Practicing Continuous Deployment
PDF
High Concurrency Architecture and Laravel Performance Tuning
PPTX
Apache Performance Tuning: Scaling Up
PDF
Creating PostgreSQL-as-a-Service at Scale
KEY
Curator intro
PDF
Memcached Code Camp 2009
PPTX
HBaseConEast2016: Practical Kerberos with Apache HBase
PDF
Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013
PPTX
Kafka Tutorial: Advanced Producers
PDF
Moxi - Memcached Proxy
Scaling Your Cache
Caching with Memcached and APC
Use case for using the ElastiCache for Redis in production
Elasticsearch for Logs & Metrics - a deep dive
In Memory Database In Action by Tanel Poder and Kerry Osborne
Empowering developers to deploy their own data stores
DjangoCon 2010 Scaling Disqus
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Oracle Latch and Mutex Contention Troubleshooting
Practicing Continuous Deployment
High Concurrency Architecture and Laravel Performance Tuning
Apache Performance Tuning: Scaling Up
Creating PostgreSQL-as-a-Service at Scale
Curator intro
Memcached Code Camp 2009
HBaseConEast2016: Practical Kerberos with Apache HBase
Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013
Kafka Tutorial: Advanced Producers
Moxi - Memcached Proxy
Ad

Similar to Caching reboot: javax.cache & Ehcache 3 (20)

PDF
Ehcache3 — JSR-107 on steroids
PDF
Where Django Caching Bust at the Seams
PDF
PPTX
HotSpotコトハジメ
PPTX
Typesafe spark- Zalando meetup
PDF
Building low latency java applications with ehcache
PDF
Caching in applications still matters
PPTX
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
PDF
In-memory No SQL- GIDS2014
PDF
Caching 101: sur la JVM et au delà
PPTX
Benchmarking Solr Performance at Scale
PDF
Caching and JCache with Greg Luck 18.02.16
PDF
Docker Logging and analysing with Elastic Stack
PDF
Docker Logging and analysing with Elastic Stack - Jakub Hajek
PPTX
Игорь Фесенко "Direction of C# as a High-Performance Language"
PPTX
AppFabric Velocity
PDF
Migration strategies 4
PDF
Gimme Caching - The JCache Way
PPTX
introduction to node.js
PPTX
06 integrate elasticsearch
Ehcache3 — JSR-107 on steroids
Where Django Caching Bust at the Seams
HotSpotコトハジメ
Typesafe spark- Zalando meetup
Building low latency java applications with ehcache
Caching in applications still matters
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
In-memory No SQL- GIDS2014
Caching 101: sur la JVM et au delà
Benchmarking Solr Performance at Scale
Caching and JCache with Greg Luck 18.02.16
Docker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic Stack - Jakub Hajek
Игорь Фесенко "Direction of C# as a High-Performance Language"
AppFabric Velocity
Migration strategies 4
Gimme Caching - The JCache Way
introduction to node.js
06 integrate elasticsearch
Ad

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
history of c programming in notes for students .pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
medical staffing services at VALiNTRY
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Understanding Forklifts - TECH EHS Solution
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Which alternative to Crystal Reports is best for small or large businesses.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Odoo POS Development Services by CandidRoot Solutions
Upgrade and Innovation Strategies for SAP ERP Customers
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PTS Company Brochure 2025 (1).pdf.......
Wondershare Filmora 15 Crack With Activation Key [2025
history of c programming in notes for students .pptx
L1 - Introduction to python Backend.pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
medical staffing services at VALiNTRY
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...

Caching reboot: javax.cache & Ehcache 3