Where is my cache? Architectural patterns for caching ... is my cache...microservices by example...

93
Where is my cache? Architectural patterns for caching microservices by example Rafał Leszko Cloud Software Engineer Hazelcast

Transcript of Where is my cache? Architectural patterns for caching ... is my cache...microservices by example...

Page 1: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Where is my cache?Architectural patterns for caching

microservices by exampleRafał Leszko

Cloud Software EngineerHazelcast

Page 2: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

About me

● Cloud Software Engineer at Hazelcast● Worked at Google and CERN● Author of the book "Continuous Delivery with

Docker and Jenkins"● Trainer and conference speaker● Live in Kraków, Poland

Page 3: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

About Hazelcast

● Distributed Company● Open Source Software● 140+ Employees● Hiring (Remote)!● Recently Raised $21M● Products:

○ Hazelcast IMDG○ Hazelcast Jet○ Hazelcast Cloud

@Hazelcast

www.hazelcast.com

Page 4: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

● Introduction● Caching Architectural Patterns

○ Embedded○ Embedded Distributed○ Client-Server○ Cloud○ Sidecar○ Reverse Proxy○ Reverse Proxy Sidecar

● Summary

Agenda

Page 5: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Why Caching?

● Performance○ Decrease latency○ Reduce load

● Resilience○ High availability○ Lower downtime

Page 6: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Service 1

Service 2 v1

Service 2 v2

Service 1

Service 4 v1

Service 4 v2

Service 4 v3

Ruby

Microservice World

Page 7: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Service 1

Service 2 v1

Service 2 v2

Service 1

Service 4 v1

Service 4 v2

Service 4 v3

Ruby

Microservice World

cache

cache

cache

cache

Page 8: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Service 1

Service 2 v1

Service 2 v2

Service 1

Service 4 v1

Service 4 v2

Service 4 v3

Ruby

Microservice Worldcache

cache

cache

Page 9: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Service 1

Service 2 v1

Service 2 v2

Service 1

Service 4 v1

Service 4 v2

Service 4 v3

Ruby

Microservice World

cache

cache

cache

Page 10: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

● Introduction ● Caching Architectural Patterns

○ Embedded○ Embedded Distributed○ Client-Server○ Cloud○ Sidecar○ Reverse Proxy○ Reverse Proxy Sidecar

● Summary

Agenda

Page 11: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

1. Embedded

Page 12: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Cache

Application

Cache

Request

Embedded Cache

Page 13: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

private ConcurrentHashMap<String, String> cache =new ConcurrentHashMap<>();

private String processRequest(String request) {if (cache.contains(request)) {

return cache.get(request);}String response = process(request);cache.put(request, response);return response;

}

Embedded Cache (Pure Java implementation)

Page 14: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

private ConcurrentHashMap<String, String> cache =new ConcurrentHashMap<>();

private String processRequest(String request) {if (cache.contains(request)) {

return cache.get(request);}String response = process(request);cache.put(request, response);return response;

}

Embedded Cache (Pure Java implementation)

Page 15: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

● No Eviction Policies● No Max Size Limit

(OutOfMemoryError)● No Statistics● No built-in Cache Loaders● No Expiration Time● No Notification Mechanism

Java Collection is not a Cache!

Page 16: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

CacheBuilder.newBuilder().initialCapacity(300).expireAfterAccess(Duration.ofMinutes(10)).maximumSize(1000).build();

Embedded Cache (Java libraries)

Page 17: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Embedded Cache (Java libraries)

CacheBuilder.newBuilder().initialCapacity(300).expireAfterAccess(Duration.ofMinutes(10)).maximumSize(1000).build();

Page 18: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Caching Application Layer

@Servicepublic class BookService {

@Cacheable("books")public String getBookNameByIsbn(String isbn) {

return findBookInSlowSource(isbn);}

}

Page 19: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Caching Application Layer

@Servicepublic class BookService {

@Cacheable("books")public String getBookNameByIsbn(String isbn) {

return findBookInSlowSource(isbn);}

}

Be Careful, Spring uses ConcurrentHashMap by default!

Page 20: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Cache

Application

Cache

Request

Embedded Cache

Page 21: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

1*. Embedded Distributed

Page 22: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Application

Load Balancer

Cache

Cache

RequestHazelcast

Cluster

Embedded Distributed Cache

Page 23: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

@Configurationpublic class HazelcastConfiguration {

@BeanCacheManager cacheManager() {

return new HazelcastCacheManager(Hazelcast.newHazelcastInstance());

}

}

Embedded Distributed Cache (Spring with Hazelcast)

Page 24: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

DEMO

Page 25: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Hazelcast Discovery Plugins

Page 26: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Hazelcast Discovery Plugins

Page 27: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Hazelcast Discovery Plugins

Page 28: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Application

Load Balancer

Cache

Cache

Request

Embedded Distributed Cache

Hazelcast Cluster

Page 29: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Embedded Cache

Pros Cons

● Simple configuration / deployment

● Low-latency data access● No separate Ops Team needed

