SlideShare a Scribd company logo
1 of 59
μservices
Week 3
But it is not the only topic today
Also:
• Self-contained systems.
• Classical distributed systems.
• Hybrid microservice systems.
A modern classic on the subject
What is a microservice architecture?
• In short, the microservice architectural style is an approach to
developing a single application as a suite of small services, each
running in its own process and communicating with lightweight
mechanisms, often an HTTP resource API.
• These services are built around business capabilities and
independently deployable by fully automated deployment machinery.
There is a bare minimum of centralized management of these
services, which may be written in different programming languages
and use different data storage technologies.
Monoliths vs μservices
The upside of monoliths
• With some care, you can run and test the application on a
developer's laptop, and use a deployment pipeline to ensure that
changes are properly tested and deployed into production.
• You can horizontally scale the
monolith by running many
instances behind a load-balancer.
And the downside
• Change cycles are tied together - a change made to a small part of the
application, requires the entire monolith to be rebuilt and deployed.
• Over time it's often hard to keep a good modular structure, making it
harder to keep changes that ought to only affect one module within that
module.
• Scaling requires scaling of the entire application rather than parts of it that
require greater resource.
Evolved paradigm
• These frustrations have led to the microservice architectural style:
building applications as suites of services.
• As well as the fact that services are independently deployable and
scalable, each service also provides a firm module boundary, even
allowing for different services to be written in different programming
languages.
• They can also be managed (=Operations as well?) by different teams .
μservices are not novel
Characteristics of a Microservice Architecture
Componentization via Services
• When talking about components we run into the difficult definition of what
makes a component. Our definition is that a component is a unit of
software that is independently replaceable and upgradeable.
• Microservice architectures will use libraries, but their primary way of
componentizing their own software is by breaking down into services.
• We define libraries as components that are linked into a program and
called using in-memory function calls, while services are out-of-process
components who communicate with a mechanism such as a web service
request, or remote procedure call.
Characteristics of a Microservice Architecture
Componentization via Services (cont.)
• One main reason for using services as components (rather than
libraries) is that services are independently deployable.
• Another consequence of using services as components is a more
explicit component interface.
• Remote calls are more expensive than in-process calls, and thus
remote APIs need to be coarser-grained, which is often more
awkward to use.
Characteristics of a Microservice Architecture
Componentization via Services (cont.)
• If you need to change the allocation of responsibilities between
components, such movements of behavior are harder to do when
you're crossing process boundaries.
• At a first approximation, we can observe that services map to runtime
processes, but that is only a first approximation. A service may consist
of multiple processes that will always be developed and deployed
together, such as an application process and a database that's only
used by that service.
Characteristics of a Microservice Architecture
Organized around Business Capabilities
Any organization that designs a system (defined broadly) will produce a
design whose structure is a copy of the organization's communication
structure.
-- Melvyn Conway, 1967
Division by technology
Division by business capability
Could we modularize monoliths by business capability?
Possibly yes, with some strings attached
• In the application is large enough to occupy multiple teams.
• If the teams are disciplined enough to stay within the defined
boundaries of their business concern.
• There may be excessively too many contexts involved for the
developers to keep in mind.
• The boundaries are implicit, making them more blurry and ambiguous
compared to the microservice approach.
Characteristics of a Microservice Architecture
Products not Projects
• Most application development efforts that we see use a project model.
• Microservice proponents tend to avoid this model, preferring instead the
notion that a team should own a product over its full lifetime.
• Amazon: "you build, you run it".
• The product mentality, ties in with the linkage to business capabilities, how
can software assist its users to enhance the business capability.
Characteristics of a Microservice Architecture
Smart endpoints and dumb pipes
• In many systems which require inter-process communication there
has been an emphasis on 'smart' communication mechanisms, that
enable message routing, applying business rules and advanced rules
and advanced rules and advanced queueing.
• Microservice depend on simple communication tools, like simple
REST protocols (usually over HTTP) and direct messaging (Erlang,
Akka,…) or via a lightweight message bus (like ØMQ and RabbitMQ –
Kafka?), which provides only a reliable, asynchronous messaging platf
orm.
Characteristics of a Microservice Architecture
Smart endpoints and dumb pipes (cont.)
• The smarts still live in the end points that are producing and
consuming messages; in the services.
• In a monolith, the components are executing in-process and
communication between them is via either method invocation or
function call.
• The biggest issue in changing a monolith into microservices lies in
changing the communication pattern (replacing fine-grained comms
with coarser ones).
Characteristics of a Microservice Architecture
Decentralized Governance
• Centralized Governance -> Standarization on single technology
platforms.
• Works 'okay', but does not let us tap the full extend of different
technologies which match different concerns the best.
• It doesn't mean that you need to use a different language for every
service.
Characteristics of a Microservice Architecture
Decentralized Governance (cont.)
Characteristics of a Microservice Architecture
Decentralized Governance (cont.)
• Teams building microservices prefer a different approach to standards
too. Rather than use a set of defined standards written down
somewhere on paper they prefer the idea of producing useful tools
that other developers can use to solve similar problems to the ones
they are facing.
• Excellent example: https://github.com/Netflix
Characteristics of a Microservice Architecture
Decentralized Governance (cont.)
• Define the contracts for your service.
• Contracts can help to automate the build process, irrespective of the
resource's implementation.
• The service can be build to the point it satisfies the contract, no need
for building unecessary artifacts (YAGNI) and specifications.
• Most extreme case: Amazon, devs build and run it 24/7.
Characteristics of a Microservice Architecture
Decentralized Data Management
• The conceptual model of the world will differ between systems.
• Sales have a different view from Devs, Devs from Ops and Ops from
PMs. They will need access to different subsets of the data or with a
different presentation logic and semantics.
Characteristics of a Microservice Architecture
Decentralized Data Management (cont.)
Characteristics of a Microservice Architecture
Decentralized Data Management (cont.)
• A useful tool to tame the complexity is Domain-Driven Design (DDD).
• It can break down a complex problem domain
into multiple bounded contexts and to map the
relationships between them.
• Applicable to monoliths and μservices.
Characteristics of a Microservice Architecture
Decentralized Data Management (cont.)
• How does a bounded context looks like?
Characteristics of a Microservice Architecture
Decentralized Data Management (cont.)
• As well as decentralizing decisions about conceptual models,
microservices also decentralize data storage decisions.
• While monolithic applications prefer a single logical database for
persistant data.
• Microservices prefer letting each service manage its own database,
either different instances of the same database technology, or
entirely different database systems.
Characteristics of a Microservice Architecture
Decentralized Data Management (cont.)
• This concept is named Polyglot Persistence.
Characteristics of a Microservice Architecture
Decentralized Data Management (cont.)
Characteristics of a Microservice Architecture
Decentralized Data Management (cont.)
Implications of Decentralized Data Management:
• How do we manage data updates?
• How do we ensure atomicity?
• How do we ensure consistency?
Characteristics of a Microservice Architecture
Decentralized Data Management (cont.)
Implications of Decentralized Data Management:
• Transactionless coordination between services
• Accept eventual consistency.
• Evaluate: Cost of sporadic inconsistency vs Cost
of lost business under greater consistency.
Characteristics of a Microservice Architecture
Infrastructure Automation
• A must for μservice based architectures.
• It has evolved tremendously with the advent of public cloud
providers.
• Relevant buzzwords: Continuous Integration and Continuoud Delivery.
Characteristics of a Microservice Architecture
Infrastructure Automation (cont.)
Characteristics of a Microservice Architecture
Infrastructure Automation (cont.)
Prerequisites for CD and CI:
• Thorough test coverage of the codebase.
• Lots of automated tests (not only unit tests).
• Every stage of the pipeline is actually an automated deployment to a
new environment.
Characteristics of a Microservice Architecture
Infrastructure Automation (cont.)
• CD and CI for monoliths and μservices is not differing much.
• Do it first for your system before you break it and then it will be easy
:-)
• Make deployments boring and there wont be a difference between 1
or 10 services.
Characteristics of a Microservice Architecture
Infrastructure Automation (cont.)
• CD and CI for monoliths and μservices is not differing much.
• Do it first for your system before you break it and then it will be easy
:-)
• Make deployments boring and there wont be a difference between 1
or 10 services.
Characteristics of a Microservice Architecture
Infrastructure Automation (cont.)
• Operating the architecturally different systems in production can be
very different.
Characteristics of a Microservice Architecture
Infrastructure Automation (cont.)
• Monitoring for μservices requires significant more automation and
orchestration.
• There are many more moving parts and interfaces to look after.
• Employ a modern monitoring system which allows the collection of diverse
metrics from many different log sources in dispersed locations, trend
analysis and large actionable data size.
• Monitor services, not only machines; you are operating systems not apps.
Characteristics of a Microservice Architecture
Infrastructure Automation (cont.)
Tools to look into, the ELK stack:
Characteristics of a Microservice Architecture
Infrastructure Automation (cont.)
Tools to look into, the Prometheus + fluentd combo:
Characteristics of a Microservice Architecture
Design for Failure
• A consequence of using services as components, is that applications
need to be designed so that they can tolerate the failure of services
• Any service call could fail due to unavailability of the supplier, the
client has to respond to this as gracefully as possible.
• Since services can fail at any time, it's important to be able to detect
the failures quickly and, if possible, automatically restore service.
Characteristics of a Microservice Architecture
Design for Failure (cont.)
• Microservice applications put a lot of emphasis on real-time monitoring of
the application, checking both architectural elements (how many requests
per second is the database getting) and business relevant metrics (such as
how many orders per minute are received).
• Semantic monitoring can provide an early warning system of something
going wrong that triggers development teams to follow up and investigate.
• Microservice teams would expect to see sophisticated monitoring and
logging setups for each individual service such as dashboards showing
up/down status and a variety of operational and business relevant metrics.
Details on circuit breaker status, current throughput and latency are other
examples we often encounter in the wild.
Characteristics of a Microservice Architecture
Design for Failure (cont.)
Learning from the Pros:
Characteristics of a Microservice Architecture
Design for Failure (cont.)
Erlang's design principles:
• Let it crash.
• Shift the failure management one level up, where it can be managed
intelligently by your orchestration or monitoring software.
• Fail fast and recover fast and automatically.
• Keep as many things as possible immutable.
Characteristics of a Microservice Architecture
Design for Failure (cont.)
• Results into running in the wild with 9
nines uptime.
• 9,99999999% uptime equals to
27ms/year downtime.
Erlang is a classical distributed processing
environment, not a microservices-based one.
• Code can be reloaded to each 'service' node, they don't have a
dedicated functionality like in a microservice application.
• The overall architecture is more 'fluid' in terms of semantics.
• A microservices-based system is a distributed system, but the other
way around may not always hold true.
Characteristics of a Microservice Architecture
Evolutionary Design
• Service decomposition is yet a further tool to enable application developers to
control changes in their application without slowing down change.
• Change control doesn't necessarily mean change reduction - with the right
attitudes and tools you can make frequent, fast, and well-controlled changes to
software.
• The key property of a component is the notion of independent replacement and
upgradeability - which implies we look for points where we can imagine rewriting
a component without affecting its collaborators.
• Indeed many microservice groups take this further by explicitly expecting many
services to be scrapped rather than evolved in the longer term.
Characteristics of a Microservice Architecture
Evolutionary Design (cont.)
Characteristics of a Microservice Architecture
Evolutionary Design
• The Guardian started their website as a monolith.
• They evolve it towards a μservice architecture.
• The monolith is the system's core.
• New features are added as microservices that use the monolith's API.
• Approach that works very well with transient features like thematic pages
covering special events, polls or special issues with special UI elements and
visualization.
Characteristics of a Microservice Architecture
Evolutionary Design
• So evolving your design or using disposable services can be used for aims
that are beyond pure engineering. For instance:
• Enhanced user experience.
• Easier A/B testing.
• Agility in feature delivery.
• Easier transition from a monolithic application.
Another path – Self-Contained Systems (SCS)
• Main concept: Instead of decomposing a monolith in microservices,
you break it down to autonomous, replaceable web applications.
• SCS are larger than microservices and they will be considerably less
SCS than microservices originating from a monolithic application.
• SCS have also separate UI, business logic and data persistence.
• The preferred integration point is on the UI level and sometimes on
API.
Another path – Self-Contained Systems (SCS)
Show Case: Kühne + Nagel FreightNet
• An initially monolithic application which evolved to a 1,5 million LOCs Godzilla,
with 200+ developers working on it.
• It is written in an internally developed Java Web Framework. Later Spring, JSP,
JQuery, Swing/ ULC, GWT/GXT where thrown in the mix.
• It became extremely difficult to evolve it.
• It is K+N's most valuable product, evaluated to billions of Euros.
• It was a make-or-break situation for the company to keep the product
manageable.
Show Case: Kühne + Nagel FreightNet (cont.)
The migration process followed was:
• They stopped adding even more stuff to the monolith.
• They found the seams of the monolith.
• They realized that most of the seams are wishful thinking, way to
complicated and inter-dependent to split.
• They “desiccate” the monolith over time in spite of #3 through new
projects that cover parts of some of the monolith’s functionality.
• Moving to Microservices might be too much of a drastic step,
especially when you have such complex monolithic software.
Show Case: Kühne + Nagel FreightNet (cont.)
• In the end, FreightNet was broken to 10 SCS, each one with ist one UI.
• Mode of transport or modules offering very special functionality were
the seams which became the boundaries of the SCSs.
• It took them 4 years only to split the functionality from the monolith,
but they see it as the only way possible to decompose a project of
this order of complexity.
Interesting resources
• https://dev.otto.de/2015/09/30/on-monoliths-and-microservices/
• https://www.elastic.io/breaking-down-monolith-microservices-and-self-contained-systems/
• https://dev.otto.de/2016/03/20/why-microservices/
• http://ryanjbaxter.com/2015/07/15/using-microservices-to-build-cloud-native-applications-part-
1/
• Building Microservics, Buch 2013, O'Reilly.
• The Tao of Microservices, Rodger 2016, Manning.
Thank you very much! Have a nice weekend!

