SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Downloaden Sie, um offline zu lesen
PATTERNS & PRACTICES
MICROSERVICES
Proxy / 

Load Balancer
Web Server
Database Server
Application Server
Web Server
~4 YEARS
Proxy / 

Load Balancer
Web Server
Database Server
Application Server
Web Server Web Server
Application Server
~3 YEARS
Proxy / 

Load Balancer
Web Server
Database Server
Application Server
Web Server Web Server
Application Server
Proxy / 

Load Balancer
Web Server
Application Server
Web Server Web Server
Application Server
Hot
Cold
Database Server
~2 YEARS
Proxy / 

Load Balancer
Web Server
Database Server
Application Server
Web Server Web Server
Application Server
Proxy / 

Load Balancer
Web Server
Application Server
Web Server Web Server
Application Server
Hot
Cold
GLB / DNS
Reporting
Database Server
~2 YEARS
Proxy / 

Load Balancer
Web Server
Database Server
Application Server
Web Server Web Server
Application Server
Proxy / 

Load Balancer
Web Server
Application Server
Web Server Web Server
Application Server
Reporting
Database Server
Hot
Hot
Database Server
GLB / DNS
~2 YEARS
x5
~2 YEARS
~2 YEARS
x2
2 YEARS
W E S L E Y R E I S Z
San Francisco / London / New York
CHAIR QCON
“Loosely coupled Service Oriented
Architecture with Bounded Contexts”


-Adrian Cockcroft, Microservices Thoughtleader
IF EVERY SERVICE HAS TO BE
UPDATED AT THE SAME TIME
IT’S NOT LOOSELY COUPLED
IF YOU HAVE TO KNOW TOO
MUCH ABOUT SURROUNDING
SERVICES YOU DON’T HAVE A
BOUNDED CONTEXT. SEE THE
DOMAIN DRIVEN DESIGN BOOK
BY ERIC EVANS.
Why Microservices?
CONS
PROS
• Monitoring/Logging becomes more 

important than ever.
• You trade code simplicity for operational 

complexity.
• Easy to chase the latest shiny technology / mix
new languages & tech in.
• Another dimension to scale 

the application.
• Easier to have different services use

data persistence most appropriate 

for the use case.
• Easier to reason about moving applications
to the cloud.
• Easier to have a developer understand

the portion of the system and contribute
• Easier to test & deploy a single service.
• Cascading failures can cause 

problems.
• Orchestration can 

become complex
FIRST PRINCIPLES
DevOps Culture,
Evolutionary Architecture, 

Scale Cube & CAP Theorem
MICROSERVICESPATTERNS & PRACTICES
PATTERNS & PRACTICES
Technical, Operational, Cultural
DEVOPS CULTURE IS A MUST
• Rapid provisioning
• Basic monitoring
• Rapid Application
Deployment
http://martinfowler.com/bliki/MicroservicePrerequisites.html
“Signing up for Microservices is signing up
for evolutionary architecture. There’s no point
where you’re just done.” 

-Josh Evans,
Director of Operations Engineering @Netflix
Proxy / 

Load Balancer
Web Server
Database Server
Application Server
Web Server Web Server
Application Server
Proxy / 

Load Balancer
Web Server
Application Server
Web Server Web Server
Application Server
Reporting
Database Server
Hot
Hot
Database Server
GLB / DNS
https://www.infoq.com/presentations/netflix-failure-multiple-regions
SCALE CUBE
X axis - horizontal Scaling
(Scale by Cloning)
Z
axis-DataPartitioning
(ScalebySharding)
Y axis - Functional
Decomposition
(Scale by Splitting)
The CAP theorem is the idea that a distributed computing system is
not able to provide partition tolerance, consistency and availability at
the same time.
MICROSERVICESPATTERNS & PRACTICES
AVAILABILITY/PARTITION TOLERANCE
CONSISTENCY/PARTITION TOLERANCE
CP: Choose Consistency over Availability when your business
requirements dictate atomic reads and writes. Wait for a response
from the partitioned node which could result in a timeout error. The
system can also choose to return an error, depending on the
scenario you desire.
AP: Choose Availability over Consistency when your business
requirements allow for some flexibility around when the data in the
system synchronizes. Return the most recent version of the data you
have, which could be stale. This system state will also accept writes that
can be processed later when the partition is resolved. Availability is also
a compelling option when the system needs to continue to function in
spite of external errors (shopping carts, etc.)
Proxy / 

Load Balancer
Web Server
Database Server
Application Server
Web Server Web Server
Application Server
Proxy / 

Load Balancer
Web Server
Application Server
Web Server Web Server
Application Server
Reporting
Database Server
Hot
Hot
Database Server
GLB / DNS
Evolu&onary Architecture
Scale Cube
CAP Theorem
Microservices is a architecture that conFnues to change
and adapt
Scale Cube consists of an X, Y and Z axes – each
addressing a different approach to scale a service.
The idea that a distributed compuFng system is not able
to provide parFFon tolerance, consistency and availability
at the same Fme.
FIRST PRINCIPLES
Things we need to
understand about as we
plan/scale systems
DevOps is a Must
Microservices is the first architecture post devops culture
shiP
TECHNICAL
Tools, Event Sourcing, CQRS,
Circuit Breaker, Retrys
OPERATIONAL
Observability, Containers, Polyglot
CULTURAL
DevOps Culture, Conway’s Law
MICROSERVICESPATTERNS & PRACTICES
1
2
3
TOOLS
“Everything is a tradeoff just be
intentional about them”
SPINE MODEL
• Needs: 

