Trending C Github Repositories aka msMicroservices Ebook aka
Trending C# Github Repositories aka. ms/Microservices. Ebook aka. ms/Microservices. Architecture Github #2 or #3 monthly trending Since May 2017
Microservices Autonomous Bounded Context Nomad & addressable services API Gateway Events Isolated Decoupled Async. communication Event Bus Service Discovery Message Brokers Health Checks Transient Failures Handling Resiliency Commands Domain-Driven Retries with Exponential Backoff Circuit Breakers Design CQRS simplified Aggregates Domain Events Mediator Domain Entity Docker Containers Linux Containers Docker Host Docker Image Windows Containers Docker Registry Docker Hub Hyper-V Containers Azure Container Registry Azure Service Bus Rabbit. MQ NService. Bus Mass. Transit Brighter Polly Orchestrators Stateful Services Azure Service Fabric Actors Azure Container Service Kubernetes Docker Swarm Mesos DC/OS
Microservices != Containers But they are a great fit…
Docker Containers • Docker improves the deployment of applications with portable, self-sufficient containers, Linux or Windows, that can run on any cloud or on-premises. No more: “It works in my dev machine!. . . Why not in production? ” Now it is: “If it works in Docker, it works in production” Keywords about WHY Docker? - Dependencies (self-sufficient) - Deployment
Docker and. NET • . NET Core Docker images x. Plat. (Linux & Windows Nano Server) • . NET Framework images Windows Server Core See at Docker Hub
Existing. NET Application Modernization: Maturity Models Existing Apps. NET Web apps (on-prem. ) Cloud Infrastructure-Ready Cloud Dev. Ops-Ready Cloud-Optimized & Cloud-Native Full Paa. S and Cloud-Native Session BRK 3189 +Modernizing Managed Services existing. NET applications Paa. S + Managed Services This session Relational Database Iaa. S On-Premises Azure LIFT & SHIFT: No re-architect, no code changes Azure Architected for the cloud (Needs new code)
Microservices application approach Traditional application approach • • A traditional application has most of its functionality within a few processes that are componentized with layers and libraries. Scales by cloning the app on multiple servers/VMs App 1 • • A microservice application segregates functionality into separate smaller services. Scales out by deploying each service independently with multiple instances across servers/VMs App 1 App 2
Data in Traditional approach • Single monolithic database • Tiers of specific technologies Data in Microservices approach • Graph of interconnected microservices • State typically scoped to the microservice • Remote Storage for cold data Web Tier Services Tier Cache Tier Data Tier Cache doesn’t help much for massive data ingress (Events, Io. T, etc. ) Mobile apps Web presentation services Database servers are usually the bottleneck SQL DB or No-SQL Monolithic Databases are shared across services. Stateless services Stateful services SQL […] Stateless services with separate stores Each microservice owns its model/data!
e. Shop. On. Containers Reference Application - Architecture Client apps Docker Host e. Shop mobile app Xamarin. Forms C# x. Plat. OS: Identity microservice (STS+users) SQL Server db Catalog microservice i. OS Android Windows SQL Server db Ordering microservice e. Shop traditional Web app e. Shop Web. App MVC ASP. NET Core MVC Ordering. API SQL Server db Grace. Period worker Svc. Basket microservice HTML e. Shop SPA Web app Redis cache Marketing microservice Mongo. DB / Cosmos. DB SQL Server DB Type. Script/Angular 4 Location microservice Mongo. DB / Cosmos. DB
(1) e. Shop. On. Containers Microservices and Docker Containers End-to-end solution overview in Visual Studio VS 2017: - Solution’s projects - Docker-compose. yml
Key Patterns for Microservices 1. Direct communication vs. API Gateway 2. Health checks 3. Resilient cloud applications: o Retries with exponential backoff plus Circuit breaker 4. Async. pub/subs communication (Event Bus) 5. Scale-out with Orchestrators
Health Checks API Microservice 1 /health Health. Checks Watch. Dog app Microservice 2 /health
Health Checks API Usually Provided by the Orchestrator (i. e. Service Fabric, Kubernetes, etc. ) Consumer B /health Router Consumer A API Gateway Microservice 1 Microservice 2 query Service Registry /health
Building resilient cloud applications Client Mobile App Back end Microservice 1 Web API JSON Container Client SPA Web. App Microservice 2 API Gateway JSON HTTP Container Request/Response Java. Script / Angular. js ASP. NET Core Web API Container HTTP Request/Response Microservice 3 Web API Traditional Web. App Browser HTML Client Web. App MVC ASP. NET Core MVC Container
Retries with Exponential Backoff Back end Microservice 1 Web API Gateway HTTP ASP. NET Core Web API Microservice 2 HTTP Web API Request/Response Microservice 3 Web API Client Web. App MVC ASP. NET Core MVC Container
Retries with Exponential Backoff + Circuit Breaker Back end Microservice 1 Web API Gateway HTTP ASP. NET Core Web API Microservice 2 HTTP Web API Request/Response Microservice 3 Web API Client Web. App MVC ASP. NET Core MVC Container
Netflix Hystrix
(2) e. Shop. On. Containers • Health. Checks • Retries with Exponential Backoff and Circuit Breaker with Polly library
Risk of Partial Failure Amplified by Microservices HTTP request/response communication Backend / Orchestrator Multiple Customers Browser Web App Dependency 6 Multiple HTTP requests Submit Order page Dependency 2 Dependency 1 Dependency 5 Dependency 3 Dependency 7 Dependency 4 Dependency 8 Anti-patterns
How to minimize exponential failures in microservices
Synchronous vs. Async communication across Microservices Anti-pattern Synchronous all req. /resp. cycle Http sync. request i. e. MVC app, API Gateway, etc. Asynchronous Comm. across internal microservices (Event. Bus: i. e. AMPQ) “Asynchronous” Comm. across internal microservices (Polling: Http) Http sync. request Catalog Http sync. response Http sync. request Other Http sync. response Same Http Request/Response cycle! Basket Ordering Other Catalog Http sync. response Http sync. request i. e. MVC app, API Gateway, etc. Ordering Http sync. response Http sync. request i. e. MVC app, API Gateway, etc. Basket Http sync. request Basket Http Polling Ordering Http sync. response Http Polling Catalog Http Polling Other
Asynchronous Event-Driven communication with an Event Bus Backend Basket Microservice User-Profile Microservice Service Web API Service Update. User command Database User. Updated event (Publish Action) DB update Event Bus (Publish/Subscribe Channel) Event Bus Abstractions/Interface Event Bus Implementations Rabbit. MQ Azure Service Bus Other: NService. Bus Mass. Transit etc. Database as Cache User. Updated event Buyer info Ordering Microservice Database Service Eventual consistency across microservices’ data based on event-driven async communication
(3) e. Shop. On. Containers Async communication between microservices with and Event Bus
http: //go. particular. net/e. Shop. On. Containers
Production environment Dev environment Forks/Flavors Foundational Development technologies e. Shop. On. Service. Fabric, e. Shop. On. Kubernetes e. Shop. On. Swarm , e. Shop. On. DCOS, etc. Cloud infrastructure and Specific Orchestrators Azure Container Service Development Deployment . NET Core. NET Framework + Linux Containers Windows Containers Mesos DC/OS Kubernetes Docker Swarm Azure Service Fabric Service Bus BLOB Storage Redis Cache Exploring Microservices Architecture/Design/Development Infrastructure Decisions Orchestrators SQL Database Cosmos DB Key Vault Production-Ready Microservices Other Cloud Infrastructure
Client apps Docker Host Identity microservice (STS+users) e. Shop mobile app Xamarin. Forms C# x. Plat. OS: Web API container i. OS Android Windows SQL Server database Catalog microservice Web API e. Shop traditional Web app e. Shop Web. App MVC ASP. NET Core MVC Container container Ordering microservice Web API HTML e. Shop SPA Web app SQL Server database container SQL Server database Basket microservice Web API Redis cache Type. Script/Angular 2 container
Orchestrator’s Cluster managing microservices/containers Clusters provide: • High scalability • Automatic High Availability and resiliency • High services density per host App 1 App 2 My Docker Images My ASP. NET Core Services Official Docker Images https: //hub. docker. com Cluster of Nodes/Hosts VM or
Azure Product Azure Service Fabric Orchestrator Service Fabric Description Azure Service Fabric is a distributed systems platform that makes it easy to package, deploy, and manage scalable and reliable microservices Good for Production-ready & Microsoft ecosystem More mature: Less mature: Azure Container Service Docker Swarm Kubernetes Docker Swarm is a clustering and scheduling tool for Docker containers. With Swarm, IT administrators and developers can establish and manage a cluster of Docker nodes as a single virtual system Easy to get started Dev/Test and Production Kubernetes is an open-source platform for automating deployment, scaling, and operations of application containers across clusters of hosts Production-ready & Linux ecosystem Common workloads a) Stateful svc & Actors b) Microservices based on plain processes c) Microservices based on containers More mature: Less mature: More mature: Microservices based on containers Less mature: Mesosphere DC/OS As a datacenter operating system, DC/OS is itself a distributed system, a cluster manager and a container platform Production-ready & Linux ecosystem More mature: Less mature: Microservices based on containers (Including other Linux containers, not just Docker)
(5) ACS-Kubernetes - Overview - Scaling out
Additional subjects covered in the e. Book Domain aka. ms/Microservices. Architecture Driven Design Patterns • Domain Models (Aggregates, Entity, VO, etc. ) • Simplified CQRS Github • Dapper Micro. ORM for queries • Commands and Mediator patter • Domain Events (within the same microservice) Microservices • • http: //aka. ms/Microservices. Ebook https: //aka. ms/microservices-guide-online-msft-docs Integration Events (across microservices) Multi-container docker-compose. yml Swagger w/ Swashbuckle Security (Authentication/Authorization) with tokens from Identity. Server 4 wrapping ASP. NET Identity
http: //microsoft. com/net/architecture
Twitter: @cesardelatorre Email: cesardl@microsoft. com
https: //myignite. microsoft. com/evaluations https: //aka. ms/ignite. mobileapp
Virtual Machines compared to Docker Containers App 1 App 2 App 3 Bins/Libs Guest OS + Network isolation at container level + Resources constraints at container level App/Svc 1 App/Svc 2 App/Svc 3 Bins/Libs Hypervisor Container Engine Host Operating System Infrastructure
Docker Engine for Linux and Windows Microsoft Azure 44
- Slides: 44