More Related Content

What's hot

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
 

What's hot (20)

Microservices for Enterprises
Microservices for Enterprises Microservices for Enterprises
Microservices for Enterprises
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Kubernetes solutions
Kubernetes solutionsKubernetes solutions
Kubernetes solutions
 
Nats meetup sf 20150826
Nats meetup sf   20150826Nats meetup sf   20150826
Nats meetup sf 20150826
 
Microservices and Azure App Services
Microservices and Azure App ServicesMicroservices and Azure App Services
Microservices and Azure App Services
 
From SOA to MSA
From SOA to MSAFrom SOA to MSA
From SOA to MSA
 
Microservices to Scale using Azure Service Fabric
Microservices to Scale using Azure Service FabricMicroservices to Scale using Azure Service Fabric
Microservices to Scale using Azure Service Fabric
 
The Microservices world in. NET Core and. NET framework
The Microservices world in. NET Core and. NET frameworkThe Microservices world in. NET Core and. NET framework
The Microservices world in. NET Core and. NET framework
 
A Modern Data Architecture for Microservices
A Modern Data Architecture for MicroservicesA Modern Data Architecture for Microservices
A Modern Data Architecture for Microservices
 
Full lifecycle of a microservice
Full lifecycle of a microserviceFull lifecycle of a microservice
Full lifecycle of a microservice
 
