architecture chronicles about implementing microser vice · 2020. 4. 27. · domain driven design...
TRANSCRIPT
![Page 1: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/1.jpg)
NOBODY TOLD ME ABOUT THATNOBODY TOLD ME ABOUT THATCHRONICLES ABOUT IMPLEMENTING MICROSERVICECHRONICLES ABOUT IMPLEMENTING MICROSERVICE
ARCHITECTUREARCHITECTURE
Khaled Souf twitter: @khaledsouf
1 / 32
![Page 2: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/2.jpg)
ABOUT MEABOUT MEDeveloper/Cra�ing So�ware Coach/ DDD Expert/TrainerCo-organizer of So�ware Cra�ers Montréal meetupCo-organizer of SOCRATES Canada unconferencemore details on : https://ksouf.com
2 / 32
![Page 3: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/3.jpg)
3 / 32
![Page 4: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/4.jpg)
4 / 32
![Page 5: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/5.jpg)
I remain convinced that it is mucheasier to partition an existing,
"brownfield" system than to do so upfront with a new, greenfield system. --
Sam Newman (Author of buildingmicroservices)
5 / 32
![Page 6: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/6.jpg)
If you can’t build a well-structuredmonolith, what makes you think you
can build a well-structured set ofmicroservices? -- Simon Brown (Author
of So�ware Architecture forDevelopers)
6 / 32
![Page 7: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/7.jpg)
source microservices.io -- Chris Richardson (Author ofmicroservices Patterns)
7 / 32
![Page 8: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/8.jpg)
DOMAIN DRIVEN DESIGN TO THE RESCUE DOMAIN DRIVEN DESIGN TO THE RESCUE STRATEGIC DESIGN TO BE PRECISESTRATEGIC DESIGN TO BE PRECISE
Extract your Microservice from the monolith based on business capabilitiesCreate New Feature on new Bounded Context (Bubble Context)Use some Context Mapping Patterns for communication
8 / 32
![Page 9: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/9.jpg)
ANTI-CORRUPTION LAYER (ACL)ANTI-CORRUPTION LAYER (ACL)
9 / 32
![Page 10: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/10.jpg)
OPEN HOST SERVICE (OHS)OPEN HOST SERVICE (OHS)
10 / 32
![Page 11: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/11.jpg)
More details on: Applied Domain Driven Design OnLegacy Code
11 / 32
![Page 12: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/12.jpg)
Don't Make Microservices communicate with eachother (Directly)!!
12 / 32
![Page 13: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/13.jpg)
UNLESS YOU WANT THIS!!!UNLESS YOU WANT THIS!!!
13 / 32
![Page 14: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/14.jpg)
14 / 32
![Page 15: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/15.jpg)
HOW WE DO AVOID IT?HOW WE DO AVOID IT?Service registry: every instance of service is registered and can be found only by theregistryMicroservices publish messages to the bus to chain actionsMicroservices consumes from queues that subscribed to specific event of the messagingbusMessages are used for asynchronous commandsRegistry is used to find API's (REST for the most) for querying
15 / 32
![Page 16: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/16.jpg)
MICROSERVICE ARCHITECTURE (WITH REGISTRY &MICROSERVICE ARCHITECTURE (WITH REGISTRY &MESSAGING BUS)MESSAGING BUS)
![Page 17: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/17.jpg)
16 / 32
![Page 18: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/18.jpg)
WHAT ABOUT DATABASES?WHAT ABOUT DATABASES?Use choreography-based saga pattern (aka eventual consistency in Domain DrivenDesign).A Microservice manage his own data (shared database is Anti-Pattern).Keep two copies for starting (one in monolith/ one in microservice).
17 / 32
![Page 19: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/19.jpg)
CHOREOGRAPHY-BASED SAGA PATTERNCHOREOGRAPHY-BASED SAGA PATTERN
18 / 32
![Page 20: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/20.jpg)
BACK-END FOR FRONT-END (BFF)BACK-END FOR FRONT-END (BFF)Don't expose your Microservices directlyUse BFF as view and information aggregator for general purpose or specific customer(depends on context)Use a gateway if you're exposing BFF to something external
19 / 32
![Page 21: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/21.jpg)
BFF: GENERAL PURPOSE APIBFF: GENERAL PURPOSE API
source samnewman.io
20 / 32
![Page 22: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/22.jpg)
BFF: SPECIFIC PURPOSE APIBFF: SPECIFIC PURPOSE API
source samnewman.io
21 / 32
![Page 23: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/23.jpg)
USE CONTRACTS TESTING FOR APIUSE CONTRACTS TESTING FOR API(INSTEAD OF END TO END TESTING)(INSTEAD OF END TO END TESTING)
Let your consumer define the contract (Consumer Driven Contracts Testing)Use a contract broker to publish/verify your contracts
22 / 32
![Page 24: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/24.jpg)
CONSUMER DRIVEN CONTRACTS TESTINGCONSUMER DRIVEN CONTRACTS TESTING
23 / 32
![Page 25: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/25.jpg)
USE MICRO FRONTENDUSE MICRO FRONTEND
24 / 32
![Page 26: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/26.jpg)
INDUSTRIALIZE YOUR APPLICATIONSINDUSTRIALIZE YOUR APPLICATIONSCreate Template by Type of Project.Focus only Business Value when creating your Microservice.Define Template by used language and capabilities.Your Template should contain also you definition of build & deployment pipelines.
25 / 32
![Page 27: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/27.jpg)
LOGGINGLOGGINGUse Centralized logs solutionUse structured logsLog your input/output of your MicroserviceUse Correlation Id to monitor cross Microservices requests
26 / 32
![Page 28: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/28.jpg)
MONITORINGMONITORINGImplement always a health check for your MicroserviceCentralize your metrics in one simple dashboardUse alerting system when any weird behavior
27 / 32
![Page 29: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/29.jpg)
PROVISIONING/CONFIGURATION MANAGEMENTPROVISIONING/CONFIGURATION MANAGEMENTUse tools to manage configuration (Ansible, Saltstack, ...).build a git repository infrastructure as code to automate your provisioning.Make sure that the only possible modification of infrastructure is by modifying infra ascode.
28 / 32
![Page 30: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/30.jpg)
SECRETS MANAGEMENTSECRETS MANAGEMENTSeparate your Secrets from your configuration in a secrets server (Vault Server)Use key rotation technique to change keys periodically to prevent that a key iscompromised
29 / 32
![Page 31: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/31.jpg)
WARP-UPWARP-UPDon't start with microservicesUse Strategic Design of Domain Driven Design and Strangler Pattern to split yourmonolithdon't make microservices communicate directly (Service Registry for API Query,Messaging BUS for Command)Use Consumer Driven Contracts Technique instead of End to End TestingCentralize your cutting-edge concern (logging, monitoring, secrets, configuration,infrastructure)Automate as much as possible (infrastructure provisioning, config management, secretsmanagement,build & deployment, ..)
30 / 32
![Page 32: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/32.jpg)
BEFORE FINISHING: I DID NOT INVENTED ALL THESEBEFORE FINISHING: I DID NOT INVENTED ALL THESETECHNIQUES!!!TECHNIQUES!!!
Domain Driven DesignMicroservices Patterns (The Book)Twelve FactorDevOps Practices
31 / 32
![Page 33: ARCHITECTURE CHRONICLES ABOUT IMPLEMENTING MICROSER VICE · 2020. 4. 27. · domain driven design to the rescue ... microservice architecture (with registry & messaging bus) 16](https://reader034.vdocument.in/reader034/viewer/2022052009/601ede888cebc154024e5355/html5/thumbnails/33.jpg)
THANK YOU FOR ATTENDINGTHANK YOU FOR ATTENDINGQuestions ?twitter: @khaledsouf
32 / 32