Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pragmatische Microservices mit .NET Core (3) – mehr als nur gRPC

Pragmatische Microservices mit .NET Core (3) – mehr als nur gRPC

Microservices: ja! Oder eher doch nicht? Um diese Frage beantworten zu können, klärt Christian Weyer in diesem Vortrag, was Microservices sind, was sie nicht sind, wann man sie nutzt – und vor allem: wie man Microservices in der .NET-Welt implementieren kann. Sehen Sie Architekturansätze und Patterns in Aktion und erleben Sie Technologien wie Web-APIs, gRPC, Push Messaging, Background Workers und Co. im praktischen Einsatz mit .NET Core 3. Versuchen wir gemeinsam, langweilige Architekturthemen spannend zu machen – durch eine pragmatische Sichtweise.

Christian Weyer

February 25, 2020
Tweet

More Decks by Christian Weyer

Other Decks in Programming

Transcript

  1. Pragmatische Microservices mit .NET Core (3) – mehr als nur

    gRPC Christian Weyer @christianweyer CTO @ Thinktecture AG
  2. The image part with relationship ID rId4 was not found

    in the file. The image part with relationship ID rId4 was not found in the file. The image part with relationship ID rId4 was not found in the file. Special Day “Modern Business Applications” Thema Sprecher Datum, Uhrzeit Raum Pragmatische Microservices mit .NET Core 3 – mehr als nur gRPC Christian Weyer DI, 25. Februar 2020, 10.30 bis 11.30 Ballsaal 2 Web Components: native Komponenten fürs Web – das Ende der SPA Frameworks? Manuel Rauber DI, 25. Februar 2020, 11.45 bis 12.45 Ballsaal 2 Progressive Web Apps – die Grundlagen Sebastian Springer DI, 25. Februar 2020, 14.15 bis 15.15 Ballsaal 2 Progressive Web-Apps mit Angular: Tipps für Fortgeschrittene Christian Liebel DI, 25. Februar 2020, 15.30 bis 16.30 Ballsaal 2 Blazor: SPAs im Browser mit C# und WebAssembly Christian Weyer DI, 25. Februar 2020, 17.15 bis 18.15 Ballsaal 2
  3. Pragmatische Microservices mit .NET Core – mehr als nur gRPC

    Boooring!!! https://twitter.com/funcOfJoe/status/1110754437834764288 3
  4. § Co-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 Developer Technologies & Azure ASPInsider, AzureInsider § Google GDE for Web Technologies, Angular [email protected] @christianweyer https://www.thinktecture.com Christian Weyer mit .NET Core – mehr als nur gRPC Pragmatische Microservices 4
  5. § Microservices - demystified § Typical Microservices patterns § Microservices

    implemented with plain .NET Core § Being pragmatic Topics Pragmatische Microservices mit .NET Core – mehr als nur gRPC 5
  6. Pragmatische Microservices mit .NET Core – mehr als nur gRPC

    Microservices, FTW! 8 https://twitter.com/ryan_marsh/status/980217902740762624
  7. § Docker § Kubernetes § Azure § Serverless § Git

    § NoSQL § Node.js § Service Fabric § gRPC § No more than 20 lines of code in deployed service Microservices are not… Pragmatische Microservices mit .NET Core – mehr als nur gRPC 11
  8. 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 mit .NET Core – mehr als nur gRPC (Some) Principles of Microservices 12
  9. Microservices Approaches & Patterns Implemented with plain .NET Core Pragmatische

    Microservices mit .NET Core – mehr als nur gRPC 13
  10. Bird’s-Eye-View Target Architecture Pragmatische Microservices mit .NET Core – mehr

    als nur gRPC 14 HTTP API WS API Service D HTTPS HTTPS WebSocket Service A Service B Service C HTTP API
  11. Pragmatische Microservices mit .NET Core – mehr als nur gRPC

    Sample Architecture – Shopping Order Monitoring Orders Service Shipping Service AuthN Service Order Monitoring SPA Shopping Web Site (simulated by Postman) 1 - authenticate 2 - register for push 3 - send new order 5 - new order created push 6 - get updated orders 4 - processing order… 16
  12. § Inbound HTTP / Web APIs § HTTPS, JSON, Binary

    § Different API Styles § RPC § OData § GraphQL § „REST“ § gRPC § Outbound communication § Web Sockets § Web Hooks § ASP.NET Core MVC § ASP.NET Core SignalR Pragmatische Microservices mit .NET Core – mehr als nur gRPC Open & Interoperable Interfaces 17
  13. § Open source remote procedure call (RPC) system initially developed

    at Google in 2015 § HTTP/2 for transport § Protocol Buffers as interface description language § Features like § Bidirectional streaming § Flow control Pragmatische Microservices mit .NET Core – mehr als nur gRPC gRPC 18 § When to use gRPC – when Web APIs (REST)? § gRPC uses more compact data format → may be relevant for runtime performance § gRPC offers contracts and enables contract-first via ProtoBuf § Web APIs can do the same via Swagger / Open API § Web APIs should be used in open user-facing frontends § Wide interoperability and network compatibility § gRPC does not work in Azure Web Apps § Grpc.AspNetCore (>= .NET Core 3)
  14. § 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.AspNetCore Pragmatische Microservices mit .NET Core – mehr als nur gRPC Describing Web APIs 19
  15. § 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 mit .NET Core – mehr als nur gRPC Registry, Discovery & Monitoring 20
  16. § 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 mit .NET Core – mehr als nur gRPC Security 21
  17. § 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 § RabbitMQ latest version § Apache ActiveMQ § Be resilient when communicating § RabbitMQ § EasyNetQ § ActiveMQ § Amqp.Net Lite § Azure Service Bus § Polly.NET Pragmatische Microservices mit .NET Core – mehr als nur gRPC Messaging & Queuing 22 X P S S
  18. § 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 Core SignalR Pragmatische Microservices mit .NET Core – mehr als nur gRPC Push Communication 23
  19. § Keep the release cycles short § Keep setup efforts

    & dependencies under control § DevOps, really § Container-ize your solution § Optional: make it available & scalable with an orchestrator § Or put it in a managed env § Make sure you see everything from your solution § Tracing, Logging & Monitoring § Docker § Kubernetes § Serilog § Seq Pragmatische Microservices mit .NET Core – mehr als nur gRPC Developing, Deploying, Running 24
  20. § Domain-Driven Design § Testing § Validation § Versioning §

    Deployment § Scalability § Availability § … and so on ... There is much, much more to consider! Pragmatische Microservices mit .NET Core – mehr als nur gRPC 25
  21. § Those are just some approaches & patterns – not

    rules § Pick and choose wisely § E.g. How would you deal with Offline-first in Microservices world? § There are not a lot of Netflix, Facebooks, Twitters etc. out there § Take a first step: modular monoliths § Slice your application in modules, with interfaces § Use these modules (DLLs) with a functional services mindset § If you can’t build monoliths properly, you will fail with Microservices For You: Pragmatic == Requirements- & Use-Case-driven Pragmatische Microservices mit .NET Core – mehr als nur gRPC 27
  22. § From 23 years of consulting experience: A lot of

    projects fail because of… overly complex architectures – sadly § Do not over-complicate KISS (Keep it simple and stupid) Pragmatische Microservices mit .NET Core – mehr als nur gRPC 28
  23. Recap Pragmatische Microservices mit .NET Core – mehr als nur

    gRPC 30 Technologies are micro decisions – E.g. gRPC or Docker are details Don’t be led by frameworks & techs – be led by requirements Microservices are an overall approach – including your org Decoupling is great – but may increase complexity Clients are important – Microfrontends bring their own problems Start with modular monoliths - can’t build monoliths properly → fail with Microservices
  24. Danke! Bei Fragen kontaktieren Sie mich gerne Christian Weyer https://thinktecture.com/christian-weyer

    @christianweyer [email protected] Demo: https://github.com/thinktecture/pragmatic-microservices-dotnetcore Artikel zu Blazor, PWA, Web Components, Angular, .NET Core & mehr: https://thinktecture.com/de/newsletter 31