SlideShare a Scribd company logo
1 of 30
Introduction to
Microservices
By Mahmoud Zidan
Software life cycle
2 16 May 2019
Gathering requirements.
The goal of analysis is to determine where the problem is, in an attempt to fix the system.
Plan sprint to meet requirements in given time. Operations are described in detail including
business rules, process diagrams, etc. The output of this stage will describe the new
system as a collection of modules or subsystems.
The real code is written here.
All the pieces are brought together into a special testing environment, then checked for
errors, bugs, and interoperability.
Putting a release into production
Doing health checks
Checking time for requests and responses …
Plan & design
Development
Testing
Analysis
Release
Monitor
What is a Microservice?
• “The microservice architectural style is an approach to develop single application as a suite of small services,
each running in its own process & communication with light weight mechanism.” . James Lewis & Martin
Fowler.
• “Microservices are SMALL & AUTONOMUS services that work together”. Book - Building Microservices, Sam
Neuman.
• There is no specific technology used to build MS.
• Some Principles and architectural patterns are used to build MS.
3 16 May 2019
Microservice overview
Micro
• Big/small, who decide ?
• Is it the number of lines in code ?
• Is it the number of developers in
team?
• There is no universal measure . One
microservice should do ONE THING
& do it well.
• It is micro because of the scope of
functionality not line of code.
• Subdomains should be identified to
know the scope of functionality.
• Bounded context
• Should be built around business
capability
Microservice overview
Service
• It is an independently deployed component for bounded context.
• Interoperability.
• Uses message based communication.
• Independent from technologies.
• Simply it is SOA
Monolithic application
Simply a monolithic application consists of
• Model
• Single database
• User interface
• APIs can be exposed for third parties
• You can have more than one instance running behind load balancer
Monolithic application
Front end
user
Address
Order
Invoice Product Category
Supplier
Monolithic application
Pros
• Simple to build
• Simple to test
• Simple to deploy
• Simple to scale
• Multiple instances
• Simple to develop
• Limited to one language.
Cons
• The bigger the app, the bigger the team.
• New team members productivity is low.
• Code harder to understand & modify.
• Not updated with new technologies.
• Startup of app will take long time.
• Scale for bad reasons
• Need more CPU for calculating invoices, you will
scale the whole app.
Monolithic application
• Taking monolithic app and dividing it to smaller services will lead to:
• Concentrating on something smaller
• Software life cycle is still the same, but moves faster.
• Smaller teams
• Small services will live side by side.
Moving to Microservice
• Microservice should be “Domain Driven Design”.
• Taking the monolith application and moving to domain driven design
• Domain:
• E-commerce
• Sub-domains:
• User: Auth, profile, address,…
• Order: invoices, discount,…
• Product: Prodcuts, suppliers,…
• Dependencies:
• Sub domians should be totally independent. If you find any dependencies duplicating entities is
required.
Moving to Microservice
Front end
user
Address
Order
Invoice
Product
Category
Supplier
user
Product
Moving to Microservice
• Organization
• Teams will be divided by subdomain not domain
• Right sized team for each subdomain
• Each team will be solely responsible for their final product
• Each team should be independent, but the communication between them should be
handled by management
• Each team should have their own repo.
Moving to Microservice
• Data store
• Each MS should have its own database
• Example:
• Product: relational database
• Order: NoSQL
• User: LDAP
• Problem ?!
• If user changes his address it should be replicated in the entity found in order sub-domain.
• In MS world there is no distributed transaction [ in same transaction you update more than 1 table in
different databases] due to performance issures
• Therefore, data is not immediately consistent.
Moving to Microservice
• Data store
• Solution for data sync is using change data capture or event sourcing pattern.
• Both are ways of modeling data, especially at scale, using a combination of a mutable database.
• Service publishes event when data changes and other services will consume the event and
update data.
• Kafka can be used for keeping data in sync
• UI
• Composition pattern can be used to be consistent
• Client side
• Server side
Moving to Microservice
• Services
• Communication
• Remote Procedure Invocation/call (RPC):
User Order Product
• Request / reply principle (purchase request product price)
• Can be sync/async
• REST or SOAP can be used
Moving to Microservice
• Services
• Communication
• Messaging:
• Message or events
• On broker or channel
• MS can publish an event & the MS who is in need can subscribe to broker & receive the message at a later
time
• Kafka can be used also.
User ProductOrder
Broker
Moving to Microservice
• Services
• Communication
• Using any of the two methods you need protocol format exchange
• Text (JSON, XML,…) readable and easy to implement
• Binary (gRPC) more compact
• MSs need contracts to know the APIs of other MSs.
• Example: WSDLs & Swagger files.
Moving to Microservice
• Distributed services
• MSs are deployed where there network locations are changed dynamically.
QUESTION?
How can MSs communicate with each other when there locations are changed
dynamically ?
ANSWER
Service registery
Moving to Microservice
• Distributed services
• Service registry
• It is a phonebook of services
• MSs should register them selves on startup and at shutdown
• You can lookup by their logical names
• Product: 127.0.0.1:8080
• Eureca can be used for this
Moving to Microservice
• Distributed services
• Best way for FE to call MS is putting an API gateway
Front end
user Order Product
API Gateway
Moving to Microservice
• Distributed services
• Best way for FE to call MS is putting an API gateway
• Unified interface
• Can control the cross cutting functionalities (Authentication, Authorization, register, …)
• API translation
Moving to Microservice
• Security
• Use identity and access mangement for authentication and authorization.
• Once signed in Access-token can be used to move from one MS to another
• Scalability
• You can scale one MS or more.
• Scaling can be:
• Vertical:
• adding more power to existing machine (more CPU/RAM …)
• Horizontal:
• replicate more machines. i.e. several instances
• Client load balancing will choose from registry. (using round robin for example)
Product1: x.y.z:80
Product2: a.b.c:81
Moving to Microservice
• Availability
• Minutes is up and operational
• We have in this architecture some single point of failures
• Broker
• API Gateway
• Registry
• ALL POF should be scaled horizontally (multiple instances) & clustered to be in sync
Moving to Microservice
• Monitoring
• Should be centralized
• Use log aggregation (Log stash can be used)
• Should be visual in dashboard (Splunk/ Kibana can be used)
• Health check
• Service running. Cant handle requests. Should show database status, available space,…
• Record exceptions in tracker system cyntralized
• Gather statistics (DropWizard can be used)
• Limit traffic to defend DOS attachks
• A coorelation id (transaction_id) for the journey of the request (dapper can be used)
Moving to Microservice
• Deployment
• Can be on physical or virtual servers (still physical but can control CPU/RAM)
• MS should be packaged with its dependencies in container image & deployed as a
container
• Images can be easily moved from one environment to another. ( Docker to be used)
• Kubernetes is used to orchestrate the contianers
• Jenkins is used for continuous delivery
• There should be an external configuration for diff environments
• Putting debug mode in dev environment only
• Activating new functionality through configuration
Challenges
• Business concerns
• Integration between teams is difficult
• Many trainings need to be done as different dev. Stacks
• There is no standard in MS.
• Solution will rely on some standards (HTTP,SQL,..) but not standard stack.
• There is no single framework, but there is an integration of different technologies
• No single support
• Cost
• Small team
• Cheap start, cheap deployments on cloud
• Time
• Faster to market.
Challenges
• Technical concerns
• Design
• How to partition the system to services (invoices could’ve been services)
• How small !?
• Technical diversity
• Choose programming language
• Right database
• Distribution
• Communication over network
• How to deal with network failures (circuit breaker)
• Data store
• Database per subdomain
• Keep data in sync
• Security
• Access token renewal
Challenges
• Technical concerns
• Testing
• Less code will be tested
• Test in isolation
• Integration testing is hard
• Maintenance
• Less code to maintain
• Less code to understand
• Extensibility
• New feature, new MS
When to use MS ?
Time to market Extensibility
Replicability Scalability
Thank You

