application has layers and libraries • Scales by cloning the app on multiple servers/VMs App 1 • A microservice splits functionality into services. • Scales out by deploying each service independently App 1 App 2 Microservice vs Monolith
Single monolithic database • Tiers of specific technologies • Graph of interconnected microservices • State typically scoped to the microservice • Remote Storage for cold data SQL DB or No-SQL Web Tier Services Tier Data Tier Cache Tier Stateful services Web presentation services Stateless services Mobile apps Stateless services with separate stores SQL […] Microservice vs Monolith. Data
it can: o Use entity objects o User Repository Interfaces/Contracts • Depends on the Infrastructure Layer (DI) so it can: o Use repository implementation classes (DI) • Ideally, it must NOT take dependency on any other layer • It implements: o Domain Entities, Aggregate-Roots, Value-Objects o Repository Contracts/Interfaces (to be used in DI) • Depends on the Domain-Model layer so it can: o Use entity objects o Like EF updating DB through mapped entities • Direct dependency on infrastructure frameworks like EF Core or any other database, cache or infrastructure API
of requests to multiple microservices • Handle cross-cutting concerns such as authorization or data transformations • Communicate with services that use non-Internet-friendly protocols • A façade made for different apps, like mobile, SPAs and ect.
Gateway Service Registry query /health /health Microservice 2 Microservice 1 Usually Provided by the Orchestrator https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks https://github.com/Xabaril/BeatPulse
MVC Container Container Web API Web API ASP.NET Core MVC Container Microservice 3 Container Web API Client SPA WebApp JavaScript / Angular.js API Gateway ASP.NET Core Web API Container Back end Traditional WebApp Browser HTML HTML JSON JSON HTTP Request/Response HTTP Request/Response Implement resilient communication With Retries w/ exponential backoff & Circuit-Breakers
Web API ASP.NET Core MVC Container Microservice 3 Web API API Gateway ASP.NET Core Web API Back end HTTP Request/Response HTTP Retries with Exponential Backoff and Circuit Breaker
Service User-Profile Microservice Web API Service Database Backend UserUpdated event (Publish Action) Event Bus (Publish/Subscribe Channel) UpdateUser command UserUpdated event → Buyer info UserUpdated event → Buyer info Eventual consistency across microservices’ data based on event-driven async communication DB update Event Bus Abstractions/Interface Event Bus Implementations RabbitMQ Azure Service Bus Other: NServiceBus MassTransit etc. Asynchronous Event-Driven communication with an Event Bus
Z E D A U T H E N T I C AT I O N W I T H A N A P I G AT E WAY A U T H E N T I C AT I O N BY I D E N T I T Y M I C R O S E R V I C E ; T R U S T I S S H A R E D U S I N G A N A U T H O R I Z AT I O N TO K E N https://github.com/ThreeMammals/Ocelot https://github.com/IdentityServer/IdentityServer4 https://github.com/policyserver/policyserver.local