SlideShare uma empresa Scribd logo
1 de 65
Baixar para ler offline
Microservice Message
Routing on Kubernetes
Frans van Buul
AxonIQ
About me About this presentation
Introductions
• Evangelist at AxonIQ, the new
company around Axon Framework.
• Prior roles
• Presales architect for Hewlett
Packard / Fortify
• Java developer at Trifork and others
• Security auditor at PwC
• Why microservices? Why
Kubernetes?
• A tiny sample app.
• Splitting that up and deploying it as
message-exchanging microservices
on Kubernetes.
Agility Scalability
Why microservices?
• Deploy new business
functionality rapidly.
• Agile, Scrum, DevOps, ….
• Have the ability to scale out
as business demand grows.
(and why not a simple monolith?)
Why Kubernetes?
We want to deploy
microservices –
many of them
They need isolation –
but no separate
machines
So use containers –
Docker being
standard choice.
How to manage running
many containers, their
connections, load
balancing, scaling etc.?
Pods
Containers
Kubernetes
overview
Kubernetes cluster
Worker node
(VM)
Worker node
(VM)
Worker node
(VM)
Worker node
(VM)
Install yourself, use Minikube, managed through GCP, AWS or Azure,
or use Pivotal's PKS
Workload +
Controller
Services Volumes
Super Simple Sample System:
Gift Cards
• Gift cards get issued at
a certain initial value.
• Each time they are
used to buy something
("redeemed") the
remaining value is
adjusted.
https://github.com/AxonIQ/giftcard-demo-series
Data store
Monolith
GiftCard system
Browser
Data store
Monolith
GiftCard system
Browser
How to transform our monolith into a agile, scalable,
microservices system running on Kubernetes?
1. Decide on component split. 2. Requirements for messaging
between the components?
3. Practical implementation
with Axon Framework, AxonHub, Spring Boot, Docker, Kubernetes, Google Cloud Platform
Data store
Monolith
GiftCard system
Browser
Data store
Business
Logic
Browser GUI
This is still a very broad
functionality (as the system
grows). Not micro.
Data store
Business
Logic
Browser GUI
Data
Access
This doesn't offer clear advantages.
It has very clear disadvantages.
CRUD-type operations,
probably over
JSON/HTTP
Native SQL or NoSQL
database commands
Data store
Business
Logic
Browser GUI
Data storeRedeemBrowser GUI
Issue
Report
Actual agility and scalability will be limited by having the
single data store.
Let's look at 2 pretty old ideas
… that are really useful in this context.
Idea Advantages
Command-Query Responsibility Segregation (CQRS)
• Separate datastores for processing
commands (changing state) vs.
queries (providing info).
• Query simplicity
• Optimal technology choice
• Easily scalable query side.
• Less workload on command side.
Command
handlers
Query
handlers
Data storeData store
Events
UI
Idea Advantages
Domain-Driven Design (DDD) and Aggregates
• Use DDD to align your system
architecture with the domain.
• Use DDD's concept of "Aggregate"
to create consistency boundaries
inside a model.
• Broadly: having your microservices
align with a domain model helps
make them independently
evolvable.
• Aggregates help size command-
side microservices:
• 2 aggregates should never "have to
be" in the same service
• 1 aggregate should not be "spread
across" multiple services
Data store
Business
Logic
Browser GUI
Data store
GiftCard
Aggregate
Browser GUI
Data store
GiftCard
Report
Queries
Commands
Events
Data store
GiftCard
Aggregate
Browser GUI
Data store
GiftCard
Report
Of course we want to
scale this out now!
How to set up actual
exchange of messages?
Queries
Commands
Events
Message requirements
Generic requirements to make this work at scale:
• Fast, efficient, asynchronous
• Some form of load balancing
• Dynamic scaling of nodes
There are also a number of specific requirements for the 3
message stereotypes command, event and query!
Command messages
• Route to a single handler
instance (load balancing)
• Associated response
required by client
(success/failure).
• Use consistent routing
based on aggregate id
Event messages
• In this case, each event
should lead to 1 update on
data store (competing
consumer).
Event messages
• The general rule: handled
once by every logical event
handler.
Event messages
• The general rule: handled
once by every logical event
handler.
• Parallel processing is
desirable, but should follow a
sequencing policy.
Event stream
1 2 3 4 1 2
3
4
• "3" may get processed before "2"
• If "2" is "Create Card X" and "3" is
"Redeem Card X" this may fail
Event messages
• The general rule: handled
once by every logical event
handler.
• Parallel processing is
desirable, but should follow a
sequencing policy.
• Event replay is a very
convenient feature to
initialize new read models.
What if this is
introduced while the
system is already in
use?
Query messages
• Route to a single handler
instance (load balancing)
• Associated response
required by client.
• More advanced query
patterns could also occur
(scatter-gather).
Generic Stereotype-specific
Message requirements
• Fast, efficient, asynchronous
• Some form of load balancing
• Dynamic scaling of nodes
• Commands: single
execution consistent
routing, responses
• Events: processed once per
logical handler, sequencing
policy, no responses, replay
• Queries: load balancing,
responses, usually (not
always) executed once.
Data store
Monolith
GiftCard system
Browser
How to transform our monolith into a scalable, agile
microservices system running on Kubernetes?
1. How to break it up? 2. Requirements for messaging
between the components?
3. Practical implementation
with Axon Framework, AxonHub, Spring Boot, Docker, Kubernetes, Google Cloud Platform
Axon Framework
• Open source Java Framework.
• Started 7 years ago.
• 800k+ downloads, 50% of which in the past 6 months.
• Started out as "CQRS Framework", currently used a lot for
microservices.
• Key principle: location transparency
Location transparency in Axon
Application's
@CommandHandler
methods (GiftCard Aggregate)
<<interface>>
CommandBus
register to
<<class>>
SimpleCommandBus
implements
Commands as illustration – Queries and Events work similarly
<<class>>
AsyncCommandBus
implements
<<class>>
DistributedCommandBus
Code that needs to execute a
commands (GiftCard GUI)
send to
send to
implements
Practical distribution with Axon
Commands Events Queries
Until recently
SpringCloud + HTTP
or
JGroups
Either AMQP
or
tracking a database table
No standard
functionality; typically
custom REST interface
with HTTP load
balancing.
Complex to set up correctly.
Doesn't meet all requirements.
Practical distribution with Axon
Commands Events Queries
SpringCloud + HTTP
or
JGroups
Either AMQP
or
tracking a database table
No standard
functionality; typically
custom REST interface
with HTTP load
balancing
or
AxonHubCommandBus
or
AxonHubEventBus
or
AxonHubQueryBus
AxonHub essentials
• Server system, together with open source client/driver.
• Unified messaging for all 3 stereotypes
• Intelligent: near-zero configuration
How does it work?
When an application has an
AxonHub*Bus, two things happen:
1. When that application puts a
message on the bus, it will be
sent to AxonHub for further
processing.
2. The application will actively
inform AxonHub about the
@CommandHandlers,
@QueryHandlers and
@EventHandlers it has.
In combination with
• AxonHub's understanding of
message meta-data and routing
patterns,
• 2-way gRPC connections
this allows fully automatic routing
and monitoring / management
functionality.
AxonHub and AxonDB
• Events go through AxonHub
doesn't store events itself – it
needs an event store for that.
• AxonDB is AxonIQ built-for-
purpose event store.
Axon
Hub
Axon
DB
Kubernetes deployment
• gc-command
• gc-query
• gc-gui
All 3 are standard Kubernetes
"deployments" of a Pod with a
single Docker container. Pods are
ephemeral.
• axonhub
• axondb
Each need to operate as a cluster for HA
Won't work as a "deployments"
Instead, using "StatefulSet".
- Pods get identity (network, storage)
- Scaled up and down sequentially
Deploying gc-command
Dockerfile
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD gc-command-1.0.jar app.jar
ADD application.properties .
ENTRYPOINT ["java","-jar","/app.jar"]
application.properties
axoniq.axonhub.servers=axonhub.default.svc.cluster.local
When creating the Kubernetes StatefulSet,
this DNS SRV entry will be created and point
to all nodes of the cluster.
Deploying gc-command
Pushing this to Google Kubernetes Engine via Google Container
Repository:
docker build -t gc-command .
docker tag gc-command eu.gcr.io/giftcard-distributed/gc-command
docker push eu.gcr.io/giftcard-distributed/gc-command
kubectl run gc-command --image eu.gcr.io/giftcard-distributed/gc-
command --replicas=1
axonhub.yaml
apiVersion: v1
kind: Service
metadata:
name: axonhub
labels:
app: axonhub
spec:
ports:
- port: 8124
name: grpc
targetPort: 8124
clusterIP: None
selector:
app: axonhub
---
apiVersion: v1
kind: Service
metadata:
name: axonhub-gui
labels:
app: axonhub
spec:
ports:
- port: 8024
name: gui
targetPort: 8024
selector:
app: axonhub
type: LoadBalancer
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: axonhub
spec:
serviceName: "axonhub"
replicas: 3
selector:
matchLabels:
app: axonhub
template:
metadata:
labels:
app: axonhub
spec:
containers:
- name: axonhub
image: eu.gcr.io…
ports:
- containerPort: 8124
protocol: TCP
name: grpc
- containerPort: 8024
protocol: TCP
name: gui
readinessProbe:
…
AxonHub gRPC port: headless service, all
instances registered in DNS by Kubernetes
AxonHub management GUI: behind HTTP
load balancer
Switching to live demo now
(but there are some slides after this one as backup)
Scaling out
Demo
Microservice message routing on Kubernetes
Microservice message routing on Kubernetes
Microservice message routing on Kubernetes
Microservice message routing on Kubernetes
Microservice message routing on Kubernetes