More Related Content

What's hot

What's hot (20)

Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architecture
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Introduction To Microservices
Introduction To MicroservicesIntroduction To Microservices
Introduction To Microservices
 
Monoliths and Microservices
Monoliths and Microservices Monoliths and Microservices
Monoliths and Microservices
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Microservice intro
Microservice introMicroservice intro
Microservice intro
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018
 
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
 
MicroService Architecture
MicroService ArchitectureMicroService Architecture
MicroService Architecture
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architecture
 
Introducing DevOps
Introducing DevOpsIntroducing DevOps
Introducing DevOps
 
Microservices
MicroservicesMicroservices
Microservices
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principles
 
Micro services Architecture
Micro services ArchitectureMicro services Architecture
Micro services Architecture
 

Similar to Introduction to Microservices

Similar to Introduction to Microservices (20)

Understanding Microservices
Understanding Microservices Understanding Microservices
Understanding Microservices
 
The Overview of Microservices Architecture
The Overview of Microservices ArchitectureThe Overview of Microservices Architecture
The Overview of Microservices Architecture
 
Serverless microservices
Serverless microservicesServerless microservices
Serverless microservices
 
QCon 2015 - Microservices Track Notes
QCon 2015 - Microservices Track Notes QCon 2015 - Microservices Track Notes
QCon 2015 - Microservices Track Notes
 
