From Monolith to Observable Microservices using DDD Maria Gomez @mariascandella Tech Principal
...
HOW?
What is Domain Driven Design? It is an approach to building software that has complex and ever- changing business requirements
Key Concepts Domain A sphere of knowledge, in fl uence, or activity. What an organisation does, and the world it does it in. Subdomains A system of abstractions describing selected aspects of a Domain. It is used to solve problems related to that Domain
Key Concepts Ubiquitous Language A Language structured around the Subdomain and used by all team members. Bounded Context An explicit boundary within which a Subdomain exists. Inside, all terms have a speci fi c meaning and are part of the Ubiquitous Language
https://martinfowler.com/bliki/BoundedContext.html
Sales Catalog Support
Event Storming Event Storming is a workshop format for quickly exploring complex business domains. http://ziobrando.blogspot.com/2013/11/introducing-event-storming.html By Henning Schwentner - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=57766348
Key Concepts Domain Event Something happened, of interest to a domain expert Command An external instruction to do something. It triggers a Domain Event. Aggregate The portion of the system that receives commands and decides whether to execute them or not, thus producing a domain event.
Choose show Choose Show seat selected Add ticket to Seat cart reserved Ticket Move to added to Accountant checkout cart Insert checkout Order data created Process Ticket Customer payment Buyer bought Service Payment confirmed Ticket sent by email
Move to checkout Add / Order Remove Order Articles created Use Promo Order code modified Promo Select added to Delivery Accountant Method Order Insert Delivery checkout Method data Promotion added Process Order Customer payment Service held Delivery Payment Address confirmed Order confirmation sent by email
What to do when bounded contexts are identified? 1. Isolate them 2. Extract them into services
Bounded Context Individual Tech Stacks & Persistence + Deploy independently = High Cohesion Microservices Isolate Failure Loose Coupling Individual Scalability Represents Business Capability
Move to checkout Add / Order Remove Order Articles created Use Promo Order code modified Promo Select added to Delivery Accountant Method Order Insert Delivery checkout Method data Promotion added Process Order Customer payment Service held Delivery Payment Address confirmed Order confirmation sent by email
Where to start? Pace of change ● Identify Performance ● Business Value Security ● Team structure ● Dependencies (internal or external) ● Technology ●
Warner Bros. [Public domain]
But, wait… We’re not done yet!
What to extract Security Testing Operations Deployment Iceberg by Oleksandr Panasovskyi from the Noun Project
Observability
“Observability is the ability to interrogate your system and get accurate answers that improve your understanding of it”
Logging Alerts Monitoring Tracing No Logs by Sweet Farm from the Noun Project Alert by ✦ Shmidt Sergey ✦ from the Noun Project traceability by Timofey Rostilov from the Noun Project
Logging Monitoring Transform Collector Query UI
Log Structured Data { CreationTime: “2017-02-24T17:49:15”, Id: “9fe0650565-3dac-425a-c83e38499c”, Host: “WEBSRVR06”, ServiceId: “MyShoppingCartService”, ComponentId: “DynamoDBWriter”, Message: “Body size exceeded 400kb limit” …. …. }
Monitoring Allows you to make informed decisions What’s relevant for each microservice and for the entire system? ● It could be not just single data points but a combination of things. ● Start with something simple and evolve as things get more complicated. ●
Semantic Monitoring
Monitoring Overload!
Alerting Things that need immediate reaction Alerts should be actionable ●
Alerting Things that need immediate reaction Alerts should be actionable ● Not all alerts need a human. Leverage automation! ●
Tracing Useful for debugging TraceId POST /pay TraceId TraceId TraceId
Tracing Useful for debugging Tracing system TraceId POST /pay TraceId TraceId TraceId
Take Away Microservices is really not a free lunch! Start by identifying business domains, DDD can help you on this. ● Don’t wait until having the perfect list of domains, they will change over time. ● Prioritize decoupling based on business value. ● Include operational concerns in your backlog (logging, monitoring, alerting & tracing) ● ○ Be intentional about things you log, monitor, and alert on ○ Proactively iterate and eliminate noise ○ Evaluate and use existing tools and libraries (ELK stack, OpenTracing, Honeycomb, Datadog, Opsgenie, etc)
Thanks! Maria Gomez @mariascandella
Recommend
More recommend