- 快召唤伙伴们来围观吧
- 微博 QQ QQ空间 贴吧
- 文档嵌入链接
- 复制
- 微信扫一扫分享
- 已成功复制到剪贴板
Design modern microservice applications on Microsoft Azure
展开查看详情
1 .Design modern microservice applications on Microsoft Azure Service Fabric Jeffrey Richter, Software Engineer Vaclav Turecek, Program Manager BRK3204
2 .Jeffrey Richter: Microsoft Software Engineer, Wintellect Co-Founder, & Author JeffreyR@Wintellect.com www.linkedin.com/in/JeffRichter @ JeffRichter
3 .Vaclav Turecek: Microsoft Program Manager Not an author.. ..unless you count Stack Overflow github.com/ vturecek
4 .Code solving a domain-specific problem Built by small team using a specific technology stack Exposes features to caller via a well-defined API contract Degrades gracefully when dependent services fail Can be upgraded & scaled independently of other services Dividing a big service into smaller services is often referred to as a microservices architecture What is a Service?
5 .Myth: microservices offer small, easy-to-understand/manage code bases A monolith can use OOP & libraries (requires developer discipline) Library changes cause build failures (not runtime failures) Myth: A failing service doesn’t impact other services Many services require dependencies be fully functioning Hard to write/test code that gracefully recovers when dependency fails We run multiple service instances so there is no such thing as “failure” A monolith is up/down completely; no recovery code Infrastructure restarts failed instances keeping them up Microservice Architecture Benefits Myths
6 .Thumbnail Service Thumbnail Service Photo Share Service Photo Share Service Photo Share Service Microservice Architecture Actual Benefits Photo Share Service Thumbnail Service Photo Share Service Thumbnail SharedLib-v7 Photo Share Service SharedLib-v1 Photo Share Service node.js Thumbnail Service .NET Photo Share Service V1 Thumbnail Service V1 Thumbnail Service SharedLib-v7 Scale Independently Different Technology Stacks Conflicting Dependencies Independent Deployments (Beware lack of testing) Thumbnail Service V2 SharedLib-v1
7 .Microservices in Service Fabric
8 .What is a service in Service Fabric ? Service Type - defines the service, like a class Named Service Instance - a deployment of the service type, like an object
9 .fabric:/app Yo , Service Fabric, I need 3 new Job Runner services! fabric:/app/job1 fabric:/app/job2 fabric:/app/job3 MyApp Type 4.0.0 Applications and Services Registered service types Deployed named service instances OK
10 .Example: Job Creator application Distributed, highly-available workloads created on demand via API. Processing jobs, Game sessions, Tenant accounts, etc.
11 .Demo 1 Creating named service instances
12 .Application Upgrading
13 .Production Cluster V1 V1 V1 V1 V1 V1 V2 V2 V2 V2 V2 V2 Production Cluster V1 V1 V1 V1 V1 V1 V2 V2 V2 V2 V2 V2 In-Place Upgrade Options Delete & Upload Rolling Upgrade
14 .Load Balancer Staging Cluster V2 V2 V2 V2 V2 V2 Production Cluster V1 V1 V1 V1 V1 V1 Traffic Manager V2 Production Cluster V2 V2 V2 V2 V2 V2 V1 Production Cluster V1 V1 V1 V1 V1 V1 LB LB New Cluster Upgrade Options Instant swap Slow migration VIP Swap Controlled Migration
15 .Some upgrades can be done 1 way and other upgrades another way Comparing Cluster Upgrade Options Delete & Upload Rolling Upgrade VIP Swap Controlled Migration Add’l Hardware Costs None None 2x 1x to 2x Service availability Downtime Reduced scale Same Same Failed upgrade recovery Downtime until V1 upload Reduced scale until rollback Immediate after swap back Immediate after TM reconfig V2 testability Not at all Not at all Private & Public Private & Public Protocol /Schema change 1-Phase 2-Phase 1-Phase 1-Phase Usable with stateful services No Yes No No
16 .Application upgrade New named application instance, side-by-side In-place rolling upgrade
17 .Demo 2 Application upgrade
18 .Application upgrade Application Service
19 .Application composition An application in Service Fabric: Is a logical grouping of services Is an upgrade unit. An upgrade targets an application instance Can have different versions of the same application type side-by-side
20 .Application composition A service in Service Fabric: Is a logical grouping of partitions (and replicas/instances) Is upgraded as part of an application upgrade* Can not have different versions of the same service type within an application *(but you can choose which services to upgrade)
21 .Application composition Named application instances are upgraded individually. Named application instances are deleted individually. A/B deployments are at the application level. Health rolls up to the application. Versioning rolls up to the application.
22 .Networking
23 .Comparing an in-process call to an HTTP request Performance: Worse & increases network congestion Unpredictable time: Managing timeouts is challenging; pass deadlines Unreliable: Requires retry loops with exponential backup/circuit breakers Server code must be idempotent Security: Requires authentication, authorization, & encryption Debugging: network issues, perf counters/events/logs, causality/call stacks Turning a Monolith into a Microservice var result = Method(arg1, arg2); Explicit, language-agnostic, multi-version API contract (loss of IntelliSense, refactoring & compile-time type-safety) (de)serialization
24 .Turning a Monolith into a Microservice var result = AddUser (name, address); Request: HTTP POST api /users { name: “”, address: “”} Response: 200 OK { result: “user added” } Explicit, language-agnostic, multi-version API contract (loss of IntelliSense, refactoring & compile-time type-safety) (de)serialization
25 .Services start/stop, scale up/down, & crash/move Each instance has its own endpoint (dynamically-assigned IP/port) Clients must dynamically discover service instance endpoints and load balance between them Beware: a new service instance could be assigned a previous instance’s endpoint This requires certificates or some ID/uniqueness so client knows which service it’s communicating with Service Endpoint Discovery
26 .Load Balancer Web Site Svc (1+ instances) Internal Svc #1 (1+ instances) Service Endpoint Discovery Internal Svc #2 (1+ instances) Service Registry IS #1-1 http://... IS #1-? http://... IS #2-1 http://... IS #2-? http://...
27 .Load Balancer VM1 VM2 VM3 Load Balancer Probes HTTP 200 HTTP 503 HTTP 200 HTTP 200 (no response) VM1 VM2 VM3 VM1 VM2 15s probes
28 .State of the web
29 .State of the web on Service Fabric WebListener 1.0.0 RC2 now available Use this on Windows today Katana Production OK (Web API 2 only) Kestrel Not production ready (Q1 2017) IIS Not supported (ever)