We are here to satisfy ________
• Values before Principles

We optimize for ________
• Principles before Practices

We leverage _____ to change the system
• Practices before tools

We do _____ to create value
• We have always been Tool users and 

makers. Tools should answer the question:

We use ____ to get our work done.
http://spinemodel.info/explanation/introduction/
Proxy / 

Load Balancer
Web Server
Database Server
Application Server
Web Server Web Server
Application Server
Proxy / 

Load Balancer
Web Server
Application Server
Web Server Web Server
Application Server
Reporting
Database Server
Hot
Hot
Database Server
GLB / DNS
Hot
Hot
GLB / DNS
User Facing Availability

Concerns
Internal Consistency
Concerns
User Facing Availability

Concerns
Internal Consistency
Concerns
Hot
Hot
GLB / DNS
High Reads
High Writes
High Reads
High Writes
Hot
Hot
GLB / DNS
High Reads
High Writes
High Reads
High Writes
https://www.infoq.com/presentations/wix-microservices-devops
EVENT SOURCING
“Yes, I think we should talk about this
again.”
Student
Enroll In 

Workshop
Security Module Student Module Workshop Module
reserveSeat() isAuthorized()
isEligible()
isAvailable()
updateSchedule()
updateSchedule()
ALL SYNCHRONOUS
MUTIABLE STATE!
The fundamental idea of Event Sourcing is that of
ensuring every change to the state of an application
is captured in an event object, and that these event
objects are themselves stored in the sequence they
were applied for the same lifetime as the application
state itself.
- M Fowler
Student
Enroll In 

Workshop
Security Module Student Module Workshop ModuleQueue/Topic
subscribe()
subscribe()
subscribe()
reserveSeat() isAuthorized()
reserveSeat()
ASYNCHRONOUS
IMMUTIABLE STATE!
updateSchedule()
updateSchedule()
Par
Immutable Events
Recreate the exact state
Increase in complexity
Performance / Load tes&ng
Provides a model to think about scalability
Because you have all of the state changes, you have all of
the changes that affected state
No longer doing CRUD. You have calculate the result.
Leverage things like snapshots
You an reply the events across the Enterprise
EVENT SOURCING
The fundamental idea of Event
Sourcing is that of ensuring
every change to the state of an
application is captured in an
event object, and that these
event objects are themselves
stored in the sequence they
were applied for the same
lifetime as the application state
itself.
CQRS
“Decouple queries from Commands
to scale each independently.”
Presentation
Business Logic
DAO Data Storage
Updates / Queries
Command and Query Responsibility Segregation
(CQRS) is a pattern that segregates the operations
that read data (Queries) from the operations that
update data (Commands) by using separate
interfaces.
Presentation
Commands
Data Persistance
Data Storage
Updates (Writes)
Domain Logic
Queries (Reads)
Presentation
Presentation
Commands
Data Persistance
Data Storage
Updates (Writes)
Domain Logic
Queries (Reads)
Presentation
Presentation
Presentation
Presentation
Commands
Data Persistance
Data Storage
Updates (Writes)
Domain Logic
Queries (Reads)
Presentation
Presentation
Presentation
Presentation
Presentation
Presentation
Read Data StoreWrite Data Store
EVENTUAL
CONSISTENCY?
Domain Specific Models
Scale
Tradeoff
Performance
Clean Domain models queried
Scale the reads above the writes
Increased the operaFonal complexity of the data stores
Tune different datastore for different performance needs
CQRS
Command-Query-Responsibility-
Separation (CQRS) separates
query processing from command
processing, which updates
entities using business logic that's
commonly implemented using
event sourcing.
Security
Updates to the model controlled different from the reads
CIRCUIT BREAKER
“Decouple queries from Commands
to scale each independently.”
Service A called B.
TRIPPED
Service B is
Sick, let’s flag is and 

try back in 5min
Service C
Different Instance of
Service B
Service B is
sick. Don’t
send traffic
there for 5
minute
(Tripped)
Service A called B.
OPEN
Service B is
still sick
Service C
Different Instance of
Service B
Service B is
still sick.
Isolate it and
remove from
ELB
Service responds
normally.
Service C
After 5 minutes. Traffic
back to service B.
Closed
set the flag to
closed. Nothing
else to do.

service B
responded
correctly,
Prevents Doomed to Fail
Three states
Prevents Cascading Failures
purpose is to detect external service failures and prevent
the applicaFon from trying to perform an acFon that is
doomed to fail.
Closed (Normal), Open(Tripped), & Half-Open state
Helps prevent cascading failures and improves resiliency.
CIRCUIT BREAKER
Circuit breaker is used to
detect failures and
encapsulates logic of
preventing a failure to reoccur
constantly (during
maintenance, temporary
external system failure or
unexpected system
difficulties).
Part of Hysterix
Part of Nelix OSS library for latency & fault tolerance
RETRY
“Upstream timeout must always be
longer than total downstream 

