terracotta ehcache : simpler, faster, distributed
TRANSCRIPT
![Page 1: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/1.jpg)
© 2016 Software AG. All rights reserved. For internal use only
TERRACOTTA EHCACHE: SIMPLER, FASTER, DISTRIBUTEDDEVOXX BELGIUM NOVEMBER 9TH 2016 ANTHONY DAHANNE @ANTHONYDAHANNE
![Page 2: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/2.jpg)
�Anthony Dahanne, Software Engineer @ Terracotta, a Software AG company
�Working on the Terracotta Management Console, and its integration in Terracotta products
�And strong Docker supporter :-P , trying to containerize as much as I can !
LET ME INTRODUCE MYSELF
�Come visit us at Booth #1 ! Oculus Rift to win !!!
![Page 3: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/3.jpg)
AGENDA
Caching 101
Caching on the JVM
Clustered Caching with Terracotta Server
Deployment examples
![Page 4: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/4.jpg)
CACHING 101
![Page 5: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/5.jpg)
CACHE DEFINITION
“Store of things that will be required in the future,
and can be retrieved rapidly.”from wiktionary.com
A Map (key / value mappings) with capacity control (via eviction) and freshness control (via expiry)
![Page 6: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/6.jpg)
WHERE IS CACHING USED ?
from ArsTechnica
![Page 7: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/7.jpg)
LATENCIES TO REMEMBERL1 cache reference 0.5 ns
L2 cache reference 7 ns 14x L1 cache
Main memory reference 100 ns 20x L2 cache
Read 1 MB sequentially from memory 250,000 ns 250 us
Round trip within same datacenter 500,000 ns 500 us
Read 1 MB sequentially from SSD* 1,000,000 ns 1,000 us 1 ms ~1GB/sec SSD
Read 1 MB sequentially from disk 20,000,000 ns 20,000 us 20 ms 80x memory
Send packet CA->Netherlands->CA 150 ms 150 ms
from github.com/jboner
![Page 8: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/8.jpg)
WHERE IS CACHING USED ?
Browser Caching CDN CachingCPU Caching
Application CachingDisk Caching
![Page 9: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/9.jpg)
CACHING THEORY : AMDAHL’S LAW
“the theoretical speedup is always limited by the part of the task that cannot benefit from the improvement.”, from Wikipedia
s : speedup in latency p : percentage of the execution time
![Page 10: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/10.jpg)
CACHING THEORY : THE LONG TAIL
![Page 11: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/11.jpg)
CACHING GLOSSARY
• Hit : when the cache returns a value
• Miss : when the cache does not have a value
• Cold / Hot : when the cache is empty / full
![Page 12: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/12.jpg)
WHAT TO MEASURE WHEN CACHING
• Cache Usage (empty ? full ?) • HitRatio : hits / (misses + hits) • HitRate : hits / second
![Page 13: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/13.jpg)
CACHING ON THE JVM
![Page 14: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/14.jpg)
HISTORY OF CACHING ON THE JVM
Review Ballot
2001
Public Review
2013
First Release
2003
2.0 “Express”
2010
2.3 Offheap
2011
JSR-107
EHCACHE
First Release
2003
Terracotta 5
2016
TERRACOTTA
Ehcache3
2016
2009
Ehcache acquisition
Public Release
2014
![Page 15: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/15.jpg)
EHCACHE REBOOT : EHCACHE3
• 3.0 (May 2016) • Compatible with JSR 107 (javax.cache) • User managed cache • Copiers & Serializers • Strong typing
• 3.1 (Jun 2016) • Clustered tier added
• 3.2 (2 days ago) • High Availability with Terracotta Server
![Page 16: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/16.jpg)
CACHING PATTERNS
• No Caching • Cache aside
• Cache through
• Demo !
Business logic
CacheGET(K)
PUT(K,V)
NULL
LOAD(K)
V
SoRK,V
K,V
Business logic Cache
GET(K) LOAD(K)
V
PUT(K,V)
K,VSoRK,VV
![Page 17: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/17.jpg)
CLUSTERED CACHING WITH TERRACOTTA SERVER
![Page 18: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/18.jpg)
TERRACOTTA SERVER RESOURCES
from ehcache.org documentation
![Page 19: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/19.jpg)
MULTI CONTAINER DEPLOYMENT
PostgreSQL
Terracotta Server
Webapp with Ehcache3 Clustered
Webapp with Ehcache3 Clustered
Webapp with Ehcache3 Clustered
![Page 20: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/20.jpg)
DEPLOYMENT EXAMPLES
![Page 21: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/21.jpg)
App Server
App ServerApp Server
DEPLOYMENT
App ServerApp Server
Ehcache
App ServerJBOSS SOA-PApp Server
Ehcache
Layer 7
“Presentation Zone” “Application Zone”Individual & Families
Issuers
3rd Parties (B2B)
187K simultaneous users / 6K processes requests/s 10’s of Terracotta Servers / 100’s of caching clients
![Page 22: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/22.jpg)
LINKS AND REFERENCES
• The essence of caching, by Greg Luck (available on youtube)
• Caching 101: Caching on the JVM (and beyond) by Louis Jacomet & Aurelien Broszniowski (available on youtube)
• Ehcache3 documentation (available on ehcache.org)
• Ehcache3 and Terracotta Server demos (available on github)
![Page 23: Terracotta Ehcache : Simpler, faster, distributed](https://reader031.vdocuments.net/reader031/viewer/2022030305/58719b8d1a28ab044e8b5c49/html5/thumbnails/23.jpg)
© 2016 Software AG. All rights reserved. For internal use only23