Microservices: an introduction
Microservices: an introductionMicroservices: an introduction
Microservices: an introduction
 
Microservices Patterns and Anti-Patterns
Microservices Patterns and Anti-PatternsMicroservices Patterns and Anti-Patterns
Microservices Patterns and Anti-Patterns
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architecture
 
Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016
 
Things I wish someone had told me about Istio, Omer Levi Hevroni
Things I wish someone had told me about Istio, Omer Levi HevroniThings I wish someone had told me about Istio, Omer Levi Hevroni
Things I wish someone had told me about Istio, Omer Levi Hevroni
 
MicroServices sur AWS
MicroServices sur AWSMicroServices sur AWS
MicroServices sur AWS
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
API Strategy Austin - App-centric vs Job-centric Microservices
API Strategy Austin - App-centric vs Job-centric MicroservicesAPI Strategy Austin - App-centric vs Job-centric Microservices
API Strategy Austin - App-centric vs Job-centric Microservices
 

Viewers also liked

A BRIEF OVERVIEW ON WILDLIFE MANAGEMENT
A BRIEF OVERVIEW ON WILDLIFE MANAGEMENTA BRIEF OVERVIEW ON WILDLIFE MANAGEMENT
A BRIEF OVERVIEW ON WILDLIFE MANAGEMENT
Pintu Kabiraj
 