● Not flexible management (scaling, backup)

● Limited to JVM-based applications

● Data collocated with applications

Page 30: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

● Introduction ● Caching Architectural Patterns

○ Embedded ○ Embedded Distributed ○ Client-Server○ Cloud○ Sidecar○ Reverse Proxy○ Reverse Proxy Sidecar

● Summary

Agenda

Page 31: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

2. Client-Server

Page 32: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cache Server

Client-Server Cache

Page 33: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cache Server

Client-Server Cache

Page 34: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cache Server

Client-Server CacheSeparate Management:

● backups● (auto) scaling● security

Ops Team

Page 35: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cache Server

Client-Server Cache

Page 36: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cache Server

Client-Server Cache

Page 37: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Client-Server Cache

Page 38: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Client-Server Cache

Page 39: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Client-Server Cache

$ ./start.sh

Starting Hazelcast Cache Server (standalone)

Page 40: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Client-Server CacheStarting Hazelcast Cache Server (Kubernetes)

$ helm install hazelcast/hazelcast

Page 41: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Client-Server Cache

Hazelcast Client (Kubernetes):

@Configurationpublic class HazelcastClientConfiguration {

@BeanCacheManager cacheManager() {

ClientConfig clientConfig = new ClientConfig();clientConfig.getNetworkConfig().getKubernetesConfig()

.setEnabled(true);return new HazelcastCacheManager(HazelcastClient

.newHazelcastClient(clientConfig));}

}

Starting Hazelcast Cache Server (Kubernetes)

$ helm install hazelcast/hazelcast

Page 42: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cache Server

Client-Server Cache

Ops Team

Separate Management:● backups● (auto) scaling● security

Page 43: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

2*. Cloud

Page 44: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cloud (Cache as a Service)

Page 45: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cloud (Cache as a Service)Management:

● backups● (auto) scaling● security

Ops Team

Page 46: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cloud (Cache as a Service)Management:

● backups● (auto) scaling● security

Ops Team

Page 47: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer

Application

Request

Cloud (Cache as a Service)

Page 48: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

@Configurationpublic class HazelcastCloudConfiguration {

@BeanCacheManager cacheManager() {

ClientConfig clientConfig = new ClientConfig();clientConfig.getNetworkConfig().getCloudConfig()

.setEnabled(true)

.setDiscoveryToken("KSXFDTi5HXPJGR0wRAjLgKe45tvEEhd");clientConfig.setGroupConfig(

new GroupConfig("test-cluster", "b2f984b5dd3314"));

return new HazelcastCacheManager(HazelcastClient.newHazelcastClient(clientConfig));

}}

Cloud (Cache as a Service)

Page 49: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

DEMOcloud.hazelcast.com

Page 50: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Client-Server (Cloud) Cache

Pros

● Data separate from applications● Separate management (scaling,

backup)● Programming-language agnostic

Cons

● Separate Ops effort● Higher latency● Server network requires

adjustment (same region, same VPC)

Page 51: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

● Introduction ● Caching Architectural Patterns

○ Embedded ○ Embedded Distributed ○ Client-Server ○ Cloud ○ Sidecar○ Reverse Proxy○ Reverse Proxy Sidecar

● Summary

Agenda

Page 52: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

3. Sidecar

Page 53: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Kubernetes Service(Load Balancer)

Request

Kubernetes POD

Application Container

Cache Container

Application Container

Cache Container

Kubernetes POD

Sidecar Cache

Hazelcast Cluster

Page 54: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Sidecar Cache

Similar to Embedded:● the same physical machine● the same resource pool● scales up and down together● no discovery needed (always localhost)

Similar to Client-Server:● different programming language● uses cache client to connect● clear isolation between app and cache

Page 55: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

@Configurationpublic class HazelcastSidecarConfiguration {

@BeanCacheManager cacheManager() {

ClientConfig clientConfig = new ClientConfig();clientConfig.getNetworkConfig()

.addAddress("localhost:5701");return new HazelcastCacheManager(HazelcastClient

.newHazelcastClient(clientConfig));}

}

Sidecar Cache

Page 56: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Sidecar Cache

apiVersion: apps/v1kind: Deployment...spec:template:

spec:containers:

- name: applicationimage: leszko/application

- name: hazelcastimage: hazelcast/hazelcast

Page 57: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Sidecar Cache

Pros Cons

● Simple configuration● Programming-language agnostic● Low latency● Some isolation of data and

applications

● Limited to container-based environments

● Not flexible management (scaling, backup)

● Data collocated with application PODs

Page 58: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

● Introduction ● Caching Architectural Patterns

○ Embedded ○ Embedded Distributed ○ Client-Server ○ Cloud ○ Sidecar ○ Reverse Proxy○ Reverse Proxy Sidecar

● Summary

Agenda

Page 59: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

4. Reverse Proxy

Page 60: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Application

Load Balancer Cache

Application

Request

Reverse Proxy Cache

Page 61: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Reverse Proxy Cache

