1. Caching with Spring: Advanced Topics and Best Practices Michael Plöd @bitboss © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
2. I will talk about Caching Types / Topologies Best Practices for Caching in Enterprise Applications Caching with Spring JCache and Spring I will NOT talk about Latency / Synchronization discussion What is the best caching product on the market HTTP / Database Caching Caching in JPA, Hibernate or other ORMs
3.Cache! / kæʃ /! In computing, a cache is a component that transparently stores data so that future requests for that data can be served faster. The data that is stored within a cache might be values that have been computed earlier or duplicates of original values that are stored elsewhere. If requested data is contained in the cache (cache hit), this request can be served by simply reading the cache, which is comparatively faster. Otherwise (cache miss), the data has to be recomputed or fetched from its original storage location, which is comparatively slower. Hence, the greater the number of requests that can be served from the cache, the faster the overall system performance becomes. Source: http://en.wikipedia.org/wiki/Cache_(computing)
4.That’s awesome. Let’s cache everything and everywhere and distribute it all in a Cluster in a transactional manner ohhh by the way: Twitter has been doing that for ages Are you crazy?
5. Business-Applications != Twitter / Facebook & co.
6. Many enterprise grade projects are adapting caching too defensive or too offensive and are running into consistency or performance issues because of that
7.But with a well adjusted caching strategy you will make your application more scalable, faster and cheaper to operate.
8. Local Cache, Data Grid, Document Store, JPA First Level Cache, JPA Second Level Cache, Hybrid Cache Types Places of for CACHES Database, Heap, HTTP Proxy, Browser, Prozessor, Disk, Off Heap, Persistence- Framework, Application
9. We will focus on local and distributed caching at the application level with the Spring Framework
10. How about data-consistency Which data shall I Which impact does it have on my cache? infrastructure Which cache shall I use? How do I introduce caching? Where shall I cache? How about caching in Spring?
11. How about data-consistency Which data shall I Which impact does it have on my cache? infrastructure Which cache shall I use? How do I introduce caching? Where shall I cache? How about caching in Spring?
12.1 Identify suitable layers for caching
13. HTTP Caching ComplaintManagementRestController Read Operations Suitable Layers ComplaintManagementBusinessService DataAggrgationManager Read Operations for Host! Commands SAP! Commands Spring Data Repository Caching Read and Read Read Write Operations Operations Operations
14.2 Stay local as long as possible
15.Lokal In-Memory JVM Cache
16. Clustered JVM JVM Cache Cache JVM JVM Cache Cache
17. How about data-consistency Which data shall I Which impact does it have on my cache? infrastructure Which cache shall I use? How do I introduce caching? Where shall I cache? How about caching in Spring?
18.Clustered - with sync JVM JVM Cache Cache JVM JVM Cache Cache
19.Clustered - with sync JVM JVM Invalidation Cache Cache JVM JVM Replication Cache Cache
20.3 Avoid real replication where possible
21.Invalidation - Option 1 Cache Cache Cache Cache
22.Invalidation - Option 1 Cache Cache PUT PUT #1 #1 (Insert) (Insert) Cache Cache PUT PUT #1 #1 (Insert) (Insert)
23.Invalidation - Option 1 Cache Cache #1 #1 Cache Cache #1 #1
24.Invalidation - Option 1 Cache Cache #1 #1 Cache Cache PUT #1 #1 (Update)
25.Invalidation - Option 1 Cache Cache Cache Cache PUT #1 (Update)
26.Invalidation - Option 2 Cache Cache Cache Cache
27.Invalidation - Option 2 Cache Cache PUT #1 (Insert) Cache Cache
28. Replication Cache Cache Cache Cache
29. Replication Cache Cache PUT #1 #1 (Insert) Cache Cache #1 #1