Microservices - opportunities, dilemmas and problems
Microservices - opportunities, dilemmas and problemsMicroservices - opportunities, dilemmas and problems
Microservices - opportunities, dilemmas and problems
 
Iot cloud service v2.0
Iot cloud service v2.0Iot cloud service v2.0
Iot cloud service v2.0
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Tokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup #5 - Microservices and Azure Service FabricTokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup #5 - Microservices and Azure Service Fabric
 
Do I Need A Service Mesh.pptx
Do I Need A Service Mesh.pptxDo I Need A Service Mesh.pptx
Do I Need A Service Mesh.pptx
 
Grokking microservices in 5 minutes
Grokking microservices in 5 minutesGrokking microservices in 5 minutes
Grokking microservices in 5 minutes
 
Microservices vs monolithics betabeers
Microservices vs monolithics   betabeersMicroservices vs monolithics   betabeers
Microservices vs monolithics betabeers
 
Micro service session 1
Micro service   session 1Micro service   session 1
Micro service session 1
 
Designing Microservices
Designing MicroservicesDesigning Microservices
Designing Microservices
 
SOA vs Microservices vs SBA
SOA vs Microservices vs SBASOA vs Microservices vs SBA
SOA vs Microservices vs SBA
 
Exploring microservices in a Microsoft landscape
Exploring microservices in a Microsoft landscapeExploring microservices in a Microsoft landscape
Exploring microservices in a Microsoft landscape
 
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...
 
MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Micro services and Containers
Micro services and ContainersMicro services and Containers
Micro services and Containers
 