Retelling nonfiction
Retelling nonfictionRetelling nonfiction
Retelling nonfiction
Emily Kissner
 

Viewers also liked (20)

A BRIEF OVERVIEW ON WILDLIFE MANAGEMENT
A BRIEF OVERVIEW ON WILDLIFE MANAGEMENTA BRIEF OVERVIEW ON WILDLIFE MANAGEMENT
A BRIEF OVERVIEW ON WILDLIFE MANAGEMENT
 
IoT and Big Data
IoT and Big DataIoT and Big Data
IoT and Big Data
 
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
 
Retelling nonfiction
Retelling nonfictionRetelling nonfiction
Retelling nonfiction
 
Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk
 
Docker security introduction-task-2016
Docker security introduction-task-2016Docker security introduction-task-2016
Docker security introduction-task-2016
 
Complex realtime event analytics using BigQuery @Crunch Warmup
Complex realtime event analytics using BigQuery @Crunch WarmupComplex realtime event analytics using BigQuery @Crunch Warmup
Complex realtime event analytics using BigQuery @Crunch Warmup
 
Elks for analysing performance test results - Helsinki QA meetup
Elks for analysing performance test results - Helsinki QA meetupElks for analysing performance test results - Helsinki QA meetup
Elks for analysing performance test results - Helsinki QA meetup
 
Docker swarm-mike-goelzer-mv-meetup-45min-workshop 02242016 (1)
Docker swarm-mike-goelzer-mv-meetup-45min-workshop 02242016 (1)Docker swarm-mike-goelzer-mv-meetup-45min-workshop 02242016 (1)
Docker swarm-mike-goelzer-mv-meetup-45min-workshop 02242016 (1)
 