Mais conteúdo relacionado

Mais procurados

Azure SQL Database
Azure SQL DatabaseAzure SQL Database
Azure SQL Databaserockplace
 
Apolicy achieving least privilege access in kubernetes - https://apolicy.io/
Apolicy   achieving least privilege access in kubernetes - https://apolicy.io/Apolicy   achieving least privilege access in kubernetes - https://apolicy.io/
Apolicy achieving least privilege access in kubernetes - https://apolicy.io/joanwlevin
 
ZCloud Consensus on Hardware for Distributed Systems
ZCloud Consensus on Hardware for Distributed SystemsZCloud Consensus on Hardware for Distributed Systems
ZCloud Consensus on Hardware for Distributed SystemsGokhan Boranalp
 
Tom Grey - Google Cloud Platform
Tom Grey - Google Cloud PlatformTom Grey - Google Cloud Platform
Tom Grey - Google Cloud PlatformFondazione CUOA
 
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with MicroservicesThe 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with MicroservicesLightbend
 
Introduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationIntroduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationAndrew Siemer
 
Cloud for Kubernetes : Session4
Cloud for Kubernetes : Session4Cloud for Kubernetes : Session4
Cloud for Kubernetes : Session4WhaTap Labs
 
Event Sourcing in less than 20 minutes - With Akka and Java 8
Event Sourcing in less than 20 minutes - With Akka and Java 8Event Sourcing in less than 20 minutes - With Akka and Java 8
Event Sourcing in less than 20 minutes - With Akka and Java 8J On The Beach
 
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...IT Arena
 
Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...
Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...
Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...HostedbyConfluent
 
