Microservices Design Module Overview Microservices Design Principles Approach

  • Slides: 25
Download presentation
Microservices Design

Microservices Design

Module Overview Microservices Design Principles Approach

Module Overview Microservices Design Principles Approach

Microservices Design Principles |Approach

Microservices Design Principles |Approach

Approach: High Cohesion Identify a single focus • Business function Business domain • Accounts

Approach: High Cohesion Identify a single focus • Business function Business domain • Accounts UI • Split into finer grained services • Avoid “Is kind of the same” • ? CRUD Accounts Service ? ? Gen? erate Invoice Don't get lazy! • ? ? Don’t be afraid to create many services • Question in codepeer reviews • Accounts Database Can this change for more than one reason •

Approach: High Cohesion Identify a single focus • Business function Business domain • •

Approach: High Cohesion Identify a single focus • Business function Business domain • • Accounts UI Split into finer grained services • Avoid “Is kind of the same” • Don't get lazy! • Accounts Invoicing Service Accounts Database Don’t be afraid to create many services • Invoicing Database Question in codepeer reviews • Can this change for more than one reason •

Approach: High Cohesion Identify a single focus • Business function Business domain • •

Approach: High Cohesion Identify a single focus • Business function Business domain • • Accounts UI Split into finer grained services • Avoid “Is kind of the same” • Accounts EDI Invoicing Service EDI Invoicing Database Don't get lazy! Accounts Invoicing Service Accounts Database • Invoicing Database Don’t be afraid to create many services • Question in codepeer reviews • Can this change for more than one reason •

Approach: Autonomous Loosely coupled • Accounts EDI Invoicing Service Communication by network • Synchronous

Approach: Autonomous Loosely coupled • Accounts EDI Invoicing Service Communication by network • Synchronous Asynchronous • EDI Invoicing Database • Publish events Subscribe to events • • Technology agnostic API • Network Avoid client libraries • Contracts between services • Fixed and agreed interfaces Shared models Clear input and output • • • Accounts Service Accounts Database Avoid chatty exchanges between services • Avoid sharing between services • Databases Shared libraries • •

Approach: Autonomous Loosely coupled • Communication by network • Order Service Synchronous Asynchronous •

Approach: Autonomous Loosely coupled • Communication by network • Order Service Synchronous Asynchronous • • Order Database 1 Publish events Subscribe to events • • Technology agnostic API • Avoid client libraries Network • Contracts between services • Fixed and agreed interfaces Shared models Clear input and output • … 2 • • Accounts Service Avoid chatty exchanges between services • Avoid sharing between services • Accounts Databases Shared libraries • •

Approach: Autonomous Loosely coupled • Communication by network Order Service • Synchronous Asynchronous •

Approach: Autonomous Loosely coupled • Communication by network Order Service • Synchronous Asynchronous • Order Database • Publish events Subscribe to events • • Technology agnostic API • Network Message Broker Avoid client libraries • Contracts between services • Fixed and agreed interfaces Shared models Clear input and output • • • Accounts Service Avoid chatty exchanges between services • Avoid sharing between services • Accounts Databases Shared libraries • •

Approach: Autonomous Loosely coupled • Communication by network • Synchronous Asynchronous • Order Service

Approach: Autonomous Loosely coupled • Communication by network • Synchronous Asynchronous • Order Service • Order Internal Model Publish events Subscribe to events • • Fixed contract Order Shared Model Technology agnostic API • Avoid client libraries • Contracts between services • Fixed and agreed interfaces Shared models Clear input and output • Fixed contract • • Accounts Service Avoid chatty exchanges between services • Avoid sharing between services • Databases Shared libraries • •

Approach: Autonomous Loosely coupled • Communication by network • Synchronous Asynchronous • Order Service

Approach: Autonomous Loosely coupled • Communication by network • Synchronous Asynchronous • Order Service Accounts Client Library • Publish events Subscribe to events • • Technology agnostic API • Avoid client libraries • Contracts between services • Fixed and agreed interfaces Shared models Clear input and output • • Accounts Service • Avoid chatty exchanges between services • Avoid sharing between services • Databases Shared libraries • •

Approach: Autonomous Loosely coupled • Communication by network • Synchronous Asynchronous Order Service •

Approach: Autonomous Loosely coupled • Communication by network • Synchronous Asynchronous Order Service • • Publish events Subscribe to events • • Technology agnostic API • Avoid client libraries • Contracts between services • Fixed and agreed interfaces Shared models Clear input and output • • • Accounts Service Avoid chatty exchanges between services • Avoid sharing between services • Databases Shared libraries • •

Approach: Autonomous Loosely coupled • Communication by network Order Service • Synchronous Asynchronous •

Approach: Autonomous Loosely coupled • Communication by network Order Service • Synchronous Asynchronous • • Publish events Subscribe to events • • Technology agnostic API • Network Shared Database Avoid client libraries • Contracts between services • Fixed and agreed interfaces Shared models Clear input and output • • • Avoid chatty exchanges between services • Accounts Service Avoid sharing between services • Databases Shared libraries • •

Approach: Autonomous Loosely coupled • . Net based Service Communication by network • Synchronous

Approach: Autonomous Loosely coupled • . Net based Service Communication by network • Synchronous Asynchronous • SQL Server Database • Publish events Subscribe to events • • Technology agnostic API • REST over HTTP and data in JSON Avoid client libraries • Contracts between services • Fixed and agreed interfaces Shared models Clear input and output • • • Avoid chatty exchanges between services • Java based service my. SQL Database Avoid sharing between services • Databases Shared libraries • •