Evolutions et nouveaux outils SEO
Evolutions et nouveaux outils SEOEvolutions et nouveaux outils SEO
Evolutions et nouveaux outils SEO
 
Interesting Places in Poland
Interesting Places in PolandInteresting Places in Poland
Interesting Places in Poland
 
Stormshield Visibility Center
Stormshield Visibility CenterStormshield Visibility Center
Stormshield Visibility Center
 
Cloud Expo New York: OpenFlow Is SDN Yet SDN Is Not Only OpenFlow
Cloud Expo New York: OpenFlow Is SDN Yet SDN Is Not Only OpenFlowCloud Expo New York: OpenFlow Is SDN Yet SDN Is Not Only OpenFlow
Cloud Expo New York: OpenFlow Is SDN Yet SDN Is Not Only OpenFlow
 
Deploy Microservices in the Real World
Deploy Microservices in the Real WorldDeploy Microservices in the Real World
Deploy Microservices in the Real World
 
Engineering Development & Design Capstone Project _ RICE-Optimized Knee Brace
Engineering Development & Design Capstone Project _ RICE-Optimized Knee BraceEngineering Development & Design Capstone Project _ RICE-Optimized Knee Brace
Engineering Development & Design Capstone Project _ RICE-Optimized Knee Brace
 
Microsoft Microservices
Microsoft MicroservicesMicrosoft Microservices
Microsoft Microservices
 
Diabetes mellitus
Diabetes mellitusDiabetes mellitus
Diabetes mellitus
 
What's new in oracle ORAchk & EXAchk 12.2.0.1.2
What's new in oracle ORAchk & EXAchk 12.2.0.1.2What's new in oracle ORAchk & EXAchk 12.2.0.1.2
What's new in oracle ORAchk & EXAchk 12.2.0.1.2
 
Big Data Europe: Simplifying Development and Deployment of Big Data Applications
Big Data Europe: Simplifying Development and Deployment of Big Data ApplicationsBig Data Europe: Simplifying Development and Deployment of Big Data Applications
Big Data Europe: Simplifying Development and Deployment of Big Data Applications
 
Security Realism in Education
Security Realism in EducationSecurity Realism in Education
Security Realism in Education
 

Similar to Software Architectures, Week 3 - Microservice-based Architectures

MICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptxMICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptx
MohammedShahid562503
 

Similar to Software Architectures, Week 3 - Microservice-based Architectures (20)

Microservices
MicroservicesMicroservices
Microservices
 
Microservice Architecture Software Architecture Microservice Design Pattern
Microservice Architecture Software Architecture Microservice Design PatternMicroservice Architecture Software Architecture Microservice Design Pattern
Microservice Architecture Software Architecture Microservice Design Pattern
 
MICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptxMICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptx
 
Microservice's in detailed
Microservice's in detailedMicroservice's in detailed
Microservice's in detailed
 
MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.
 
What are microservices
What are microservicesWhat are microservices
What are microservices
 
SOA vs Microservices vs SBA
SOA vs Microservices vs SBASOA vs Microservices vs SBA
SOA vs Microservices vs SBA
 
Discussion About Microservices Architecture
Discussion About Microservices ArchitectureDiscussion About Microservices Architecture
Discussion About Microservices Architecture
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Pitfalls & Challenges Faced During a Microservices Architecture Implementation
Pitfalls & Challenges Faced During a Microservices Architecture ImplementationPitfalls & Challenges Faced During a Microservices Architecture Implementation
Pitfalls & Challenges Faced During a Microservices Architecture Implementation
 
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
 
Microservice intro
Microservice introMicroservice intro
Microservice intro
 
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
 
Microservice final final
Microservice final finalMicroservice final final
Microservice final final
 
Understanding Microservices
Understanding Microservices Understanding Microservices
Understanding Microservices
 
Microservices, Containers, Scheduling and Orchestration - A Primer
Microservices, Containers, Scheduling and Orchestration - A PrimerMicroservices, Containers, Scheduling and Orchestration - A Primer
Microservices, Containers, Scheduling and Orchestration - A Primer
 
Microservices for Application Modernisation
Microservices for Application ModernisationMicroservices for Application Modernisation
Microservices for Application Modernisation
 
Design Patterns for Micro Service Architecture
Design Patterns for Micro Service ArchitectureDesign Patterns for Micro Service Architecture
Design Patterns for Micro Service Architecture
 
Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.
 

