SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
2.
About me
● Cloud-Native Team Lead 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
3.
About Hazelcast
● Distributed Company
● Open Source Software
● 140+ Employees
● Products:
○ Hazelcast IMDG
○ Hazelcast Jet
○ Hazelcast Cloud
@Hazelcast
www.hazelcast.com
14.
● 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!
17.
Caching Application Layer
@Service
public class BookService {
@Cacheable("books")
public String getBookNameByIsbn(String isbn) {
return findBookInSlowSource(isbn);
}
}
18.
Caching Application Layer
@Service
public class BookService {
@Cacheable("books")
public String getBookNameByIsbn(String isbn) {
return findBookInSlowSource(isbn);
}
}
Be Careful, Spring uses ConcurrentHashMap by default!
19.
Embedded Cache
Application
Kubernetes
Service
Cache
Application
Cache
Request
Kubernetes Pod
Kubernetes Pod
25.
Embedded Distributed Cache
Application
Application
Kubernetes
Service
Cache
Cache
Request
Hazelcast
Cluster
Kubernetes Pod
Kubernetes Pod
26.
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
29.
Application
Kubernetes
Service
Application
Request
Cache Server
StatefulSet
Client-Server Cache
Kubernetes Pod
Kubernetes Pod
30.
Client-Server Cache
Application
Kubernetes
Service
Application
Request
Cache Server
StatefulSet
Kubernetes Pod
Kubernetes Pod
31.
Client-Server Cache
Separate Management:
● backups
● (auto) scaling
● security
Ops Team
Application
Kubernetes
Service
Application
Request
Cache Server
StatefulSet
Kubernetes Pod
Kubernetes Pod
32.
Client-Server Cache
Application
Kubernetes
Service
Application
Request
Cache Server
StatefulSet
Kubernetes Pod
Kubernetes Pod
33.
Client-Server Cache
Application
Kubernetes
Service
Application
Request
Cache Server
StatefulSet
Kubernetes Pod
Kubernetes Pod
37.
Client-Server Cache
Hazelcast Client
@Configuration
public class HazelcastClientConfiguration {
@Bean
CacheManager cacheManager() {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().getKubernetesConfig()
.setEnabled(true);
return new HazelcastCacheManager(HazelcastClient
.newHazelcastClient(clientConfig));
}
}
Starting Hazelcast Cache Server
$ helm install hazelcast/hazelcast
38.
Client-Server Cache
Separate Management:
● backups
● (auto) scaling
● security
Ops Team
Application
Kubernetes
Service
Application
Request
Cache Server
StatefulSet
Kubernetes Pod
Kubernetes Pod
40.
Application
Kubernetes
Service
Application
Request
Cloud (Cache as a Service)
Kubernetes Pod
Kubernetes Pod
41.
Cloud (Cache as a Service)
Management:
● backups
● (auto) scaling
● security
Ops Team
Application
Kubernetes
Service
Application
Request
Kubernetes Pod
Kubernetes Pod
42.
Cloud (Cache as a Service)
Management:
● backups
● (auto) scaling
● security
Ops Team
Application
Kubernetes
Service
Application
Request
Kubernetes Pod
Kubernetes Pod
43.
Cloud (Cache as a Service)
Application
Kubernetes
Service
Application
Request
Kubernetes Pod
Kubernetes Pod
44.
@Configuration
public class HazelcastCloudConfiguration {
@Bean
CacheManager 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)
45.
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)
48.
Kubernetes Service
Request
Hazelcast
Cluster
Kubernetes POD
Application Container
Cache Container
Application Container
Cache Container
Kubernetes POD
Sidecar Cache
49.
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
50.
@Configuration
public class HazelcastSidecarConfiguration {
@Bean
CacheManager cacheManager() {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig()
.addAddress("localhost:5701");
return new HazelcastCacheManager(HazelcastClient
.newHazelcastClient(clientConfig));
}
}
Sidecar Cache
52.
Sidecar Cache
Pros Cons
● Simple configuration
● Programming-language
agnostic
● Low latency
● Some isolation of data and
applications
● Not flexible management
(scaling, backup)
● Data collocated with
application PODs
70.
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)
75.
application-aware?
Reverse Proxy
no
no
early adopter?
76.
application-aware?
Reverse Proxy
Reverse Proxy
Sidecar
no
yes no
early adopter?
77.
application-aware?
Reverse Proxy
Reverse Proxy
Sidecar
lot of data?
security restrictions?
yes no
yes no
early adopter?
78.
application-aware?
Reverse Proxy
Reverse Proxy
Sidecar
lot of data?
security restrictions?
language-agnostic?
yes no
yes no
no
early adopter?
79.
application-aware?
Reverse Proxy
Reverse Proxy
Sidecar
lot of data?
security restrictions?
language-agnostic?
Embedded
(Distributed)
yes no
yes no
no
no
early adopter?
80.
application-aware?
Reverse Proxy
Reverse Proxy
Sidecar
lot of data?
security restrictions?
language-agnostic?
Embedded
(Distributed)
Sidecar
yes no
yes
yes no
no
no
early adopter?
81.
application-aware?
Reverse Proxy
Reverse Proxy
Sidecar
lot of data?
security restrictions?
language-agnostic?
Embedded
(Distributed)
Sidecar
cloud?
yes no
yes
yes
yes no
no
no
early adopter?
82.
application-aware?
Reverse Proxy
Reverse Proxy
Sidecar
lot of data?
security restrictions?
language-agnostic?
Embedded
(Distributed)
Sidecar
cloud?
Client-Server
yes no
yes
yes
yes no
no
no
no
early adopter?
83.
application-aware?
Reverse Proxy
Reverse Proxy
Sidecar
lot of data?
security restrictions?
language-agnostic?
Embedded
(Distributed)
Sidecar
cloud?
Client-Server
Cloud
yes no
yes
yes yes
yes no
no
no
no
early adopter?