http {...proxy_cache_path /data/nginx/cache

keys_zone=one:10m;...

}

Page 62: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

● Only for HTTP● Not distributed● No High Availability● Data stored on the disk

NGINX Reverse Proxy Cache Issues

Page 63: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

NGINX Reverse Proxy Cache Issues

● Only for HTTP● Not distributed● No High Availability● Data stored on the disk

Page 64: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

4*. Reverse Proxy Sidecar

Page 65: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Kubernetes Service(Load Balancer)

Request

Kubernetes POD

Application Container

Reverse Proxy Cache Container

Application Container

Reverse Proxy Cache Container

Kubernetes POD

Reverse Proxy Sidecar Cache

Hazelcast Cluster

Page 66: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous
Page 67: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Good

Page 68: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Reverse Proxy Sidecar Cache

Service 1

Service 2 v1

Service 2 v2

Service 1

Service 4 v1

Service 4 v2

Service 4 v3

Ruby

Page 69: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Reverse Proxy Sidecar Cache

Service 1

Service 2 v1

Service 2 v2

Service 1

Service 4 v1

Service 4 v2

Service 4 v3

Ruby

Page 70: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Reverse Proxy Sidecar Cache

apiVersion: apps/v1kind: Deployment...spec:template:

spec:initContainers:

- name: init-networkingimage: leszko/init-networking

containers:- name: caching-proxy

image: leszko/caching-proxy- name: application

image: leszko/application

Page 71: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Reverse Proxy Sidecar Cache

Service 1

Service 2 v1

Service 2 v2

Service 1

Service 4 v1

Service 4 v2

Service 4 v3

Ruby

Page 72: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous
Page 73: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Reverse Proxy Sidecar Cache (Istio)

Page 74: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Bad

Page 75: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous
Page 76: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Reverse Proxy Cache

@CacheEvict(value = "someValue", allEntries = true)public void evictAllCacheValues() {}

Application Cache:

Page 77: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Reverse Proxy Cache

@CacheEvict(value = "someValue", allEntries = true)public void evictAllCacheValues() {}

Application Cache:

Proxy Cache:

http {...location / {

add_header Cache-Control public;expires 86400;etag on;

}}

Page 78: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Reverse Proxy (Sidecar) Cache

Pros Cons

● Configuration-based (no need to change applications)

● Programming-language agnostic● Consistent with containers and

microservice world

● Difficult cache invalidation● No mature solutions yet● Protocol-based (e.g. works only

with HTTP)

Page 79: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

● Introduction ● Caching Architectural Patterns

○ Embedded ○ Embedded Distributed ○ Client-Server ○ Cloud ○ Sidecar ○ Reverse Proxy ○ Reverse Proxy Sidecar

● Summary

Agenda

Page 80: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Summary

Page 81: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

Page 82: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

no

Page 83: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

Reverse Proxy

no

no

Page 84: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

Reverse ProxyReverse Proxy Sidecar

no

yes no

Page 85: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

Reverse ProxyReverse Proxy Sidecar

lot of data?security restrictions?

yes no

yes no

Page 86: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

Reverse ProxyReverse Proxy Sidecar

lot of data?security restrictions?

language-agnostic? containers?

yes no

yes nono

Page 87: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

Reverse ProxyReverse Proxy Sidecar

lot of data?security restrictions?

language-agnostic? containers?

Embedded (Distributed)

yes no

yes no

no

no

Page 88: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

Reverse ProxyReverse Proxy Sidecar

lot of data?security restrictions?

language-agnostic? containers?

Embedded (Distributed)Sidecar

yes no

yes

yes no

no

no

Page 89: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

Reverse ProxyReverse Proxy Sidecar

lot of data?security restrictions?

language-agnostic? containers?

Embedded (Distributed)Sidecar

cloud?

yes no

yes

yes

yes no

no

no

Page 90: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

Reverse ProxyReverse Proxy Sidecar

lot of data?security restrictions?

language-agnostic? containers?

Embedded (Distributed)Sidecar

cloud?

Client-Server

yes no

yes

yes

yes no

nono

no

Page 91: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

application-aware?

containers?

Reverse ProxyReverse Proxy Sidecar

lot of data?security restrictions?

language-agnostic? containers?

Embedded (Distributed)Sidecar

cloud?

Client-ServerCloud

yes no

yes

yes yes

yes no

nono

no

Page 92: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Resources

● Hazelcast Sidecar Container Pattern: https://hazelcast.com/blog/hazelcast-sidecar-container-pattern/

● Hazelcast Reverse Proxy Sidecar Caching Prototype: https://github.com/leszko/caching-injector

● Caching Best Practices: https://vladmihalcea.com/caching-best-practices/● NGINX HTTP Reverse Proxy Caching:

https://www.nginx.com/resources/videos/best-practices-for-caching/

Page 93: Where is my cache? Architectural patterns for caching ... is my cache...microservices by example Rafał Leszko Cloud Software Engineer Hazelcast. ... Author of the book "Continuous

Thank You!

Rafał Leszko@RafalLeszko