Software Architectures, Week 3 - Microservice-based Architectures

  • 2. But it is not the only topic today Also: • Self-contained systems. • Classical distributed systems. • Hybrid microservice systems.
  • 3. A modern classic on the subject
  • 4. What is a microservice architecture? • In short, the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. • These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.
  • 6. The upside of monoliths • With some care, you can run and test the application on a developer's laptop, and use a deployment pipeline to ensure that changes are properly tested and deployed into production. • You can horizontally scale the monolith by running many instances behind a load-balancer.
  • 7. And the downside • Change cycles are tied together - a change made to a small part of the application, requires the entire monolith to be rebuilt and deployed. • Over time it's often hard to keep a good modular structure, making it harder to keep changes that ought to only affect one module within that module. • Scaling requires scaling of the entire application rather than parts of it that require greater resource.
  • 8. Evolved paradigm • These frustrations have led to the microservice architectural style: building applications as suites of services. • As well as the fact that services are independently deployable and scalable, each service also provides a firm module boundary, even allowing for different services to be written in different programming languages. • They can also be managed (=Operations as well?) by different teams .
  • 10. Characteristics of a Microservice Architecture Componentization via Services • When talking about components we run into the difficult definition of what makes a component. Our definition is that a component is a unit of software that is independently replaceable and upgradeable. • Microservice architectures will use libraries, but their primary way of componentizing their own software is by breaking down into services. • We define libraries as components that are linked into a program and called using in-memory function calls, while services are out-of-process components who communicate with a mechanism such as a web service request, or remote procedure call.
  • 11. Characteristics of a Microservice Architecture Componentization via Services (cont.) • One main reason for using services as components (rather than libraries) is that services are independently deployable. • Another consequence of using services as components is a more explicit component interface. • Remote calls are more expensive than in-process calls, and thus remote APIs need to be coarser-grained, which is often more awkward to use.
  • 12. Characteristics of a Microservice Architecture Componentization via Services (cont.) • If you need to change the allocation of responsibilities between components, such movements of behavior are harder to do when you're crossing process boundaries. • At a first approximation, we can observe that services map to runtime processes, but that is only a first approximation. A service may consist of multiple processes that will always be developed and deployed together, such as an application process and a database that's only used by that service.
  • 13. Characteristics of a Microservice Architecture Organized around Business Capabilities Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure. -- Melvyn Conway, 1967
  • 15. Division by business capability
  • 16. Could we modularize monoliths by business capability?
  • 17. Possibly yes, with some strings attached • In the application is large enough to occupy multiple teams. • If the teams are disciplined enough to stay within the defined boundaries of their business concern. • There may be excessively too many contexts involved for the developers to keep in mind. • The boundaries are implicit, making them more blurry and ambiguous compared to the microservice approach.
  • 18. Characteristics of a Microservice Architecture Products not Projects • Most application development efforts that we see use a project model. • Microservice proponents tend to avoid this model, preferring instead the notion that a team should own a product over its full lifetime. • Amazon: "you build, you run it". • The product mentality, ties in with the linkage to business capabilities, how can software assist its users to enhance the business capability.
  • 19. Characteristics of a Microservice Architecture Smart endpoints and dumb pipes • In many systems which require inter-process communication there has been an emphasis on 'smart' communication mechanisms, that enable message routing, applying business rules and advanced rules and advanced rules and advanced queueing. • Microservice depend on simple communication tools, like simple REST protocols (usually over HTTP) and direct messaging (Erlang, Akka,…) or via a lightweight message bus (like ØMQ and RabbitMQ – Kafka?), which provides only a reliable, asynchronous messaging platf orm.
  • 20. Characteristics of a Microservice Architecture Smart endpoints and dumb pipes (cont.) • The smarts still live in the end points that are producing and consuming messages; in the services. • In a monolith, the components are executing in-process and communication between them is via either method invocation or function call. • The biggest issue in changing a monolith into microservices lies in changing the communication pattern (replacing fine-grained comms with coarser ones).
  • 21. Characteristics of a Microservice Architecture Decentralized Governance • Centralized Governance -> Standarization on single technology platforms. • Works 'okay', but does not let us tap the full extend of different technologies which match different concerns the best. • It doesn't mean that you need to use a different language for every service.
  • 22. Characteristics of a Microservice Architecture Decentralized Governance (cont.)
  • 23. Characteristics of a Microservice Architecture Decentralized Governance (cont.) • Teams building microservices prefer a different approach to standards too. Rather than use a set of defined standards written down somewhere on paper they prefer the idea of producing useful tools that other developers can use to solve similar problems to the ones they are facing. • Excellent example: https://github.com/Netflix
  • 24. Characteristics of a Microservice Architecture Decentralized Governance (cont.) • Define the contracts for your service. • Contracts can help to automate the build process, irrespective of the resource's implementation. • The service can be build to the point it satisfies the contract, no need for building unecessary artifacts (YAGNI) and specifications. • Most extreme case: Amazon, devs build and run it 24/7.
  • 25. Characteristics of a Microservice Architecture Decentralized Data Management • The conceptual model of the world will differ between systems. • Sales have a different view from Devs, Devs from Ops and Ops from PMs. They will need access to different subsets of the data or with a different presentation logic and semantics.
  • 26. Characteristics of a Microservice Architecture Decentralized Data Management (cont.)
  • 27. Characteristics of a Microservice Architecture Decentralized Data Management (cont.) • A useful tool to tame the complexity is Domain-Driven Design (DDD). • It can break down a complex problem domain into multiple bounded contexts and to map the relationships between them. • Applicable to monoliths and μservices.
  • 28. Characteristics of a Microservice Architecture Decentralized Data Management (cont.) • How does a bounded context looks like?
  • 29. Characteristics of a Microservice Architecture Decentralized Data Management (cont.) • As well as decentralizing decisions about conceptual models, microservices also decentralize data storage decisions. • While monolithic applications prefer a single logical database for persistant data. • Microservices prefer letting each service manage its own database, either different instances of the same database technology, or entirely different database systems.
  • 30. Characteristics of a Microservice Architecture Decentralized Data Management (cont.) • This concept is named Polyglot Persistence.
  • 31. Characteristics of a Microservice Architecture Decentralized Data Management (cont.)
  • 32. Characteristics of a Microservice Architecture Decentralized Data Management (cont.) Implications of Decentralized Data Management: • How do we manage data updates? • How do we ensure atomicity? • How do we ensure consistency?
  • 33. Characteristics of a Microservice Architecture Decentralized Data Management (cont.) Implications of Decentralized Data Management: • Transactionless coordination between services • Accept eventual consistency. • Evaluate: Cost of sporadic inconsistency vs Cost of lost business under greater consistency.
  • 34. Characteristics of a Microservice Architecture Infrastructure Automation • A must for μservice based architectures. • It has evolved tremendously with the advent of public cloud providers. • Relevant buzzwords: Continuous Integration and Continuoud Delivery.
  • 35. Characteristics of a Microservice Architecture Infrastructure Automation (cont.)
  • 36. Characteristics of a Microservice Architecture Infrastructure Automation (cont.) Prerequisites for CD and CI: • Thorough test coverage of the codebase. • Lots of automated tests (not only unit tests). • Every stage of the pipeline is actually an automated deployment to a new environment.
  • 37. Characteristics of a Microservice Architecture Infrastructure Automation (cont.) • CD and CI for monoliths and μservices is not differing much. • Do it first for your system before you break it and then it will be easy :-) • Make deployments boring and there wont be a difference between 1 or 10 services.
  • 38. Characteristics of a Microservice Architecture Infrastructure Automation (cont.) • CD and CI for monoliths and μservices is not differing much. • Do it first for your system before you break it and then it will be easy :-) • Make deployments boring and there wont be a difference between 1 or 10 services.
  • 39. Characteristics of a Microservice Architecture Infrastructure Automation (cont.) • Operating the architecturally different systems in production can be very different.
  • 40. Characteristics of a Microservice Architecture Infrastructure Automation (cont.) • Monitoring for μservices requires significant more automation and orchestration. • There are many more moving parts and interfaces to look after. • Employ a modern monitoring system which allows the collection of diverse metrics from many different log sources in dispersed locations, trend analysis and large actionable data size. • Monitor services, not only machines; you are operating systems not apps.
  • 41. Characteristics of a Microservice Architecture Infrastructure Automation (cont.) Tools to look into, the ELK stack:
  • 42. Characteristics of a Microservice Architecture Infrastructure Automation (cont.) Tools to look into, the Prometheus + fluentd combo:
  • 43. Characteristics of a Microservice Architecture Design for Failure • A consequence of using services as components, is that applications need to be designed so that they can tolerate the failure of services • Any service call could fail due to unavailability of the supplier, the client has to respond to this as gracefully as possible. • Since services can fail at any time, it's important to be able to detect the failures quickly and, if possible, automatically restore service.
  • 44. Characteristics of a Microservice Architecture Design for Failure (cont.) • Microservice applications put a lot of emphasis on real-time monitoring of the application, checking both architectural elements (how many requests per second is the database getting) and business relevant metrics (such as how many orders per minute are received). • Semantic monitoring can provide an early warning system of something going wrong that triggers development teams to follow up and investigate. • Microservice teams would expect to see sophisticated monitoring and logging setups for each individual service such as dashboards showing up/down status and a variety of operational and business relevant metrics. Details on circuit breaker status, current throughput and latency are other examples we often encounter in the wild.
  • 45. Characteristics of a Microservice Architecture Design for Failure (cont.) Learning from the Pros:
  • 46. Characteristics of a Microservice Architecture Design for Failure (cont.) Erlang's design principles: • Let it crash. • Shift the failure management one level up, where it can be managed intelligently by your orchestration or monitoring software. • Fail fast and recover fast and automatically. • Keep as many things as possible immutable.
  • 47. Characteristics of a Microservice Architecture Design for Failure (cont.) • Results into running in the wild with 9 nines uptime. • 9,99999999% uptime equals to 27ms/year downtime.
  • 48. Erlang is a classical distributed processing environment, not a microservices-based one. • Code can be reloaded to each 'service' node, they don't have a dedicated functionality like in a microservice application. • The overall architecture is more 'fluid' in terms of semantics. • A microservices-based system is a distributed system, but the other way around may not always hold true.
  • 49. Characteristics of a Microservice Architecture Evolutionary Design • Service decomposition is yet a further tool to enable application developers to control changes in their application without slowing down change. • Change control doesn't necessarily mean change reduction - with the right attitudes and tools you can make frequent, fast, and well-controlled changes to software. • The key property of a component is the notion of independent replacement and upgradeability - which implies we look for points where we can imagine rewriting a component without affecting its collaborators. • Indeed many microservice groups take this further by explicitly expecting many services to be scrapped rather than evolved in the longer term.
  • 50. Characteristics of a Microservice Architecture Evolutionary Design (cont.)
  • 51. Characteristics of a Microservice Architecture Evolutionary Design • The Guardian started their website as a monolith. • They evolve it towards a μservice architecture. • The monolith is the system's core. • New features are added as microservices that use the monolith's API. • Approach that works very well with transient features like thematic pages covering special events, polls or special issues with special UI elements and visualization.
  • 52. Characteristics of a Microservice Architecture Evolutionary Design • So evolving your design or using disposable services can be used for aims that are beyond pure engineering. For instance: • Enhanced user experience. • Easier A/B testing. • Agility in feature delivery. • Easier transition from a monolithic application.
  • 53. Another path – Self-Contained Systems (SCS) • Main concept: Instead of decomposing a monolith in microservices, you break it down to autonomous, replaceable web applications. • SCS are larger than microservices and they will be considerably less SCS than microservices originating from a monolithic application. • SCS have also separate UI, business logic and data persistence. • The preferred integration point is on the UI level and sometimes on API.
  • 54. Another path – Self-Contained Systems (SCS)
  • 55. Show Case: Kühne + Nagel FreightNet • An initially monolithic application which evolved to a 1,5 million LOCs Godzilla, with 200+ developers working on it. • It is written in an internally developed Java Web Framework. Later Spring, JSP, JQuery, Swing/ ULC, GWT/GXT where thrown in the mix. • It became extremely difficult to evolve it. • It is K+N's most valuable product, evaluated to billions of Euros. • It was a make-or-break situation for the company to keep the product manageable.
  • 56. Show Case: Kühne + Nagel FreightNet (cont.) The migration process followed was: • They stopped adding even more stuff to the monolith. • They found the seams of the monolith. • They realized that most of the seams are wishful thinking, way to complicated and inter-dependent to split. • They “desiccate” the monolith over time in spite of #3 through new projects that cover parts of some of the monolith’s functionality. • Moving to Microservices might be too much of a drastic step, especially when you have such complex monolithic software.
  • 57. Show Case: Kühne + Nagel FreightNet (cont.) • In the end, FreightNet was broken to 10 SCS, each one with ist one UI. • Mode of transport or modules offering very special functionality were the seams which became the boundaries of the SCSs. • It took them 4 years only to split the functionality from the monolith, but they see it as the only way possible to decompose a project of this order of complexity.
  • 58. Interesting resources • https://dev.otto.de/2015/09/30/on-monoliths-and-microservices/ • https://www.elastic.io/breaking-down-monolith-microservices-and-self-contained-systems/ • https://dev.otto.de/2016/03/20/why-microservices/ • http://ryanjbaxter.com/2015/07/15/using-microservices-to-build-cloud-native-applications-part- 1/ • Building Microservics, Buch 2013, O'Reilly. • The Tao of Microservices, Rodger 2016, Manning.
  • 59. Thank you very much! Have a nice weekend!

Editor's Notes

  1. Not about LoC but scope of responsibility