timeout * retries delay”

-Adrian Cockcroft
Bad Service
Good Service
Edge Service
3s
1s 1s
Fails fast @ 2s
“Upstream timeout must always be
longer than total downstream 

timeout * retries delay”

-Adrian Cockcroft
Budgeted timeout, one retry
Tools
Resiliency PaIerns
Architectural PaIerns to Consider
Don’t start with the tool.
Circuit Breaker, Retry
Event Sourcing & CQRS
TECHNICAL
These are some interesting
technical considerations
with Microservices
TECHNICAL
Getting started, Event Sourcing, CQRS
OPERATIONAL
Observability, Containers, Polyglot
CULTURAL
DevOps Culture, Conway’s Law,
MICROSERVICESPATTERNS & PRACTICES
1
2
3
OBSERVABILITY
In control theory, observability is a
measure for how well internal states of a
system can be inferred by knowledge of
its external outputs.
At a minimum setup
log stash, look at going
an extra step to setup
ELK.
OBSERVABILITY: THINGS TO THINK ABOUT
LOGS
• Need consistent, structured logging
• Logs are not for humans
• Logstash, Elasticsearch, Kibania works 

great
OBSERVABILITY: THINGS TO THINK ABOUT
PROTOCOLS/
TRANSPORT
RPC/HTTP
vs
JSON vs Binary
RPC vs HTTP
JSON vs Binary
• Speed/Performance vs Readability
• Measure serialization, transmission, deserialization 

costs
OBSERVABILITY: THINGS TO THINK ABOUT
How do you
Recreate a failure in
a distributed resilient
environment?
TRACING
Look into:
• Zipkin
• Prometheus
Best way to understand Fanout
https://www.infoq.com/presentations/uber-scalability-services
CONTAINERS
“What do you feel is the most disruptive (or at
least potentially disruptive technology)?”
POLYGLOT
More challenges than they thought…
Observability
Polyglot
Containers
Logging, Service CommunicaFon, Tracking
Containers makes it easier, but observability, logging,
tracking can be more challenging
Low fricFon deployment, Finer-grained execuFon
environments, speed, isolaFon
OPERATIONAL
Microservices simplifies
code. It trades code
complexity for operational
complexity
TECHNICAL
Getting started, Event Sourcing, CQRS
OPERATIONAL
Observability, Containers, Polyglot
CULTURAL
DevOps Culture, Conway’s Law
MICROSERVICESPATTERNS & PRACTICES
1
2
3
CONWAY'S LAW
“Organizations which design systems ... are
constrained to produce designs which are
copies of the communication structures of these
organizations”
-Conway
Model
One size does not fit all
Tradeoff
Organiza&onal Lifecycle Stages
Provides a model to think about scalability
Microservices (funcFon decomposiFon) is AN approach
Each approach has different tradeoffs (For example: as
we’ll find with Y-axis scaling, you may trade code
complexity for organizaFonal complexity)
Different needs at different points of an org’s lifecycle
CONWAY’S LAW
Organizations which design
systems ... are constrained
to produce designs which
are copies of the
communication structures of
these organizations
So what do I wish I knew before
starting the push to Microservices?
Proxy / 

Load Balancer
Web Server
Database Server
Application Server
Web Server Web Server
Application Server
Proxy / 

Load Balancer
Web Server
Application Server
Web Server Web Server
Application Server
Reporting
Database Server
Hot
Hot
Database Server
GLB / DNS
Document Repo
Recruiting
Processing
Boards
Applicants
Recruiting
Processing
Document Repo
Applicants
Applicants
API Gateway
API Gateway
Applicants
Boards
https://www.infoq.com/presentations/netflix-failure-multiple-regions
FIRST PRINCIPLES
MICROSERVICESPATTERNS & PRACTICES
• Have capabilities in your org to do things
like rapidly provision, monitor, and use
rapid deployment.

(DevOPs Culture is a must)
• Accept that the service going to evolve 

(Evolutionary Architecture)
• Handle their own data needs 

(Consistency/Availablity Tradeoffs)
• Be able to scale based on it’s needs

(Scale Cube)
Processing
DevOps Culture,
Evolutionary Architecture, 

Scale Cube & CAP Theorem
TECHNICAL
Spine Model

Event Sourcing/CQRS
Circuit Breaker
Retry
OPERATIONAL
Observability

Containers
Polyglot
CULTURAL
Conway’s Law
MICROSERVICESPATTERNS & PRACTICES Processing
• Have a decision process

(Spine Model)
• Consider using events where it makes sense and
how you might scale commands & queries

(Event Sourcing / CQRS)
• Protect against cascading failures

