SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
Srinivasan Nanduri
Architect, Mobile Services, IBM CloudMicroservicesArchitecture
@srinivasan_n
2
•Prelude
•Overview
•Principles
•Characteristics
•Challenges
•Best practices
•References
Agenda
Prelude
4
Monolith
..an architectural style that structures the application as a
single executable unit
• Simple to develop, test & deploy
o At most one technology per layer
• Simple to scale
o Run multiple copies (horizontal
scaling) behind a load balancer
Benefits
Image source: microservices.io
5
Monolith: Problems
•Difficult to achieve operational agility
o Huge and intimidating code base for developers
o Long lead times for releasing new functionality because involves people with all skills coming
together
§ Redeploy entire unit to change one (sub) component
§ Refactoring take minutes, builds take hours, testing in Continuous Integration takes days
o Interrupts long running background (e.g. Quartz) jobs
o Increase risk of failure
•Single development stack - limits right tool for the job
•Convoluted database model
•Scaling is often a challenge
o Running a copy of the whole system is resource-intense
o Doesn’t scale with data out-of-the-box
Overview
7
Overview
..an architectural style where applications are broken into
smaller *autonomous services that work together
• Developed by small engineering teams
• Can be written in any language /
framework
Benefits
*independently developed, run and operated
Trade-off: Complexity
Image source: microservices.io
8
ConceptualTechnicalTeam
One large application that
serves the business
function
Small Independent
autonomous, auto deployable,
domain driven services of one
application
Each service is dependent on
the other
Each service has
independent stack &
de-centralized data
Organizational
UI Team DBA Team Test Team Build TeamServer Team
Service 3 team
Service 1 team
Cross Functional
Autonomous
Service teams
Embraces pure agile that
is cross functional
Every service team is small
and responsible end to
end.
Monolithvs. Microservices
Principles
10
Principles
•The term “micro” refers to the sizing
o a microservice must be manageable by a single development team (5-9 developers)
•Independent deployability
o No shared state and inter-process communication (often HTTP REST-ish interfaces)
•Functional system decomposition / vertical slicing (in contrast to horizontal
slicing through layers)
•Each microservice is functionally complete with
o Resource representation
o Data management
Microservices are fun-sized services, as in
“still fun to develop and deploy”
11
Model goodservices
•Each service should be
o Loosely coupled - a change in one should require no change in another
o Highly cohesive - related behaviour sits together, unrelated else where
§ Bounded context helps – a specific responsibility enforced by explicit boundaries. A ‘product’ is
different in the context of a catalog vs. shipping
•Each microservice handles one resource (or verb), e.g.
o Client
o Shop items
o Cart
o Checkout
Should comply with
SRP & LSP
Might be well-structured inside.
But, can only be deployed as a whole
Catalog
System
Integration
Testing
Micro services can only be deployed independently if tests are independent & if your Continuous Delivery Pipeline works
Catalog
MonolithicMicroservice
Commit Stage
Automated
Acceptance Testing
Automated
Capability Testing
Manual
Explorative Testing
Release
Release
Manual
Explorative Testing
Automated
Capability Testing
Automated
Acceptance Testing
Commit Stage
Manual
Explorative Testing
Automated
Capability Testing
Automated
Acceptance Testing
Commit Stage
Manual
Explorative Testing
Automated
Capability Testing
Automated
Acceptance Testing
Commit Stage
Manual
Explorative Testing
Automated
Capability Testing
Automated
Acceptance Testing
Commit Stage 7
Independent deployabilityiskey enablesseparationandindependentevolutionof
• codebase
• technologystacks
• scaling
• andfeatures,too
13
Independent codebase
•Each service has its own software repository
•Codebase is maintainable for developers – it fits into their brain
•Tools work fast – building, testing, refactoring code takes seconds
•Service startup only takes seconds
•No accidental cross-dependencies between code bases
Independenttechnologystacks
14
•Each service is implemented in its own technology stack
•The technology stack can be selected to fit the task best
•Teams can also experiment with new technologies within a single
microservice
•No system-wide standardized technology stack also means
•No struggle to get your technology introduced to the canon
•No piggy-pack dependencies to unnecessary technologies or libraries
•It‘s only your own dependency hell you need to struggle with
•Selected technology stacks are often very light-weight
•A microservice is often just a single process that is started via command line, and not
code and configuration that is deployed to a container.
Independentscaling
•Each microservice can be scaled independently
•Identified bottlenecks can be addressed directly
•Data sharding can be applied to microservices as
needed
•Parts of the system that do not represent bottlenecks
can remain simple and un-scaled
Scaling
Cube
horizontal&vertical
functionaldecomp.
15
Independent evolution of features
16
•Microservices can be extended without affecting other services
•For example, you can deploy a new version of (a part of) the UI without
re-deploying the whole system
•You can also go so far as to replace the service by a complete rewrite
But you have to ensure that the service interface remains stable
Stable Interfaces – standardized communication
17
•HTTP(S) – battle-tested and broadly available transport protocol
•REST – uniform interfaces on data as resources with known
manipulation means
•JSON – simple data representation format
REST and JSON are convenient because they
simplify interface evolution
Characteristics
Componentization via Services
19
•Interaction mode: share-nothing, cross-process communication
•Independently deployable (with all the benefits)
•Explicit, REST-based public interface
•Sized and designed for replaceability
•Upgrading technologies should not happen big-bang, all-or-nothing-style
•Downsides
•Communication is more expensive than in-process
•Interfaces need to be coarser-grained
•Re-allocation of responsibilities between services is harder
•Lack of tooling
•Operational complexity
FavorsCross-FunctionalTeams
Line of separation is along functional boundaries, not along tiers
VS
Presentation
Logic
DB
DataAccess
20
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
DecentralizedGovernance
Principle: focus on standardizing the relevant parts, and leverage battle-tested
standards and infrastructure
Treats differently
•What needs to be standardized
•Communication protocol (HTTP)
•Message format (JSON)
•What should be standardized
•Communication patterns (REST)
•What doesn‘t need to be standardized
•Application technology stack
21
DecentralizedDataManagement
•Create a separate database for each service
•OO Encapsulation applies to services as well
•Each service can choose the persistence solution that fits best its
•Data access patterns
•Scaling and data sharding requirements
•Only few services really need enterprisey persistence
22
InfrastructureAutomation
•The microservice architectural style assumes using continuous
Integration and continuous delivery development practices
•Continuous Delivery is much easier when the system is build of
microservices
•Having to deploy significant number of services
forces operations to automate the infrastructure for
•Deployment (Continuous Delivery)
•Monitoring (Automated failure detection)
•Managing (Automated failure recovery)
23
Challenges
How to decompose an application into services?
How to deploy an application’s services?
How to handle cross cutting concerns?
Which communication mechanisms to use?
How do external clients communicate with the services?
How does a client discover the network location of a service instance?
How to prevent a network or service failure from cascading to other services?
How to maintain data consistency and implement queries?
How to understand the behavior of an application and troubleshoot problems?
How to make testing easier?
How to implement a UI screen or page that displays data from multiple services?
Challenges
FallaciesofDistributedComputing
Essentially everyone, when they first build a distributed application, makes
the following eight assumptions. All prove to be false in the long run and all
cause big trouble and painful learning experiences.
•The network is reliable
•Latency is zero
•Bandwidth is infinite
•The network is secure
•Topology doesn‘t change
•There is one administrator
•Transport cost is zero
•The network is homogeneous
Peter Deutsch
26
MicroservicesPrerequisites
27
Before applying microservices, you should have in place
•Rapid provisioning
o Dev teams should be able to automatically provision new infrastructure
•Basic monitoring
o Essential to detect problems in the complex system landscape
•Rapid application deployment
o Service deployments must be controlled and traceable
o Rollbacks of deployments must be easy
Source
http://martinfowler.com/bliki/MicroservicePrerequisites.html
Evolvinginterfacescorrectly
28
•Microservice architectures enable independent evolution of services
– but how is this done without breaking existing clients?
•There are two answers
•Version service APIs on incompatible API changes
•Using JSON and REST limits versioning needs of service APIs
•Versioning is key
•Service interfaces are like programmer APIs – you need to know which version
you program against
•As service provider, you need to keep old versions of your interface
operational while delivering new versions
•But first, let’s recap compatibility
API Compatibility
29
There are two types of compatibility
•Forward Compatibility
•Upgrading the service in the future will not break existing clients
•Requires some agreements on future design features, and the design of new versions
to respect old interfaces
•Backward Compatibility
•Newly created service is compatible with old clients
•Requires the design of new versions to respect old interfaces
The hard type of compatibility is forward compatibility!
FurtherChallenges
30
•Testing the whole system
•A single microservice isn‘t the whole system.
•A clear picture of upstream and downstream services is needed for integration testing
•Transactions
•Instead of distributed transactions, compensations are used (as in SOA)
•Authentication
•Is often offloaded to reverse proxies making use of authentication (micro) services
•Request logging
•Pass along request tokens
•Add them to the log
•Perform log aggregation
MigrationChallenges
31
•Incrementally refactor the monolithic application
•New functionality in a new microservice
•Split frontend and backend
•Extract services
•Service discovery
Best practices
Thetwelvefactors
• Just one tool to deploy everything - as long as the microservice is in a
container, the tool knows how to deploy it.
• Docker has become the de facto standard for containers very quickly.
Deployincontainers
Patterns
Image source: microservices.io
Asynchronous calls
36
• An application based on asynchronous communication implements a
loosely coupled design, much better so than one based purely on
synchronous method calls
• An event-driven approach can make efficient use of existing
resources. Example:
o When you need to create an order, just publish an event to the bus informing that
you need an order.
• Lightweight messaging technologies (as an alternative for JMS):
o Simple messaging via Atom feeds
o Apache Kafka (http://kafka.apache.org/) - a high-throughput distributed
messaging system
• The event-driven approach is a key element of reactive programming
o In reactive programming, when you have a:=b+c assignment, and after that you
change b or c, a will change as well
Reactive Programming
37
• Alternative to imperative programming
• According to The Reactive Manifesto
(http://www.reactivemanifesto.org), RP allows developers to build
systems that are:
o Event-driven
o Scalable
o Resilient (to software, hardware or connection failures)
o Responsive (providing rich, real-time interaction with users)
• By reacting it is means to react to:
o Events
o Load
o Failures
o Users
References
SourcesandFurtherReading
39
Books:
• Continuous Delivery - Jez Humble, Dave Farley
• Working Effectively with Legacy Code - Michael Feathers
• Domain Driven Design - Eric Evans
• Your Brain atWork - David Rock
• Refactoring Databases - ScottWAmbler & Pramod Sadalage
• Building Microservices - Sam Newman
Articles/Blogs:
• http://microservices.io
• Ball of Mud: http://www.laputan.org/mud/
• Demming - http://leanandkanban.wordpress.com/2011/07/15/demings-14-points/
• Coding Horror: http://www.codinghorror.com/blog/2007/11/the-big-ball-of-mud-and-other-architectural-
disasters.html
• http://devlicio.us/blogs/casey/archive/2009/05/14/commercial-suicide-integration-at-the-database-level.aspx
•EvolutionaryArchitecture and Emergent Design: http://www.ibm.com/developerworks/java/library/j-eaed1/index.html
• Microservices: http://www.infoq.com/presentations/Micro-Services and
http://yobriefca.se/blog/2013/04/29/micro-service-architecture/ and
http://davidmorgantini.blogspot.co.uk/2013/08/micro-services-what-are-micro- services.html
SourcesandFurtherReading
40
Aritcles/Blogs:
• https://www.ibm.com/blogs/bluemix/2018/05/architecting-applications-microservices-general-principles/
• http://martinfowler.com/articles/microservices.html
• http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html
Case studies:
• https://www.nginx.com/blog/microservices-at-netflix-architectural-best-practices/
• http://highscalability.com/blog/2015/12/1/deep-lessons-from-google-and-ebay-on-building-ecosystems-of.html
• https://apiumhub.com/tech-blog-barcelona/microservices-architecture-implementation/
Thank you

Mais conteúdo relacionado

Mais procurados

Lowering the risk of monolith to microservices
Lowering the risk of monolith to microservicesLowering the risk of monolith to microservices
Lowering the risk of monolith to microservicesChristian Posta
 
Microservices in Action
Microservices in ActionMicroservices in Action
Microservices in ActionBhagwat Kumar
 
Come for the traffic management, stay for the security
Come for the traffic management, stay for the securityCome for the traffic management, stay for the security
Come for the traffic management, stay for the securityChristian Posta
 
Making sense of microservices, service mesh, and serverless
Making sense of microservices, service mesh, and serverlessMaking sense of microservices, service mesh, and serverless
Making sense of microservices, service mesh, and serverlessChristian Posta
 
Microservices and Integration: what's next with Istio service mesh
Microservices and Integration: what's next with Istio service meshMicroservices and Integration: what's next with Istio service mesh
Microservices and Integration: what's next with Istio service meshChristian Posta
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitecturePaul Mooney
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootKashif Ali Siddiqui
 
Continuous delivery by sergey seletsky
Continuous delivery by sergey seletskyContinuous delivery by sergey seletsky
Continuous delivery by sergey seletskySergey Seletsky
 
Securing the Cloud Native Stack
Securing the Cloud Native StackSecuring the Cloud Native Stack
Securing the Cloud Native StackApcera
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring BootRasheed Waraich
 
Integration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices ArchitecturesIntegration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices ArchitecturesApcera
 
Microservices Antipatterns
Microservices AntipatternsMicroservices Antipatterns
Microservices AntipatternsC4Media
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice ArchitectureEngin Yoeyen
 
Microservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got HereMicroservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got HereLightbend
 
Accelerate DevOps/Microservices and Kubernetes
Accelerate DevOps/Microservices and KubernetesAccelerate DevOps/Microservices and Kubernetes
Accelerate DevOps/Microservices and KubernetesRick Hightower
 
Evolution of integration and microservices patterns with service mesh
Evolution of integration and microservices patterns with service meshEvolution of integration and microservices patterns with service mesh
Evolution of integration and microservices patterns with service meshChristian Posta
 

Mais procurados (20)

Going Reactive in Java with Typesafe Reactive Platform
Going Reactive in Java with Typesafe Reactive PlatformGoing Reactive in Java with Typesafe Reactive Platform
Going Reactive in Java with Typesafe Reactive Platform
 
Tech Talks Microservices
Tech Talks MicroservicesTech Talks Microservices
Tech Talks Microservices
 
Lowering the risk of monolith to microservices
Lowering the risk of monolith to microservicesLowering the risk of monolith to microservices
Lowering the risk of monolith to microservices
 
Microservices in Action
Microservices in ActionMicroservices in Action
Microservices in Action
 
Come for the traffic management, stay for the security
Come for the traffic management, stay for the securityCome for the traffic management, stay for the security
Come for the traffic management, stay for the security
 
Microservices
MicroservicesMicroservices
Microservices
 
Making sense of microservices, service mesh, and serverless
Making sense of microservices, service mesh, and serverlessMaking sense of microservices, service mesh, and serverless
Making sense of microservices, service mesh, and serverless
 
Microservices and Integration: what's next with Istio service mesh
Microservices and Integration: what's next with Istio service meshMicroservices and Integration: what's next with Istio service mesh
Microservices and Integration: what's next with Istio service mesh
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic Architecture
 
Microservices with Spring
Microservices with SpringMicroservices with Spring
Microservices with Spring
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring Boot
 
Continuous delivery by sergey seletsky
Continuous delivery by sergey seletskyContinuous delivery by sergey seletsky
Continuous delivery by sergey seletsky
 
Securing the Cloud Native Stack
Securing the Cloud Native StackSecuring the Cloud Native Stack
Securing the Cloud Native Stack
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
 
Integration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices ArchitecturesIntegration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices Architectures
 
Microservices Antipatterns
Microservices AntipatternsMicroservices Antipatterns
Microservices Antipatterns
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Microservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got HereMicroservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got Here
 
Accelerate DevOps/Microservices and Kubernetes
Accelerate DevOps/Microservices and KubernetesAccelerate DevOps/Microservices and Kubernetes
Accelerate DevOps/Microservices and Kubernetes
 
Evolution of integration and microservices patterns with service mesh
Evolution of integration and microservices patterns with service meshEvolution of integration and microservices patterns with service mesh
Evolution of integration and microservices patterns with service mesh
 

Semelhante a Microservices Architecture

Understanding Microservices
Understanding Microservices Understanding Microservices
Understanding Microservices M A Hossain Tonu
 
MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.PLovababu
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to MicroservicesMahmoudZidan41
 
Software Architectures, Week 3 - Microservice-based Architectures
Software Architectures, Week 3 - Microservice-based ArchitecturesSoftware Architectures, Week 3 - Microservice-based Architectures
Software Architectures, Week 3 - Microservice-based ArchitecturesAngelos Kapsimanis
 
Iot cloud service v2.0
Iot cloud service v2.0Iot cloud service v2.0
Iot cloud service v2.0Vinod Wilson
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecturetyrantbrian
 
Serverless microservices
Serverless microservicesServerless microservices
Serverless microservicesLalit Kale
 
The "Why", "What" and "How" of Microservices
The "Why", "What" and "How" of Microservices The "Why", "What" and "How" of Microservices
The "Why", "What" and "How" of Microservices INPAY
 
How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.Markus Eisele
 
From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015Randy Shoup
 
Concurrency at Scale: Evolution to Micro-Services
Concurrency at Scale:  Evolution to Micro-ServicesConcurrency at Scale:  Evolution to Micro-Services
Concurrency at Scale: Evolution to Micro-ServicesRandy Shoup
 
Service Architectures at Scale
Service Architectures at ScaleService Architectures at Scale
Service Architectures at ScaleRandy Shoup
 
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...AFAS Software
 
The Overview of Microservices Architecture
The Overview of Microservices ArchitectureThe Overview of Microservices Architecture
The Overview of Microservices ArchitectureParia Heidari
 
SOA vs Microservices vs SBA
SOA vs Microservices vs SBASOA vs Microservices vs SBA
SOA vs Microservices vs SBAMichael Sukachev
 
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.Richard Langlois P. Eng.
 
Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?Eduard Tomàs
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
Developing Enterprise Applications for the Cloud,from Monolith to MicroservicesDeveloping Enterprise Applications for the Cloud,from Monolith to Microservices
Developing Enterprise Applications for the Cloud, from Monolith to MicroservicesDavid Currie
 

Semelhante a Microservices Architecture (20)

Microservice intro
Microservice introMicroservice intro
Microservice intro
 
Understanding Microservices
Understanding Microservices Understanding Microservices
Understanding Microservices
 
MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Deploying at will - SEI
 Deploying at will - SEI Deploying at will - SEI
Deploying at will - SEI
 
Software Architectures, Week 3 - Microservice-based Architectures
Software Architectures, Week 3 - Microservice-based ArchitecturesSoftware Architectures, Week 3 - Microservice-based Architectures
Software Architectures, Week 3 - Microservice-based Architectures
 
Iot cloud service v2.0
Iot cloud service v2.0Iot cloud service v2.0
Iot cloud service v2.0
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Serverless microservices
Serverless microservicesServerless microservices
Serverless microservices
 
The "Why", "What" and "How" of Microservices
The "Why", "What" and "How" of Microservices The "Why", "What" and "How" of Microservices
The "Why", "What" and "How" of Microservices
 
How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.
 
From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015
 
Concurrency at Scale: Evolution to Micro-Services
Concurrency at Scale:  Evolution to Micro-ServicesConcurrency at Scale:  Evolution to Micro-Services
Concurrency at Scale: Evolution to Micro-Services
 
Service Architectures at Scale
Service Architectures at ScaleService Architectures at Scale
Service Architectures at Scale
 
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...
 
The Overview of Microservices Architecture
The Overview of Microservices ArchitectureThe Overview of Microservices Architecture
The Overview of Microservices Architecture
 
SOA vs Microservices vs SBA
SOA vs Microservices vs SBASOA vs Microservices vs SBA
SOA vs Microservices vs SBA
 
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.
 
Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
Developing Enterprise Applications for the Cloud,from Monolith to MicroservicesDeveloping Enterprise Applications for the Cloud,from Monolith to Microservices
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
 

Último

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Último (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

Microservices Architecture

  • 1. Srinivasan Nanduri Architect, Mobile Services, IBM CloudMicroservicesArchitecture @srinivasan_n
  • 4. 4 Monolith ..an architectural style that structures the application as a single executable unit • Simple to develop, test & deploy o At most one technology per layer • Simple to scale o Run multiple copies (horizontal scaling) behind a load balancer Benefits Image source: microservices.io
  • 5. 5 Monolith: Problems •Difficult to achieve operational agility o Huge and intimidating code base for developers o Long lead times for releasing new functionality because involves people with all skills coming together § Redeploy entire unit to change one (sub) component § Refactoring take minutes, builds take hours, testing in Continuous Integration takes days o Interrupts long running background (e.g. Quartz) jobs o Increase risk of failure •Single development stack - limits right tool for the job •Convoluted database model •Scaling is often a challenge o Running a copy of the whole system is resource-intense o Doesn’t scale with data out-of-the-box
  • 7. 7 Overview ..an architectural style where applications are broken into smaller *autonomous services that work together • Developed by small engineering teams • Can be written in any language / framework Benefits *independently developed, run and operated Trade-off: Complexity Image source: microservices.io
  • 8. 8 ConceptualTechnicalTeam One large application that serves the business function Small Independent autonomous, auto deployable, domain driven services of one application Each service is dependent on the other Each service has independent stack & de-centralized data Organizational UI Team DBA Team Test Team Build TeamServer Team Service 3 team Service 1 team Cross Functional Autonomous Service teams Embraces pure agile that is cross functional Every service team is small and responsible end to end. Monolithvs. Microservices
  • 10. 10 Principles •The term “micro” refers to the sizing o a microservice must be manageable by a single development team (5-9 developers) •Independent deployability o No shared state and inter-process communication (often HTTP REST-ish interfaces) •Functional system decomposition / vertical slicing (in contrast to horizontal slicing through layers) •Each microservice is functionally complete with o Resource representation o Data management Microservices are fun-sized services, as in “still fun to develop and deploy”
  • 11. 11 Model goodservices •Each service should be o Loosely coupled - a change in one should require no change in another o Highly cohesive - related behaviour sits together, unrelated else where § Bounded context helps – a specific responsibility enforced by explicit boundaries. A ‘product’ is different in the context of a catalog vs. shipping •Each microservice handles one resource (or verb), e.g. o Client o Shop items o Cart o Checkout Should comply with SRP & LSP
  • 12. Might be well-structured inside. But, can only be deployed as a whole Catalog System Integration Testing Micro services can only be deployed independently if tests are independent & if your Continuous Delivery Pipeline works Catalog MonolithicMicroservice Commit Stage Automated Acceptance Testing Automated Capability Testing Manual Explorative Testing Release Release Manual Explorative Testing Automated Capability Testing Automated Acceptance Testing Commit Stage Manual Explorative Testing Automated Capability Testing Automated Acceptance Testing Commit Stage Manual Explorative Testing Automated Capability Testing Automated Acceptance Testing Commit Stage Manual Explorative Testing Automated Capability Testing Automated Acceptance Testing Commit Stage 7 Independent deployabilityiskey enablesseparationandindependentevolutionof • codebase • technologystacks • scaling • andfeatures,too
  • 13. 13 Independent codebase •Each service has its own software repository •Codebase is maintainable for developers – it fits into their brain •Tools work fast – building, testing, refactoring code takes seconds •Service startup only takes seconds •No accidental cross-dependencies between code bases
  • 14. Independenttechnologystacks 14 •Each service is implemented in its own technology stack •The technology stack can be selected to fit the task best •Teams can also experiment with new technologies within a single microservice •No system-wide standardized technology stack also means •No struggle to get your technology introduced to the canon •No piggy-pack dependencies to unnecessary technologies or libraries •It‘s only your own dependency hell you need to struggle with •Selected technology stacks are often very light-weight •A microservice is often just a single process that is started via command line, and not code and configuration that is deployed to a container.
  • 15. Independentscaling •Each microservice can be scaled independently •Identified bottlenecks can be addressed directly •Data sharding can be applied to microservices as needed •Parts of the system that do not represent bottlenecks can remain simple and un-scaled Scaling Cube horizontal&vertical functionaldecomp. 15
  • 16. Independent evolution of features 16 •Microservices can be extended without affecting other services •For example, you can deploy a new version of (a part of) the UI without re-deploying the whole system •You can also go so far as to replace the service by a complete rewrite But you have to ensure that the service interface remains stable
  • 17. Stable Interfaces – standardized communication 17 •HTTP(S) – battle-tested and broadly available transport protocol •REST – uniform interfaces on data as resources with known manipulation means •JSON – simple data representation format REST and JSON are convenient because they simplify interface evolution
  • 19. Componentization via Services 19 •Interaction mode: share-nothing, cross-process communication •Independently deployable (with all the benefits) •Explicit, REST-based public interface •Sized and designed for replaceability •Upgrading technologies should not happen big-bang, all-or-nothing-style •Downsides •Communication is more expensive than in-process •Interfaces need to be coarser-grained •Re-allocation of responsibilities between services is harder •Lack of tooling •Operational complexity
  • 20. FavorsCross-FunctionalTeams Line of separation is along functional boundaries, not along tiers VS Presentation Logic DB DataAccess 20 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
  • 21. DecentralizedGovernance Principle: focus on standardizing the relevant parts, and leverage battle-tested standards and infrastructure Treats differently •What needs to be standardized •Communication protocol (HTTP) •Message format (JSON) •What should be standardized •Communication patterns (REST) •What doesn‘t need to be standardized •Application technology stack 21
  • 22. DecentralizedDataManagement •Create a separate database for each service •OO Encapsulation applies to services as well •Each service can choose the persistence solution that fits best its •Data access patterns •Scaling and data sharding requirements •Only few services really need enterprisey persistence 22
  • 23. InfrastructureAutomation •The microservice architectural style assumes using continuous Integration and continuous delivery development practices •Continuous Delivery is much easier when the system is build of microservices •Having to deploy significant number of services forces operations to automate the infrastructure for •Deployment (Continuous Delivery) •Monitoring (Automated failure detection) •Managing (Automated failure recovery) 23
  • 25. How to decompose an application into services? How to deploy an application’s services? How to handle cross cutting concerns? Which communication mechanisms to use? How do external clients communicate with the services? How does a client discover the network location of a service instance? How to prevent a network or service failure from cascading to other services? How to maintain data consistency and implement queries? How to understand the behavior of an application and troubleshoot problems? How to make testing easier? How to implement a UI screen or page that displays data from multiple services? Challenges
  • 26. FallaciesofDistributedComputing Essentially everyone, when they first build a distributed application, makes the following eight assumptions. All prove to be false in the long run and all cause big trouble and painful learning experiences. •The network is reliable •Latency is zero •Bandwidth is infinite •The network is secure •Topology doesn‘t change •There is one administrator •Transport cost is zero •The network is homogeneous Peter Deutsch 26
  • 27. MicroservicesPrerequisites 27 Before applying microservices, you should have in place •Rapid provisioning o Dev teams should be able to automatically provision new infrastructure •Basic monitoring o Essential to detect problems in the complex system landscape •Rapid application deployment o Service deployments must be controlled and traceable o Rollbacks of deployments must be easy Source http://martinfowler.com/bliki/MicroservicePrerequisites.html
  • 28. Evolvinginterfacescorrectly 28 •Microservice architectures enable independent evolution of services – but how is this done without breaking existing clients? •There are two answers •Version service APIs on incompatible API changes •Using JSON and REST limits versioning needs of service APIs •Versioning is key •Service interfaces are like programmer APIs – you need to know which version you program against •As service provider, you need to keep old versions of your interface operational while delivering new versions •But first, let’s recap compatibility
  • 29. API Compatibility 29 There are two types of compatibility •Forward Compatibility •Upgrading the service in the future will not break existing clients •Requires some agreements on future design features, and the design of new versions to respect old interfaces •Backward Compatibility •Newly created service is compatible with old clients •Requires the design of new versions to respect old interfaces The hard type of compatibility is forward compatibility!
  • 30. FurtherChallenges 30 •Testing the whole system •A single microservice isn‘t the whole system. •A clear picture of upstream and downstream services is needed for integration testing •Transactions •Instead of distributed transactions, compensations are used (as in SOA) •Authentication •Is often offloaded to reverse proxies making use of authentication (micro) services •Request logging •Pass along request tokens •Add them to the log •Perform log aggregation
  • 31. MigrationChallenges 31 •Incrementally refactor the monolithic application •New functionality in a new microservice •Split frontend and backend •Extract services •Service discovery
  • 34. • Just one tool to deploy everything - as long as the microservice is in a container, the tool knows how to deploy it. • Docker has become the de facto standard for containers very quickly. Deployincontainers
  • 36. Asynchronous calls 36 • An application based on asynchronous communication implements a loosely coupled design, much better so than one based purely on synchronous method calls • An event-driven approach can make efficient use of existing resources. Example: o When you need to create an order, just publish an event to the bus informing that you need an order. • Lightweight messaging technologies (as an alternative for JMS): o Simple messaging via Atom feeds o Apache Kafka (http://kafka.apache.org/) - a high-throughput distributed messaging system • The event-driven approach is a key element of reactive programming o In reactive programming, when you have a:=b+c assignment, and after that you change b or c, a will change as well
  • 37. Reactive Programming 37 • Alternative to imperative programming • According to The Reactive Manifesto (http://www.reactivemanifesto.org), RP allows developers to build systems that are: o Event-driven o Scalable o Resilient (to software, hardware or connection failures) o Responsive (providing rich, real-time interaction with users) • By reacting it is means to react to: o Events o Load o Failures o Users
  • 39. SourcesandFurtherReading 39 Books: • Continuous Delivery - Jez Humble, Dave Farley • Working Effectively with Legacy Code - Michael Feathers • Domain Driven Design - Eric Evans • Your Brain atWork - David Rock • Refactoring Databases - ScottWAmbler & Pramod Sadalage • Building Microservices - Sam Newman Articles/Blogs: • http://microservices.io • Ball of Mud: http://www.laputan.org/mud/ • Demming - http://leanandkanban.wordpress.com/2011/07/15/demings-14-points/ • Coding Horror: http://www.codinghorror.com/blog/2007/11/the-big-ball-of-mud-and-other-architectural- disasters.html • http://devlicio.us/blogs/casey/archive/2009/05/14/commercial-suicide-integration-at-the-database-level.aspx •EvolutionaryArchitecture and Emergent Design: http://www.ibm.com/developerworks/java/library/j-eaed1/index.html • Microservices: http://www.infoq.com/presentations/Micro-Services and http://yobriefca.se/blog/2013/04/29/micro-service-architecture/ and http://davidmorgantini.blogspot.co.uk/2013/08/micro-services-what-are-micro- services.html
  • 40. SourcesandFurtherReading 40 Aritcles/Blogs: • https://www.ibm.com/blogs/bluemix/2018/05/architecting-applications-microservices-general-principles/ • http://martinfowler.com/articles/microservices.html • http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html Case studies: • https://www.nginx.com/blog/microservices-at-netflix-architectural-best-practices/ • http://highscalability.com/blog/2015/12/1/deep-lessons-from-google-and-ebay-on-building-ecosystems-of.html • https://apiumhub.com/tech-blog-barcelona/microservices-architecture-implementation/