Introduction to Windows Azure and Windows Azure SQL Database
Introduction to Windows Azure and Windows Azure SQL DatabaseIntroduction to Windows Azure and Windows Azure SQL Database
Introduction to Windows Azure and Windows Azure SQL DatabaseVikas Sahni
 
Microservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got HereMicroservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got HereLightbend
 
Confluent Enterprise Datasheet
Confluent Enterprise DatasheetConfluent Enterprise Datasheet
Confluent Enterprise Datasheetconfluent
 
AWS Study Group - Chapter 09 - Storage Option [Solution Architect Associate G...
AWS Study Group - Chapter 09 - Storage Option [Solution Architect Associate G...AWS Study Group - Chapter 09 - Storage Option [Solution Architect Associate G...
AWS Study Group - Chapter 09 - Storage Option [Solution Architect Associate G...QCloudMentor
 
Siddhi: A Second Look at Complex Event Processing Implementations
Siddhi: A Second Look at Complex Event Processing ImplementationsSiddhi: A Second Look at Complex Event Processing Implementations
Siddhi: A Second Look at Complex Event Processing ImplementationsSrinath Perera
 
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Lucas Jellema
 
DEVNET-1140 InterCloud Mapreduce and Spark Workload Migration and Sharing: Fi...
DEVNET-1140	InterCloud Mapreduce and Spark Workload Migration and Sharing: Fi...DEVNET-1140	InterCloud Mapreduce and Spark Workload Migration and Sharing: Fi...
DEVNET-1140 InterCloud Mapreduce and Spark Workload Migration and Sharing: Fi...Cisco DevNet
 
DDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCDDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCAndy Butland
 

Mais procurados (20)

Azure SQL Database
Azure SQL DatabaseAzure SQL Database
Azure SQL Database
 
Apolicy achieving least privilege access in kubernetes - https://apolicy.io/
Apolicy   achieving least privilege access in kubernetes - https://apolicy.io/Apolicy   achieving least privilege access in kubernetes - https://apolicy.io/
Apolicy achieving least privilege access in kubernetes - https://apolicy.io/
 
ZCloud Consensus on Hardware for Distributed Systems
ZCloud Consensus on Hardware for Distributed SystemsZCloud Consensus on Hardware for Distributed Systems
ZCloud Consensus on Hardware for Distributed Systems
 
Tom Grey - Google Cloud Platform
Tom Grey - Google Cloud PlatformTom Grey - Google Cloud Platform
Tom Grey - Google Cloud Platform
 
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with MicroservicesThe 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
 
Introduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationIntroduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregation
 
Cloud for Kubernetes : Session4
Cloud for Kubernetes : Session4Cloud for Kubernetes : Session4
Cloud for Kubernetes : Session4
 
Event Sourcing in less than 20 minutes - With Akka and Java 8
Event Sourcing in less than 20 minutes - With Akka and Java 8Event Sourcing in less than 20 minutes - With Akka and Java 8
Event Sourcing in less than 20 minutes - With Akka and Java 8
 
Securing your data with Azure SQL DB
Securing your data with Azure SQL DBSecuring your data with Azure SQL DB
Securing your data with Azure SQL DB
 
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
 
Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...
Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...
Redis and Kafka - Simplifying Advanced Design Patterns within Microservices A...
 
Introduction to Windows Azure and Windows Azure SQL Database
Introduction to Windows Azure and Windows Azure SQL DatabaseIntroduction to Windows Azure and Windows Azure SQL Database
Introduction to Windows Azure and Windows Azure SQL Database
 
Microservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got HereMicroservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got Here
 
Confluent Enterprise Datasheet
Confluent Enterprise DatasheetConfluent Enterprise Datasheet
Confluent Enterprise Datasheet
 
AWS Study Group - Chapter 09 - Storage Option [Solution Architect Associate G...
AWS Study Group - Chapter 09 - Storage Option [Solution Architect Associate G...AWS Study Group - Chapter 09 - Storage Option [Solution Architect Associate G...
AWS Study Group - Chapter 09 - Storage Option [Solution Architect Associate G...
 
Siddhi: A Second Look at Complex Event Processing Implementations
Siddhi: A Second Look at Complex Event Processing ImplementationsSiddhi: A Second Look at Complex Event Processing Implementations
Siddhi: A Second Look at Complex Event Processing Implementations
 
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
 
DEVNET-1140 InterCloud Mapreduce and Spark Workload Migration and Sharing: Fi...
DEVNET-1140	InterCloud Mapreduce and Spark Workload Migration and Sharing: Fi...DEVNET-1140	InterCloud Mapreduce and Spark Workload Migration and Sharing: Fi...
DEVNET-1140 InterCloud Mapreduce and Spark Workload Migration and Sharing: Fi...
 
DDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCDDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVC
 
Microservices deck
Microservices deckMicroservices deck
Microservices deck
 

Semelhante a Microservice message routing on Kubernetes

AxonHub beta release 11 april 2018
AxonHub beta release 11 april 2018AxonHub beta release 11 april 2018
AxonHub beta release 11 april 2018Frans van Buul
 
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon Web Services Korea
 
SpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud ComputingSpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud ComputingSpringPeople
 
Beyond REST and RPC: Asynchronous Eventing and Messaging Patterns
Beyond REST and RPC: Asynchronous Eventing and Messaging PatternsBeyond REST and RPC: Asynchronous Eventing and Messaging Patterns
Beyond REST and RPC: Asynchronous Eventing and Messaging PatternsClemens Vasters
 
Stay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolithStay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolithMarkus Eisele
 
HPC and cloud distributed computing, as a journey
HPC and cloud distributed computing, as a journeyHPC and cloud distributed computing, as a journey
HPC and cloud distributed computing, as a journeyPeter Clapham
 
Modern Architecture in the Cloud of 2018
Modern Architecture in the Cloud of 2018Modern Architecture in the Cloud of 2018
Modern Architecture in the Cloud of 2018Marius Zaharia
 
170215 msa intro
170215 msa intro170215 msa intro
170215 msa introSonic leigh
 
Amazon AWS vs Azure Cloud vs Kubernetes
Amazon AWS vs Azure Cloud vs KubernetesAmazon AWS vs Azure Cloud vs Kubernetes
Amazon AWS vs Azure Cloud vs KubernetesStridely Solutions
 
Estimating the Total Costs of Your Cloud Analytics Platform
Estimating the Total Costs of Your Cloud Analytics PlatformEstimating the Total Costs of Your Cloud Analytics Platform
Estimating the Total Costs of Your Cloud Analytics PlatformDATAVERSITY
 
Build cloud native solution using open source
Build cloud native solution using open source Build cloud native solution using open source
Build cloud native solution using open source Nitesh Jadhav
 
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин ВладевPlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин ВладевPlovDev Conference
 
Cloud technology with practical knowledge
Cloud technology with practical knowledgeCloud technology with practical knowledge
Cloud technology with practical knowledgeAnshikaNigam8
 
Reference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to KubernetesReference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to KubernetesRakesh Gujjarlapudi
 
Kubernetes Infra 2.0
Kubernetes Infra 2.0Kubernetes Infra 2.0
Kubernetes Infra 2.0Deepak Sood
 
Do You Need A Service Mesh?
Do You Need A Service Mesh?Do You Need A Service Mesh?
Do You Need A Service Mesh?NGINX, Inc.
 
Java Agile ALM: OTAP and DevOps in the Cloud
Java Agile ALM: OTAP and DevOps in the CloudJava Agile ALM: OTAP and DevOps in the Cloud
Java Agile ALM: OTAP and DevOps in the CloudMongoDB
 
Breaking the Monolith Road to Containers
Breaking the Monolith Road to ContainersBreaking the Monolith Road to Containers
Breaking the Monolith Road to ContainersAmazon Web Services
 
Bluemix paas 기반 saas 개발 사례
Bluemix paas 기반 saas 개발 사례Bluemix paas 기반 saas 개발 사례
Bluemix paas 기반 saas 개발 사례uEngine Solutions
 
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...HostedbyConfluent
 

Semelhante a Microservice message routing on Kubernetes (20)

AxonHub beta release 11 april 2018
AxonHub beta release 11 april 2018AxonHub beta release 11 april 2018
AxonHub beta release 11 april 2018
 
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
 
SpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud ComputingSpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud Computing
 
Beyond REST and RPC: Asynchronous Eventing and Messaging Patterns
Beyond REST and RPC: Asynchronous Eventing and Messaging PatternsBeyond REST and RPC: Asynchronous Eventing and Messaging Patterns
Beyond REST and RPC: Asynchronous Eventing and Messaging Patterns
 
Stay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolithStay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolith
 
HPC and cloud distributed computing, as a journey
HPC and cloud distributed computing, as a journeyHPC and cloud distributed computing, as a journey
HPC and cloud distributed computing, as a journey
 
Modern Architecture in the Cloud of 2018
Modern Architecture in the Cloud of 2018Modern Architecture in the Cloud of 2018
Modern Architecture in the Cloud of 2018
 
170215 msa intro
170215 msa intro170215 msa intro
170215 msa intro
 
Amazon AWS vs Azure Cloud vs Kubernetes
Amazon AWS vs Azure Cloud vs KubernetesAmazon AWS vs Azure Cloud vs Kubernetes
Amazon AWS vs Azure Cloud vs Kubernetes
 
Estimating the Total Costs of Your Cloud Analytics Platform
Estimating the Total Costs of Your Cloud Analytics PlatformEstimating the Total Costs of Your Cloud Analytics Platform
Estimating the Total Costs of Your Cloud Analytics Platform
 
Build cloud native solution using open source
Build cloud native solution using open source Build cloud native solution using open source
Build cloud native solution using open source
 
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин ВладевPlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
 
Cloud technology with practical knowledge
Cloud technology with practical knowledgeCloud technology with practical knowledge
Cloud technology with practical knowledge
 
Reference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to KubernetesReference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to Kubernetes
 
Kubernetes Infra 2.0
Kubernetes Infra 2.0Kubernetes Infra 2.0
Kubernetes Infra 2.0
 
Do You Need A Service Mesh?
Do You Need A Service Mesh?Do You Need A Service Mesh?
Do You Need A Service Mesh?
 
Java Agile ALM: OTAP and DevOps in the Cloud
Java Agile ALM: OTAP and DevOps in the CloudJava Agile ALM: OTAP and DevOps in the Cloud
Java Agile ALM: OTAP and DevOps in the Cloud
 
Breaking the Monolith Road to Containers
Breaking the Monolith Road to ContainersBreaking the Monolith Road to Containers
Breaking the Monolith Road to Containers
 
Bluemix paas 기반 saas 개발 사례
Bluemix paas 기반 saas 개발 사례Bluemix paas 기반 saas 개발 사례
Bluemix paas 기반 saas 개발 사례
 
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Microservice message routing on Kubernetes

  • 1. Microservice Message Routing on Kubernetes Frans van Buul AxonIQ
  • 2. About me About this presentation Introductions • Evangelist at AxonIQ, the new company around Axon Framework. • Prior roles • Presales architect for Hewlett Packard / Fortify • Java developer at Trifork and others • Security auditor at PwC • Why microservices? Why Kubernetes? • A tiny sample app. • Splitting that up and deploying it as message-exchanging microservices on Kubernetes.
  • 3. Agility Scalability Why microservices? • Deploy new business functionality rapidly. • Agile, Scrum, DevOps, …. • Have the ability to scale out as business demand grows. (and why not a simple monolith?)
  • 4. Why Kubernetes? We want to deploy microservices – many of them They need isolation – but no separate machines So use containers – Docker being standard choice. How to manage running many containers, their connections, load balancing, scaling etc.?
  • 5. Pods Containers Kubernetes overview Kubernetes cluster Worker node (VM) Worker node (VM) Worker node (VM) Worker node (VM) Install yourself, use Minikube, managed through GCP, AWS or Azure, or use Pivotal's PKS Workload + Controller Services Volumes
  • 6. Super Simple Sample System: Gift Cards • Gift cards get issued at a certain initial value. • Each time they are used to buy something ("redeemed") the remaining value is adjusted.
  • 9. Data store Monolith GiftCard system Browser How to transform our monolith into a agile, scalable, microservices system running on Kubernetes? 1. Decide on component split. 2. Requirements for messaging between the components? 3. Practical implementation with Axon Framework, AxonHub, Spring Boot, Docker, Kubernetes, Google Cloud Platform
  • 11. Data store Business Logic Browser GUI This is still a very broad functionality (as the system grows). Not micro.
  • 12. Data store Business Logic Browser GUI Data Access This doesn't offer clear advantages. It has very clear disadvantages. CRUD-type operations, probably over JSON/HTTP Native SQL or NoSQL database commands
  • 14. Data storeRedeemBrowser GUI Issue Report Actual agility and scalability will be limited by having the single data store.
  • 15. Let's look at 2 pretty old ideas … that are really useful in this context.
  • 16. Idea Advantages Command-Query Responsibility Segregation (CQRS) • Separate datastores for processing commands (changing state) vs. queries (providing info). • Query simplicity • Optimal technology choice • Easily scalable query side. • Less workload on command side. Command handlers Query handlers Data storeData store Events UI
  • 17. Idea Advantages Domain-Driven Design (DDD) and Aggregates • Use DDD to align your system architecture with the domain. • Use DDD's concept of "Aggregate" to create consistency boundaries inside a model. • Broadly: having your microservices align with a domain model helps make them independently evolvable. • Aggregates help size command- side microservices: • 2 aggregates should never "have to be" in the same service • 1 aggregate should not be "spread across" multiple services
  • 19. Data store GiftCard Aggregate Browser GUI Data store GiftCard Report Queries Commands Events
  • 20. Data store GiftCard Aggregate Browser GUI Data store GiftCard Report Of course we want to scale this out now! How to set up actual exchange of messages? Queries Commands Events
  • 21. Message requirements Generic requirements to make this work at scale: • Fast, efficient, asynchronous • Some form of load balancing • Dynamic scaling of nodes There are also a number of specific requirements for the 3 message stereotypes command, event and query!
  • 22. Command messages • Route to a single handler instance (load balancing) • Associated response required by client (success/failure). • Use consistent routing based on aggregate id
  • 23. Event messages • In this case, each event should lead to 1 update on data store (competing consumer).
  • 24. Event messages • The general rule: handled once by every logical event handler.
  • 25. Event messages • The general rule: handled once by every logical event handler. • Parallel processing is desirable, but should follow a sequencing policy. Event stream 1 2 3 4 1 2 3 4 • "3" may get processed before "2" • If "2" is "Create Card X" and "3" is "Redeem Card X" this may fail
  • 26. Event messages • The general rule: handled once by every logical event handler. • Parallel processing is desirable, but should follow a sequencing policy. • Event replay is a very convenient feature to initialize new read models. What if this is introduced while the system is already in use?
  • 27. Query messages • Route to a single handler instance (load balancing) • Associated response required by client. • More advanced query patterns could also occur (scatter-gather).
  • 28. Generic Stereotype-specific Message requirements • Fast, efficient, asynchronous • Some form of load balancing • Dynamic scaling of nodes • Commands: single execution consistent routing, responses • Events: processed once per logical handler, sequencing policy, no responses, replay • Queries: load balancing, responses, usually (not always) executed once.
  • 29. Data store Monolith GiftCard system Browser How to transform our monolith into a scalable, agile microservices system running on Kubernetes? 1. How to break it up? 2. Requirements for messaging between the components? 3. Practical implementation with Axon Framework, AxonHub, Spring Boot, Docker, Kubernetes, Google Cloud Platform
  • 30. Axon Framework • Open source Java Framework. • Started 7 years ago. • 800k+ downloads, 50% of which in the past 6 months. • Started out as "CQRS Framework", currently used a lot for microservices. • Key principle: location transparency
  • 31. Location transparency in Axon Application's @CommandHandler methods (GiftCard Aggregate) <<interface>> CommandBus register to <<class>> SimpleCommandBus implements Commands as illustration – Queries and Events work similarly <<class>> AsyncCommandBus implements <<class>> DistributedCommandBus Code that needs to execute a commands (GiftCard GUI) send to send to implements
  • 32.
  • 33.
  • 34. Practical distribution with Axon Commands Events Queries Until recently SpringCloud + HTTP or JGroups Either AMQP or tracking a database table No standard functionality; typically custom REST interface with HTTP load balancing. Complex to set up correctly. Doesn't meet all requirements.
  • 35. Practical distribution with Axon Commands Events Queries SpringCloud + HTTP or JGroups Either AMQP or tracking a database table No standard functionality; typically custom REST interface with HTTP load balancing or AxonHubCommandBus or AxonHubEventBus or AxonHubQueryBus
  • 36. AxonHub essentials • Server system, together with open source client/driver. • Unified messaging for all 3 stereotypes • Intelligent: near-zero configuration
  • 37. How does it work? When an application has an AxonHub*Bus, two things happen: 1. When that application puts a message on the bus, it will be sent to AxonHub for further processing. 2. The application will actively inform AxonHub about the @CommandHandlers, @QueryHandlers and @EventHandlers it has. In combination with • AxonHub's understanding of message meta-data and routing patterns, • 2-way gRPC connections this allows fully automatic routing and monitoring / management functionality.
  • 38. AxonHub and AxonDB • Events go through AxonHub doesn't store events itself – it needs an event store for that. • AxonDB is AxonIQ built-for- purpose event store. Axon Hub Axon DB
  • 39.
  • 40.
  • 41. Kubernetes deployment • gc-command • gc-query • gc-gui All 3 are standard Kubernetes "deployments" of a Pod with a single Docker container. Pods are ephemeral. • axonhub • axondb Each need to operate as a cluster for HA Won't work as a "deployments" Instead, using "StatefulSet". - Pods get identity (network, storage) - Scaled up and down sequentially
  • 42. Deploying gc-command Dockerfile FROM openjdk:8-jdk-alpine VOLUME /tmp ADD gc-command-1.0.jar app.jar ADD application.properties . ENTRYPOINT ["java","-jar","/app.jar"] application.properties axoniq.axonhub.servers=axonhub.default.svc.cluster.local When creating the Kubernetes StatefulSet, this DNS SRV entry will be created and point to all nodes of the cluster.
  • 43. Deploying gc-command Pushing this to Google Kubernetes Engine via Google Container Repository: docker build -t gc-command . docker tag gc-command eu.gcr.io/giftcard-distributed/gc-command docker push eu.gcr.io/giftcard-distributed/gc-command kubectl run gc-command --image eu.gcr.io/giftcard-distributed/gc- command --replicas=1
  • 44. axonhub.yaml apiVersion: v1 kind: Service metadata: name: axonhub labels: app: axonhub spec: ports: - port: 8124 name: grpc targetPort: 8124 clusterIP: None selector: app: axonhub --- apiVersion: v1 kind: Service metadata: name: axonhub-gui labels: app: axonhub spec: ports: - port: 8024 name: gui targetPort: 8024 selector: app: axonhub type: LoadBalancer --- apiVersion: apps/v1 kind: StatefulSet metadata: name: axonhub spec: serviceName: "axonhub" replicas: 3 selector: matchLabels: app: axonhub template: metadata: labels: app: axonhub spec: containers: - name: axonhub image: eu.gcr.io… ports: - containerPort: 8124 protocol: TCP name: grpc - containerPort: 8024 protocol: TCP name: gui readinessProbe: … AxonHub gRPC port: headless service, all instances registered in DNS by Kubernetes AxonHub management GUI: behind HTTP load balancer
  • 45. Switching to live demo now (but there are some slides after this one as backup)
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.