(Circuit Breaker, Bulkhead)
• “Everything is a tradeoff, do it intentionally” Matt
Ranney (RPC/HTTP, Containers, Polyglot)
• Bootstrap services with organizational capabilities
(Logs, Tracing)
• Beware of Conway’s Law
CONS
PROS
• Monitoring/Logging becomes more 

important than ever.
• You trade code complexity for operational 

complexity.
• Easy to chase the latest shiny technology / mix
new languages & tech in.
• Another dimension to scale 

the application.
• Easier to have different services use

data persistence most appropriate 

for the use case.
• Easier to reason about moving applications
to the cloud.
• Easier to have a developer understand

the portion of the system and contribute
• Easier to test & deploy a single service.
• Cascading failures can cause 

problems.
• Orchestration can 

become complex
“If you don’t end up regretting your early
technology decisions, you probably over
engineered.” - Randy Shoup, Engineering Director @StitchFix
MICROSERVICESPATTERNS & PRACTICES
Wesley Reisz
@wesreisz
wes@c4media.com

Weitere ähnliche Inhalte

Was ist angesagt?

A Modern Data Architecture for Microservices
A Modern Data Architecture for MicroservicesA Modern Data Architecture for Microservices
A Modern Data Architecture for Microservices
Amazon Web Services
 
Building Cloud-Aware Applications
Building Cloud-Aware ApplicationsBuilding Cloud-Aware Applications
Building Cloud-Aware Applications
Chris Haddad
 
Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...
Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...
Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...
Kai Wähner
 

Was ist angesagt? (20)

Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
 
Developing applications with a microservice architecture (svcc)
Developing applications with a microservice architecture (svcc)Developing applications with a microservice architecture (svcc)
Developing applications with a microservice architecture (svcc)
 
Java micro-services
Java micro-servicesJava micro-services
Java micro-services
 
A Modern Data Architecture for Microservices
A Modern Data Architecture for MicroservicesA Modern Data Architecture for Microservices
A Modern Data Architecture for Microservices
 
Saturn 2018: Managing data consistency in a microservice architecture using S...
Saturn 2018: Managing data consistency in a microservice architecture using S...Saturn 2018: Managing data consistency in a microservice architecture using S...
Saturn 2018: Managing data consistency in a microservice architecture using S...
 
Agile Development From A Developers Perspective
Agile Development From A Developers PerspectiveAgile Development From A Developers Perspective
Agile Development From A Developers Perspective
 
From a monolith to microservices + REST: The evolution of LinkedIn's architec...
From a monolith to microservices + REST: The evolution of LinkedIn's architec...From a monolith to microservices + REST: The evolution of LinkedIn's architec...
From a monolith to microservices + REST: The evolution of LinkedIn's architec...
 
Deploying Java Applicationson Ec2
Deploying Java Applicationson Ec2Deploying Java Applicationson Ec2
Deploying Java Applicationson Ec2
 