Approach: Autonomous Microservice ownership by team • Responsibility to make autonomous • Green Team

Approach: Autonomous Microservice ownership by team • Responsibility to make autonomous • Green Team Agreeing contracts between teams • Responsible for long-term maintenance Accounts Service • Collaborative development • Red Team Communicate contract requirements Communicate data requirements • • Postage Service Concurrent development • Versioning • Avoid breaking changes Orders Service • Backwards compatibility • Integration tests • Have a versioning strategy • Pink Team Stock Service Concurrent versions Old and new Semantic versioning Major. Minor. Patch (e. g. 15. 1. 2) Coexisting endpoints /V 2/customer/ • • • Purple Team •

Approach: Autonomous Microservice ownership by team • Responsibility to make autonomous • Agreeing contracts

Approach: Autonomous Microservice ownership by team • Responsibility to make autonomous • Agreeing contracts between teams • Responsible for long-term maintenance Order Service • Collaborative development • New Order Model Communicate contract requirements Communicate data requirements • • Contract Change Concurrent development • Versioning • Avoid breaking changes • Order Model Backwards compatibility • Integration tests • Have a versioning strategy • Concurrent versions Old and new Semantic versioning Major. Minor. Patch (e. g. 15. 1. 2) Coexisting endpoints /V 2/customer/ • • Accounts Service • •

Approach: Business Domain Centric Business function or business domain • Approach • Identify business

Approach: Business Domain Centric Business function or business domain • Approach • Identify business domains in a coarse manner Review sub groups of business functions or areas Review benefits of splitting further Agree a common language • Accounts Domain Marketing Domain • • • Microservices for data (CRUD) or functions • Fix incorrect boundaries • Sales Domain Merge or split • Explicit interfaces for outside world • Splitting using technical boundaries • Service to access archive data For performance tuning • •

Approach: Business Domain Centric Business function or business domain • Approach • Identify business

Approach: Business Domain Centric Business function or business domain • Approach • Identify business domains in a coarse manner Review sub groups of business functions or areas Review benefits of splitting further Agree a common language • • • Accounts Domain • Microservices for data (CRUD) or functions • Fix incorrect boundaries • Merge or split • Explicit interfaces for outside world • Splitting using technical boundaries • Service to access archive data For performance tuning • •

Approach: Business Domain Centric Business function or business domain • Approach • Identify business

Approach: Business Domain Centric Business function or business domain • Approach • Identify business domains in a coarse manner Review sub groups of business functions or areas Review benefits of splitting further Agree a common language • Account s CRUD Service EDI Invoice Service • • • Account s Domain Invoice Generation Service Microservices for data (CRUD) or functions • Fix incorrect boundaries • Expenses Service Merge or split • Explicit interfaces for outside world • Splitting using technical boundaries • Service to access archive data For performance tuning • •

Approach: Resilience Design for known failures • Failure of downstream systems • Accounts Service

Approach: Resilience Design for known failures • Failure of downstream systems • Accounts Service Other services internal or external • Postage Service ! Degrade functionality on failure detection • Default functionality on failure detection • Design system to fail fast • Use timeouts Orders Service • Use for connected systems Timeout our requests after a threshold Service to service Service to other systems Standard timeout length Adjust length on a case by case basis • • • Stock Service • • • Products Service Network outages and latency • Monitor timeouts • Log timeouts •

Approach: Observable Centralized monitoring • Real-time monitoring • Monitor the host • Central Monitoring

Approach: Observable Centralized monitoring • Real-time monitoring • Monitor the host • Central Monitoring CPU, memory, disk usage, etc. • Expose metrics within the services • Response times Timeouts Exceptions and errors • • • Business data related metrics • Number of orders Average time from basket to checkout • • Collect and aggregate monitoring data • Monitoring tools that provide aggregation Monitoring tools that provide drill down options • • Monitoring tool that can help visualise trends • Monitoring tool that can compare data across servers • Monitoring tool that can trigger alerts •

Approach: Observable Centralized Logging • When to log • Startup or shutdown Code path

Approach: Observable Centralized Logging • When to log • Startup or shutdown Code path milestones Requests, responses and decisions Timeouts, exceptions and errors • • Structured logging • Level • Information • Error • Debug • Statistic Date and time Correlation ID Host name Service name and service instance Message • • • Central Logging Traceable distributed transactions • Correlation ID Passed service to service • •

Approach: Automation Continuous Integration Tools • Work with source control systems • ✓ Unit

Approach: Automation Continuous Integration Tools • Work with source control systems • ✓ Unit tests and integration tests required X ✓ Automatic after check-in • • Ensure quality of check-in • Code compiles Tests pass Changes integrate Quick feedback • • ✓ • • X Urgency to fix quickly • Creation of build • Build ready for test team • Build ready for deployment •

Approach: Automation Continuous Deployment Tools • Accounts Service ✓ Automate software deployment • Configure

Approach: Automation Continuous Deployment Tools • Accounts Service ✓ Automate software deployment • Configure once Works with CI tools Deployable after check in Reliably released at anytime Server 1 • Orders Service ✓ GO • Continous Deployment Tool Products Service • • Server 2 Benefits ✓ • Quick to market Reliable deployment Better customer experience • • Server 3 •