Testing the Migration of Monolithic Applications to Microservices on the Cloud
Testing the Migration of Monolithic Applications to Microservices on the CloudTesting the Migration of Monolithic Applications to Microservices on the Cloud
Testing the Migration of Monolithic Applications to Microservices on the Cloud
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Recently uploaded (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 

Introduction to Microservices

  • 2. Software life cycle 2 16 May 2019 Gathering requirements. The goal of analysis is to determine where the problem is, in an attempt to fix the system. Plan sprint to meet requirements in given time. Operations are described in detail including business rules, process diagrams, etc. The output of this stage will describe the new system as a collection of modules or subsystems. The real code is written here. All the pieces are brought together into a special testing environment, then checked for errors, bugs, and interoperability. Putting a release into production Doing health checks Checking time for requests and responses … Plan & design Development Testing Analysis Release Monitor
  • 3. What is a Microservice? • “The microservice architectural style is an approach to develop single application as a suite of small services, each running in its own process & communication with light weight mechanism.” . James Lewis & Martin Fowler. • “Microservices are SMALL & AUTONOMUS services that work together”. Book - Building Microservices, Sam Neuman. • There is no specific technology used to build MS. • Some Principles and architectural patterns are used to build MS. 3 16 May 2019
  • 4. Microservice overview Micro • Big/small, who decide ? • Is it the number of lines in code ? • Is it the number of developers in team? • There is no universal measure . One microservice should do ONE THING & do it well. • It is micro because of the scope of functionality not line of code. • Subdomains should be identified to know the scope of functionality. • Bounded context • Should be built around business capability
  • 5. Microservice overview Service • It is an independently deployed component for bounded context. • Interoperability. • Uses message based communication. • Independent from technologies. • Simply it is SOA
  • 6. Monolithic application Simply a monolithic application consists of • Model • Single database • User interface • APIs can be exposed for third parties • You can have more than one instance running behind load balancer
  • 8. Monolithic application Pros • Simple to build • Simple to test • Simple to deploy • Simple to scale • Multiple instances • Simple to develop • Limited to one language. Cons • The bigger the app, the bigger the team. • New team members productivity is low. • Code harder to understand & modify. • Not updated with new technologies. • Startup of app will take long time. • Scale for bad reasons • Need more CPU for calculating invoices, you will scale the whole app.
  • 9. Monolithic application • Taking monolithic app and dividing it to smaller services will lead to: • Concentrating on something smaller • Software life cycle is still the same, but moves faster. • Smaller teams • Small services will live side by side.
  • 10. Moving to Microservice • Microservice should be “Domain Driven Design”. • Taking the monolith application and moving to domain driven design • Domain: • E-commerce • Sub-domains: • User: Auth, profile, address,… • Order: invoices, discount,… • Product: Prodcuts, suppliers,… • Dependencies: • Sub domians should be totally independent. If you find any dependencies duplicating entities is required.
  • 11. Moving to Microservice Front end user Address Order Invoice Product Category Supplier user Product
  • 12. Moving to Microservice • Organization • Teams will be divided by subdomain not domain • Right sized team for each subdomain • Each team will be solely responsible for their final product • Each team should be independent, but the communication between them should be handled by management • Each team should have their own repo.
  • 13. Moving to Microservice • Data store • Each MS should have its own database • Example: • Product: relational database • Order: NoSQL • User: LDAP • Problem ?! • If user changes his address it should be replicated in the entity found in order sub-domain. • In MS world there is no distributed transaction [ in same transaction you update more than 1 table in different databases] due to performance issures • Therefore, data is not immediately consistent.
  • 14. Moving to Microservice • Data store • Solution for data sync is using change data capture or event sourcing pattern. • Both are ways of modeling data, especially at scale, using a combination of a mutable database. • Service publishes event when data changes and other services will consume the event and update data. • Kafka can be used for keeping data in sync • UI • Composition pattern can be used to be consistent • Client side • Server side
  • 15. Moving to Microservice • Services • Communication • Remote Procedure Invocation/call (RPC): User Order Product • Request / reply principle (purchase request product price) • Can be sync/async • REST or SOAP can be used
  • 16. Moving to Microservice • Services • Communication • Messaging: • Message or events • On broker or channel • MS can publish an event & the MS who is in need can subscribe to broker & receive the message at a later time • Kafka can be used also. User ProductOrder Broker
  • 17. Moving to Microservice • Services • Communication • Using any of the two methods you need protocol format exchange • Text (JSON, XML,…) readable and easy to implement • Binary (gRPC) more compact • MSs need contracts to know the APIs of other MSs. • Example: WSDLs & Swagger files.
  • 18. Moving to Microservice • Distributed services • MSs are deployed where there network locations are changed dynamically. QUESTION? How can MSs communicate with each other when there locations are changed dynamically ? ANSWER Service registery
  • 19. Moving to Microservice • Distributed services • Service registry • It is a phonebook of services • MSs should register them selves on startup and at shutdown • You can lookup by their logical names • Product: 127.0.0.1:8080 • Eureca can be used for this
  • 20. Moving to Microservice • Distributed services • Best way for FE to call MS is putting an API gateway Front end user Order Product API Gateway
  • 21. Moving to Microservice • Distributed services • Best way for FE to call MS is putting an API gateway • Unified interface • Can control the cross cutting functionalities (Authentication, Authorization, register, …) • API translation
  • 22. Moving to Microservice • Security • Use identity and access mangement for authentication and authorization. • Once signed in Access-token can be used to move from one MS to another • Scalability • You can scale one MS or more. • Scaling can be: • Vertical: • adding more power to existing machine (more CPU/RAM …) • Horizontal: • replicate more machines. i.e. several instances • Client load balancing will choose from registry. (using round robin for example) Product1: x.y.z:80 Product2: a.b.c:81
  • 23. Moving to Microservice • Availability • Minutes is up and operational • We have in this architecture some single point of failures • Broker • API Gateway • Registry • ALL POF should be scaled horizontally (multiple instances) & clustered to be in sync
  • 24. Moving to Microservice • Monitoring • Should be centralized • Use log aggregation (Log stash can be used) • Should be visual in dashboard (Splunk/ Kibana can be used) • Health check • Service running. Cant handle requests. Should show database status, available space,… • Record exceptions in tracker system cyntralized • Gather statistics (DropWizard can be used) • Limit traffic to defend DOS attachks • A coorelation id (transaction_id) for the journey of the request (dapper can be used)
  • 25. Moving to Microservice • Deployment • Can be on physical or virtual servers (still physical but can control CPU/RAM) • MS should be packaged with its dependencies in container image & deployed as a container • Images can be easily moved from one environment to another. ( Docker to be used) • Kubernetes is used to orchestrate the contianers • Jenkins is used for continuous delivery • There should be an external configuration for diff environments • Putting debug mode in dev environment only • Activating new functionality through configuration
  • 26. Challenges • Business concerns • Integration between teams is difficult • Many trainings need to be done as different dev. Stacks • There is no standard in MS. • Solution will rely on some standards (HTTP,SQL,..) but not standard stack. • There is no single framework, but there is an integration of different technologies • No single support • Cost • Small team • Cheap start, cheap deployments on cloud • Time • Faster to market.
  • 27. Challenges • Technical concerns • Design • How to partition the system to services (invoices could’ve been services) • How small !? • Technical diversity • Choose programming language • Right database • Distribution • Communication over network • How to deal with network failures (circuit breaker) • Data store • Database per subdomain • Keep data in sync • Security • Access token renewal
  • 28. Challenges • Technical concerns • Testing • Less code will be tested • Test in isolation • Integration testing is hard • Maintenance • Less code to maintain • Less code to understand • Extensibility • New feature, new MS
  • 29. When to use MS ? Time to market Extensibility Replicability Scalability