Building microservices with Scala, functional domain models and Spring Boot (...
Building microservices with Scala, functional domain models and Spring Boot (...Building microservices with Scala, functional domain models and Spring Boot (...
Building microservices with Scala, functional domain models and Spring Boot (...
 
Goto Berlin - Migrating to Microservices (Fast Delivery)
Goto Berlin - Migrating to Microservices (Fast Delivery)Goto Berlin - Migrating to Microservices (Fast Delivery)
Goto Berlin - Migrating to Microservices (Fast Delivery)
 
Developing event-driven microservices with event sourcing and CQRS (phillyete)
Developing event-driven microservices with event sourcing and CQRS (phillyete)Developing event-driven microservices with event sourcing and CQRS (phillyete)
Developing event-driven microservices with event sourcing and CQRS (phillyete)
 
InterConnect 2015: 3962 Docking DevOps
InterConnect 2015: 3962 Docking DevOpsInterConnect 2015: 3962 Docking DevOps
InterConnect 2015: 3962 Docking DevOps
 
API Microservices with Node.js and Docker
API Microservices with Node.js and DockerAPI Microservices with Node.js and Docker
API Microservices with Node.js and Docker
 
Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Microservices: Decomposing Applications for Deployability and Scalability (ja...
Microservices: Decomposing Applications for Deployability and Scalability (ja...Microservices: Decomposing Applications for Deployability and Scalability (ja...
Microservices: Decomposing Applications for Deployability and Scalability (ja...
 
Building Cloud-Aware Applications
Building Cloud-Aware ApplicationsBuilding Cloud-Aware Applications
Building Cloud-Aware Applications
 
Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...
Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...
Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Are microservices 'soa done right'?
Are microservices 'soa done right'?Are microservices 'soa done right'?
Are microservices 'soa done right'?
 
Transformacion e innovacion digital Meetup - Application Modernization and Mi...
Transformacion e innovacion digital Meetup - Application Modernization and Mi...Transformacion e innovacion digital Meetup - Application Modernization and Mi...
Transformacion e innovacion digital Meetup - Application Modernization and Mi...
 

Andere mochten auch

Andere mochten auch (7)

5 must-have patterns for your microservice - buildstuff
5 must-have patterns for your microservice - buildstuff5 must-have patterns for your microservice - buildstuff
5 must-have patterns for your microservice - buildstuff
 
Graph Database workshop
Graph Database workshopGraph Database workshop
Graph Database workshop
 
Service Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications todayService Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications today
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
 
Devteach 2016: A practical overview of actors in service fabric
Devteach 2016: A practical overview of actors in service fabricDevteach 2016: A practical overview of actors in service fabric
Devteach 2016: A practical overview of actors in service fabric
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
 
Microservice architecture at ASOS
Microservice architecture at ASOSMicroservice architecture at ASOS
Microservice architecture at ASOS
 

Ähnlich wie Patterns & Practices of Microservices

AWS Cloud Kata 2014 | Jakarta - Startup Best Practices
AWS Cloud Kata 2014 | Jakarta - Startup Best PracticesAWS Cloud Kata 2014 | Jakarta - Startup Best Practices
AWS Cloud Kata 2014 | Jakarta - Startup Best Practices
Amazon Web Services
 
Sukumar Nayak-Agile-DevOps-Cloud Management
Sukumar Nayak-Agile-DevOps-Cloud ManagementSukumar Nayak-Agile-DevOps-Cloud Management
Sukumar Nayak-Agile-DevOps-Cloud Management
Sukumar Nayak
 

Ähnlich wie Patterns & Practices of Microservices (20)

Build on AWS: Migrating and Platforming
Build on AWS: Migrating and PlatformingBuild on AWS: Migrating and Platforming
Build on AWS: Migrating and Platforming
 
Build on AWS: Migrating And Platforming
Build on AWS: Migrating And PlatformingBuild on AWS: Migrating And Platforming
Build on AWS: Migrating And Platforming
 
Reduce Risk with End to End Monitoring of Middleware-based Applications
Reduce Risk with End to End Monitoring of Middleware-based ApplicationsReduce Risk with End to End Monitoring of Middleware-based Applications
Reduce Risk with End to End Monitoring of Middleware-based Applications
 
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
 
AWS Cloud Kata 2014 | Jakarta - Startup Best Practices
AWS Cloud Kata 2014 | Jakarta - Startup Best PracticesAWS Cloud Kata 2014 | Jakarta - Startup Best Practices
AWS Cloud Kata 2014 | Jakarta - Startup Best Practices
 
Twelve Factor App
Twelve Factor AppTwelve Factor App
Twelve Factor App
 
Managing Software from Development to Deployment in the Cloud
Managing Software from Development to Deployment in the CloudManaging Software from Development to Deployment in the Cloud
Managing Software from Development to Deployment in the Cloud
 
11 Ways Microservices & Dynamic Clouds Break Your Monitoring
11 Ways Microservices & Dynamic Clouds Break Your Monitoring11 Ways Microservices & Dynamic Clouds Break Your Monitoring
11 Ways Microservices & Dynamic Clouds Break Your Monitoring
 
Modernizing Applications with Microservices and DC/OS (Lightbend/Mesosphere c...
Modernizing Applications with Microservices and DC/OS (Lightbend/Mesosphere c...Modernizing Applications with Microservices and DC/OS (Lightbend/Mesosphere c...
Modernizing Applications with Microservices and DC/OS (Lightbend/Mesosphere c...
 
Running Microservices on Amazon ECS - AWS April 2016 Webinar Series
Running Microservices on Amazon ECS - AWS April 2016 Webinar SeriesRunning Microservices on Amazon ECS - AWS April 2016 Webinar Series
Running Microservices on Amazon ECS - AWS April 2016 Webinar Series
 
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
 
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
 
Sukumar Nayak-Agile-DevOps-Cloud Management
Sukumar Nayak-Agile-DevOps-Cloud ManagementSukumar Nayak-Agile-DevOps-Cloud Management
Sukumar Nayak-Agile-DevOps-Cloud Management
 
Paa sing a java ee 6 application kshitiz saxena
Paa sing a java ee 6 application   kshitiz saxenaPaa sing a java ee 6 application   kshitiz saxena
Paa sing a java ee 6 application kshitiz saxena
 
Application Migrations at Scale AWS Summit SG 2017
Application Migrations at Scale AWS Summit SG 2017Application Migrations at Scale AWS Summit SG 2017
Application Migrations at Scale AWS Summit SG 2017
 
Simplify and Scale Enterprise Spring Apps in the Cloud | March 23, 2023
Simplify and Scale Enterprise Spring Apps in the Cloud | March 23, 2023Simplify and Scale Enterprise Spring Apps in the Cloud | March 23, 2023
Simplify and Scale Enterprise Spring Apps in the Cloud | March 23, 2023
 
5 Years Of Building SaaS On AWS
5 Years Of Building SaaS On AWS5 Years Of Building SaaS On AWS
5 Years Of Building SaaS On AWS
 
SoCal DevOps Meetup 1/26/2017 - Habitat by Chef
SoCal DevOps Meetup 1/26/2017 - Habitat by ChefSoCal DevOps Meetup 1/26/2017 - Habitat by Chef
SoCal DevOps Meetup 1/26/2017 - Habitat by Chef
 
App Mod 01: Moving existing apps to the cloud
App Mod 01: Moving existing apps to the cloudApp Mod 01: Moving existing apps to the cloud
App Mod 01: Moving existing apps to the cloud
 
AWS Webcast - Design for Availability
AWS Webcast - Design for AvailabilityAWS Webcast - Design for Availability
AWS Webcast - Design for Availability
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 

Patterns & Practices of Microservices

  • 2. Proxy / 
 Load Balancer Web Server Database Server Application Server Web Server ~4 YEARS
  • 3. Proxy / 
 Load Balancer Web Server Database Server Application Server Web Server Web Server Application Server ~3 YEARS
  • 4. Proxy / 
 Load Balancer Web Server Database Server Application Server Web Server Web Server Application Server Proxy / 
 Load Balancer Web Server Application Server Web Server Web Server Application Server Hot Cold Database Server ~2 YEARS
  • 5. Proxy / 
 Load Balancer Web Server Database Server Application Server Web Server Web Server Application Server Proxy / 
 Load Balancer Web Server Application Server Web Server Web Server Application Server Hot Cold GLB / DNS Reporting Database Server ~2 YEARS
  • 6. Proxy / 
 Load Balancer Web Server Database Server Application Server Web Server Web Server Application Server Proxy / 
 Load Balancer Web Server Application Server Web Server Web Server Application Server Reporting Database Server Hot Hot Database Server GLB / DNS ~2 YEARS
  • 10. W E S L E Y R E I S Z San Francisco / London / New York CHAIR QCON
  • 11.
  • 12.
  • 13. “Loosely coupled Service Oriented Architecture with Bounded Contexts” 
 -Adrian Cockcroft, Microservices Thoughtleader IF EVERY SERVICE HAS TO BE UPDATED AT THE SAME TIME IT’S NOT LOOSELY COUPLED IF YOU HAVE TO KNOW TOO MUCH ABOUT SURROUNDING SERVICES YOU DON’T HAVE A BOUNDED CONTEXT. SEE THE DOMAIN DRIVEN DESIGN BOOK BY ERIC EVANS.
  • 15. CONS PROS • Monitoring/Logging becomes more 
 important than ever. • You trade code simplicity for operational 
 complexity. • Easy to chase the latest shiny technology / mix new languages & tech in. • Another dimension to scale 
 the application. • Easier to have different services use
 data persistence most appropriate 
 for the use case. • Easier to reason about moving applications to the cloud. • Easier to have a developer understand
 the portion of the system and contribute • Easier to test & deploy a single service. • Cascading failures can cause 
 problems. • Orchestration can 
 become complex
  • 16. FIRST PRINCIPLES DevOps Culture, Evolutionary Architecture, 
 Scale Cube & CAP Theorem MICROSERVICESPATTERNS & PRACTICES PATTERNS & PRACTICES Technical, Operational, Cultural
  • 17. DEVOPS CULTURE IS A MUST • Rapid provisioning • Basic monitoring • Rapid Application Deployment http://martinfowler.com/bliki/MicroservicePrerequisites.html
  • 18. “Signing up for Microservices is signing up for evolutionary architecture. There’s no point where you’re just done.” 
 -Josh Evans, Director of Operations Engineering @Netflix
  • 19. Proxy / 
 Load Balancer Web Server Database Server Application Server Web Server Web Server Application Server Proxy / 
 Load Balancer Web Server Application Server Web Server Web Server Application Server Reporting Database Server Hot Hot Database Server GLB / DNS
  • 21. SCALE CUBE X axis - horizontal Scaling (Scale by Cloning) Z axis-DataPartitioning (ScalebySharding) Y axis - Functional Decomposition (Scale by Splitting)
  • 22. The CAP theorem is the idea that a distributed computing system is not able to provide partition tolerance, consistency and availability at the same time.
  • 23. MICROSERVICESPATTERNS & PRACTICES AVAILABILITY/PARTITION TOLERANCE CONSISTENCY/PARTITION TOLERANCE CP: Choose Consistency over Availability when your business requirements dictate atomic reads and writes. Wait for a response from the partitioned node which could result in a timeout error. The system can also choose to return an error, depending on the scenario you desire. AP: Choose Availability over Consistency when your business requirements allow for some flexibility around when the data in the system synchronizes. Return the most recent version of the data you have, which could be stale. This system state will also accept writes that can be processed later when the partition is resolved. Availability is also a compelling option when the system needs to continue to function in spite of external errors (shopping carts, etc.)
  • 24. Proxy / 
 Load Balancer Web Server Database Server Application Server Web Server Web Server Application Server Proxy / 
 Load Balancer Web Server Application Server Web Server Web Server Application Server Reporting Database Server Hot Hot Database Server GLB / DNS
  • 25. Evolu&onary Architecture Scale Cube CAP Theorem Microservices is a architecture that conFnues to change and adapt Scale Cube consists of an X, Y and Z axes – each addressing a different approach to scale a service. The idea that a distributed compuFng system is not able to provide parFFon tolerance, consistency and availability at the same Fme. FIRST PRINCIPLES Things we need to understand about as we plan/scale systems DevOps is a Must Microservices is the first architecture post devops culture shiP
  • 26. TECHNICAL Tools, Event Sourcing, CQRS, Circuit Breaker, Retrys OPERATIONAL Observability, Containers, Polyglot CULTURAL DevOps Culture, Conway’s Law MICROSERVICESPATTERNS & PRACTICES 1 2 3
  • 27. TOOLS “Everything is a tradeoff just be intentional about them”
  • 28. SPINE MODEL • Needs: 
 We are here to satisfy ________ • Values before Principles
 We optimize for ________ • Principles before Practices
 We leverage _____ to change the system • Practices before tools
 We do _____ to create value • We have always been Tool users and 
 makers. Tools should answer the question:
 We use ____ to get our work done. http://spinemodel.info/explanation/introduction/
  • 29. Proxy / 
 Load Balancer Web Server Database Server Application Server Web Server Web Server Application Server Proxy / 
 Load Balancer Web Server Application Server Web Server Web Server Application Server Reporting Database Server Hot Hot Database Server GLB / DNS
  • 30. Hot Hot GLB / DNS User Facing Availability
 Concerns Internal Consistency Concerns User Facing Availability
 Concerns Internal Consistency Concerns
  • 31. Hot Hot GLB / DNS High Reads High Writes High Reads High Writes
  • 32. Hot Hot GLB / DNS High Reads High Writes High Reads High Writes
  • 34. EVENT SOURCING “Yes, I think we should talk about this again.”
  • 35. Student Enroll In 
 Workshop Security Module Student Module Workshop Module reserveSeat() isAuthorized() isEligible() isAvailable() updateSchedule() updateSchedule() ALL SYNCHRONOUS MUTIABLE STATE!
  • 36. The fundamental idea of Event Sourcing is that of ensuring every change to the state of an application is captured in an event object, and that these event objects are themselves stored in the sequence they were applied for the same lifetime as the application state itself. - M Fowler
  • 37. Student Enroll In 
 Workshop Security Module Student Module Workshop ModuleQueue/Topic subscribe() subscribe() subscribe() reserveSeat() isAuthorized() reserveSeat() ASYNCHRONOUS IMMUTIABLE STATE! updateSchedule() updateSchedule() Par
  • 38. Immutable Events Recreate the exact state Increase in complexity Performance / Load tes&ng Provides a model to think about scalability Because you have all of the state changes, you have all of the changes that affected state No longer doing CRUD. You have calculate the result. Leverage things like snapshots You an reply the events across the Enterprise EVENT SOURCING The fundamental idea of Event Sourcing is that of ensuring every change to the state of an application is captured in an event object, and that these event objects are themselves stored in the sequence they were applied for the same lifetime as the application state itself.
  • 39. CQRS “Decouple queries from Commands to scale each independently.”
  • 40. Presentation Business Logic DAO Data Storage Updates / Queries
  • 41. Command and Query Responsibility Segregation (CQRS) is a pattern that segregates the operations that read data (Queries) from the operations that update data (Commands) by using separate interfaces.
  • 42. Presentation Commands Data Persistance Data Storage Updates (Writes) Domain Logic Queries (Reads) Presentation
  • 43. Presentation Commands Data Persistance Data Storage Updates (Writes) Domain Logic Queries (Reads) Presentation Presentation Presentation
  • 44. Presentation Commands Data Persistance Data Storage Updates (Writes) Domain Logic Queries (Reads) Presentation Presentation Presentation Presentation Presentation Presentation Read Data StoreWrite Data Store EVENTUAL CONSISTENCY?
  • 45. Domain Specific Models Scale Tradeoff Performance Clean Domain models queried Scale the reads above the writes Increased the operaFonal complexity of the data stores Tune different datastore for different performance needs CQRS Command-Query-Responsibility- Separation (CQRS) separates query processing from command processing, which updates entities using business logic that's commonly implemented using event sourcing. Security Updates to the model controlled different from the reads
  • 46. CIRCUIT BREAKER “Decouple queries from Commands to scale each independently.”
  • 47. Service A called B. TRIPPED Service B is Sick, let’s flag is and 
 try back in 5min Service C Different Instance of Service B Service B is sick. Don’t send traffic there for 5 minute (Tripped)
  • 48. Service A called B. OPEN Service B is still sick Service C Different Instance of Service B Service B is still sick. Isolate it and remove from ELB
  • 49. Service responds normally. Service C After 5 minutes. Traffic back to service B. Closed set the flag to closed. Nothing else to do.
 service B responded correctly,
  • 50. Prevents Doomed to Fail Three states Prevents Cascading Failures purpose is to detect external service failures and prevent the applicaFon from trying to perform an acFon that is doomed to fail. Closed (Normal), Open(Tripped), & Half-Open state Helps prevent cascading failures and improves resiliency. CIRCUIT BREAKER Circuit breaker is used to detect failures and encapsulates logic of preventing a failure to reoccur constantly (during maintenance, temporary external system failure or unexpected system difficulties). Part of Hysterix Part of Nelix OSS library for latency & fault tolerance
  • 51. RETRY “Upstream timeout must always be longer than total downstream 
 timeout * retries delay”
 -Adrian Cockcroft
  • 52. Bad Service Good Service Edge Service 3s 1s 1s Fails fast @ 2s “Upstream timeout must always be longer than total downstream 
 timeout * retries delay”
 -Adrian Cockcroft Budgeted timeout, one retry
  • 53. Tools Resiliency PaIerns Architectural PaIerns to Consider Don’t start with the tool. Circuit Breaker, Retry Event Sourcing & CQRS TECHNICAL These are some interesting technical considerations with Microservices
  • 54. TECHNICAL Getting started, Event Sourcing, CQRS OPERATIONAL Observability, Containers, Polyglot CULTURAL DevOps Culture, Conway’s Law, MICROSERVICESPATTERNS & PRACTICES 1 2 3
  • 55. OBSERVABILITY In control theory, observability is a measure for how well internal states of a system can be inferred by knowledge of its external outputs.
  • 56. At a minimum setup log stash, look at going an extra step to setup ELK. OBSERVABILITY: THINGS TO THINK ABOUT LOGS • Need consistent, structured logging • Logs are not for humans • Logstash, Elasticsearch, Kibania works 
 great
  • 57. OBSERVABILITY: THINGS TO THINK ABOUT PROTOCOLS/ TRANSPORT RPC/HTTP vs JSON vs Binary RPC vs HTTP JSON vs Binary • Speed/Performance vs Readability • Measure serialization, transmission, deserialization 
 costs
  • 58. OBSERVABILITY: THINGS TO THINK ABOUT How do you Recreate a failure in a distributed resilient environment? TRACING Look into: • Zipkin • Prometheus Best way to understand Fanout
  • 60. CONTAINERS “What do you feel is the most disruptive (or at least potentially disruptive technology)?”
  • 61. POLYGLOT More challenges than they thought…
  • 62. Observability Polyglot Containers Logging, Service CommunicaFon, Tracking Containers makes it easier, but observability, logging, tracking can be more challenging Low fricFon deployment, Finer-grained execuFon environments, speed, isolaFon OPERATIONAL Microservices simplifies code. It trades code complexity for operational complexity
  • 63. TECHNICAL Getting started, Event Sourcing, CQRS OPERATIONAL Observability, Containers, Polyglot CULTURAL DevOps Culture, Conway’s Law MICROSERVICESPATTERNS & PRACTICES 1 2 3
  • 64. CONWAY'S LAW “Organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations” -Conway
  • 65. Model One size does not fit all Tradeoff Organiza&onal Lifecycle Stages Provides a model to think about scalability Microservices (funcFon decomposiFon) is AN approach Each approach has different tradeoffs (For example: as we’ll find with Y-axis scaling, you may trade code complexity for organizaFonal complexity) Different needs at different points of an org’s lifecycle CONWAY’S LAW Organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations
  • 66. So what do I wish I knew before starting the push to Microservices?
  • 67. Proxy / 
 Load Balancer Web Server Database Server Application Server Web Server Web Server Application Server Proxy / 
 Load Balancer Web Server Application Server Web Server Web Server Application Server Reporting Database Server Hot Hot Database Server GLB / DNS
  • 70. FIRST PRINCIPLES MICROSERVICESPATTERNS & PRACTICES • Have capabilities in your org to do things like rapidly provision, monitor, and use rapid deployment.
 (DevOPs Culture is a must) • Accept that the service going to evolve 
 (Evolutionary Architecture) • Handle their own data needs 
 (Consistency/Availablity Tradeoffs) • Be able to scale based on it’s needs
 (Scale Cube) Processing DevOps Culture, Evolutionary Architecture, 
 Scale Cube & CAP Theorem
  • 71. TECHNICAL Spine Model
 Event Sourcing/CQRS Circuit Breaker Retry OPERATIONAL Observability
 Containers Polyglot CULTURAL Conway’s Law MICROSERVICESPATTERNS & PRACTICES Processing • Have a decision process
 (Spine Model) • Consider using events where it makes sense and how you might scale commands & queries
 (Event Sourcing / CQRS) • Protect against cascading failures
 (Circuit Breaker, Bulkhead) • “Everything is a tradeoff, do it intentionally” Matt Ranney (RPC/HTTP, Containers, Polyglot) • Bootstrap services with organizational capabilities (Logs, Tracing) • Beware of Conway’s Law
  • 72. CONS PROS • Monitoring/Logging becomes more 
 important than ever. • You trade code complexity for operational 
 complexity. • Easy to chase the latest shiny technology / mix new languages & tech in. • Another dimension to scale 
 the application. • Easier to have different services use
 data persistence most appropriate 
 for the use case. • Easier to reason about moving applications to the cloud. • Easier to have a developer understand
 the portion of the system and contribute • Easier to test & deploy a single service. • Cascading failures can cause 
 problems. • Orchestration can 
 become complex
  • 73. “If you don’t end up regretting your early technology decisions, you probably over engineered.” - Randy Shoup, Engineering Director @StitchFix MICROSERVICESPATTERNS & PRACTICES