Slide 1

Slide 1 text

Pragmatische Microservices-Architekturen mit .NET Core – Patterns & Code Christian Weyer @christianweyer CTO

Slide 2

Slide 2 text

§ Founder & CTO at Thinktecture AG § Personal focus on § Mobile & web-based application architectures § Interoperability, cross-device § Pragmatic end-to-end solutions § Cloud-native & serverless architectures § Independent Microsoft Regional Director § Microsoft MVP for ASP.NET (Architecture) ASPInsider, AzureInsider § Google GDE for Web Technologies [email protected] @christianweyer https://www.thinktecture.com Christian Weyer mit .NET Core - Patterns & Code Pragmatische Microservices-Architekturen 2

Slide 3

Slide 3 text

§ Microservices - demystified § Typical Microservices patterns § Microservices implemented with plain .NET Core § Being pragmatic Topics Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 3

Slide 4

Slide 4 text

Microservices demystified Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 4

Slide 5

Slide 5 text

Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 5

Slide 6

Slide 6 text

Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code Microservices, FTW! 6 https://twitter.com/ryan_marsh/status/980217902740762624

Slide 7

Slide 7 text

Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 7

Slide 8

Slide 8 text

§ Docker / containers § Azure / AWS § Serverless § Feature flags § Gitflow § NoSQL § Node.js § No more than 20 lines of code in deployed service § AWS Lambda § Service Fabric Microservices are not… https://lostechies.com/jimmybogard/2016/06/03/what-microservices-is-not/ Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 8

Slide 9

Slide 9 text

Single Responsibility § Focused around business domain § ‘Small’ Isolation § Choice of technology § Well-defined technology- agnostic API § Mobility Autonomy § Exclusive state (data storage) Decoupling § Asynchronous communication § Really, always? Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code (Some) Principles of Microservices 9

Slide 10

Slide 10 text

Microservices Approaches & Patterns Implemented with plain .NET / .NET Core Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 10

Slide 11

Slide 11 text

Bird’s-Eye-View Target Architecture Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 11 HTTP API WS API Service D HTTPS HTTPS WebSocket Service A Service B Service C HTTP API

Slide 12

Slide 12 text

Simple Sample J Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 12

Slide 13

Slide 13 text

§ Inbound HTTP / Web APIs § HTTPS, JSON, Binary § Different API Styles § RPC § OData § GraphQL § „REST“ § Outbound communication § Web Sockets § Web Hooks § ASP.NET Web API § ASP.NET Core MVC § ASP.NET SignalR § ASP.NET Core SignalR § ASP.NET WebHooks Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code Open & Interoperable Interfaces 13

Slide 14

Slide 14 text

§ If you are not a hardcore REST-afarian you may want to have your interfaces described / documented § Technical for further tooling § Human readable § E.g. Swagger / OpenAPI § Swashbuckle § Swashbuckle.AspNetCore Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code Describing Web APIs 14

Slide 15

Slide 15 text

§ Consumers need to find services § Services should register themselves and be discoverable § Infrastructure should monitor service availability § Simple discovery: Plain DNS works in a lot of cases § Enhanced discovery with attached metadata sometimes needed, e.g. with Consul § Consul § Consul.NET Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code Registry, Discovery & Monitoring 15

Slide 16

Slide 16 text

§ Microservices need to be secured § Think about trusted subsystems where possible § Need to authenticate applications and users § Separate authentication into its own microservice § Apply authorization logic in the functional microservices § Standards help § OAuth2 & OpenID Connect § IdentityServer § Azure Active Directory § Azure Active Directory B2C Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code Security 16

Slide 17

Slide 17 text

§ Asynchronous message passing for decoupling § Different message exchange patterns at your hand § RabbitMQ as popular broker- based system § But standards help: think about AMQP 1.0 § E.g. Apache ActiveMQ § Be resilient when communicating § RabbitMQ § EasyNetQ § ActiveMQ § Amqp.Net Lite § Azure Service Bus § Polly.NET Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code Messaging & Queuing 17 X P S S

Slide 18

Slide 18 text

§ Always think end-to-end § Let consumers know that something important changed § Near real-time push from services § Platform push § Provided by platform vendors (including Web Push) § Application push § Web Sockets § ASP.NET SignalR § ASP.NET Core SignalR Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code Push Communication 18

Slide 19

Slide 19 text

§ Keep the release cycles short § Keep setup efforts & dependencies under control § DevOps, FTW! § Container-ize your solution § Make it available & scalable with an orchestrator § Make sure you see everything from your solution § Tracing, Logging & Monitoring § Docker § Kubernetes § Serilog § Seq Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code Developing, Deploying, Running 19

Slide 20

Slide 20 text

§ Domain-Driven Design § Testing § Validation § Versioning § Deployment § Scalability § Availability § … and so on ... There is much, much more to consider! Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 20

Slide 21

Slide 21 text

User Interfaces mit .NET Core - Patterns & Code Pragmatische Microservices-Architekturen 21

Slide 22

Slide 22 text

§ When thinking end-to-end, there are microservices with and without user interfaces § Need a way to compose UIs consisting of several „sub-UIs“ § Can be done server-side § Can be done client-side § SPA-style (Iframes, Web Components) § Open-sourced real world PoC with SPA & server-side solutions § http://lvm-it.github.io/ Microservices can have UIs: Microfrontends mit .NET Core - Patterns & Code Pragmatische Microservices-Architekturen 22

Slide 23

Slide 23 text

Being Pragmatic Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 23

Slide 24

Slide 24 text

§ Those are just some approaches & patterns – not rules! § Pick and choose wisely § There are not a lot of Netflix, Facebooks, Twitters etc. out there § Do not over-complicate! § Take a first step: modular monoliths § Slice your application in modules § If you can’t build monoliths properly, you will fail with Microservices ! Pragmatic == Requirements- & Use-Case-driven Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 24

Slide 25

Slide 25 text

§ BTW: A lot of projects fail because of… overly complex architectures – sadly KISS ! Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 25 !

Slide 26

Slide 26 text

§ Microservices are all the hype § A lot of the ideas are not really new – “SOA done right” § Focus on the/a business domain § New approaches & tooling for shorter dev & release cycles bring value-add § Many ways to approach microservices in the .NET world § Plain, as seen here § Using some framework § Using all-the-things Azure: AKS, Service Fabric, Serverless § Microservices bring their own – partly new – challenges: be prepared! § Always stay cool: Keep it simple & stupid! ! Summary Pragmatische Microservices-Architekturen mit .NET Core - Patterns & Code 26

Slide 27

Slide 27 text

Danke! https://github.com/thinktecture/pragmatic-microservices-dotnetcore Christian Weyer @christianweyer [email protected]