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

Azure and Microservices

Daron Yondem
November 17, 2016

Azure and Microservices

This talk is about implementing Microservices with Service Fabric on Microsoft Azure.

Daron Yondem

November 17, 2016
Tweet

More Decks by Daron Yondem

Other Decks in Programming

Transcript

  1. • Scales by cloning the app on multiple machines Monolithic

    application Microservices application • Scales by deploying each service independently App 1 App 2 App 1
  2. Application design Traditional application Application Component Library 1 API UI

    Data Access Component Library 2 Component Library 3 • Compile-time contract validation • Local operations • Easier to reason about • Expensive to scale application • Hard to scale data access • Upgrades are long and costly
  3. Application design Application composed of services • Cheaper to scale

    application • Easier to scale data access • Upgrade continuously • Runtime contract validation • Network operations • Harder to reason about
  4. Thumbnail Service Thumbnail Service Photo Share Service Photo Share Service

    Photo Share Service 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 Thumbnail Service V2 SharedLib-v1
  5. Azure Other Clouds On Premise Data centers Azure Service Fabric

    Dev Box Service Fabric for Windows Server GA Service Fabric preview for Linux
  6. Azure Cloud Services (Web & Worker Roles) Azure Service Fabric

    (Microservices) • 1 service instance per VM • Slow deployment & upgrades • Slow scaling of roles up/down • Emulator for development • Many microservices per machine/VM • Fast deployment & upgrades • Fast scaling of microservices up/down • Single machine cluster for development Cloud Services vs Service Fabric
  7. Cloud Services Deployment Web Application Web role Web role Worker

    Application Worker role Worker role Worker role Worker role Worker role Storage queue Service Bus Azure cache Redis Azure load balancer Operational Insights Table Storage Azure SQL database Blob Storage
  8. Storage queue Table Storage Service Bus Azure SQL database Azure

    cache Redis Azure load balancer Node Service Fabric cluster Node Stateless Worker Service Node Node Node Stateless Web Service Stateless Worker Service Stateless Worker Service Stateless Worker Service Stateless Web Service Stateless Worker Service Operational Insights Blob Storage
  9. Datacenter (Azure, On-Premises, Amazon) Load Balancer PC/VM #1 Service Fabric

    Your code, etc. PC/VM #2 Service Fabric Your code, etc. PC/VM #3 Service Fabric Your code, etc. PC/VM #4 Service Fabric Your code, etc. PC/VM #5 Service Fabric Your code, etc. Your code, etc. (Port: 19080) Web Request (Port: 80/443/?) Cluster supports 1,000s of nodes is self repairing, and scales-in and out
  10. Load Balancer Web Site Svc (1+ instances) Internal Svc #1

    (1+ instances) Internal Svc #2 (1+ instances) Service Registry IS #1-1  http://... IS #1-?  http://... IS #2-1  http://... IS #2-?  http://...
  11. in Service Fabric Service Type - defines the service, like

    a class Named Service Instance - a deployment of the service type, like an object
  12. <ServiceManifest Name="QueueService" Version="1.0"> <ServiceTypes> <StatefulServiceType ServiceTypeName="QueueServiceType" HasPersistedState="true" /> </ServiceTypes> <CodePackage

    Name="Code" Version="1.0"> <EntryPoint> <ExeHost> <Program>ServiceHost.exe</Program> </ExeHost> </EntryPoint> </CodePackage> <ConfigPackage Name="Config" Version="1.0" /> <DataPackage Name="Data" Version="1.0" /> </ServiceManifest>
  13. 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 Web Service Type 1.0.0 User Service Type 1.5.0 Session Service Type 1.2.0 Authentication Service Type 3.1.4 Job Runner Service Type 1.2.0 fabric:/app/users fabric:/app/sessions fabric:/app/auth fabric:/app/job1 fabric:/app/job2 fabric:/app/job3 Service Fabric fabric:/app/web Registered service types Deployed named service instances
  14. Queues Storage Stateless Services Pattern Front End (Stateless Web) Stateless

    Middle-tier Compute Cache • Scale stateless services backed by partitioned storage • Increase reliability and ordering with queues • Reduce read latency with caches • Manage your own transactions for state consistency • More moving parts each managed differently Load Balancer
  15. Stateful Middle-tier Compute Stateful Services Pattern Simplify design, reduce latency

    Front End (Stateless Web) • Application state lives in the compute tier • Low Latency reads and writes • Partitions are first class at the service layer for scale- out • Built in transactions • Fewer moving parts • External stores for exhaust and offline analytics Load Balancer Cold Data Stores For Exhaust (Optional)
  16. • State: Single monolithic database • Tiers of specific technologies

    • Graph of interconnected services • State typically scoped to the service • Variety of technologies used stateless services stateless services with separate stores stateful services stateless presentation services Monolithic application Microservices application
  17. Node 5 Node 4 Node 3 Node 6 Node 2

    Node 1 P2 S S S P4 S P1 S P3 S S S • Services can be partitioned for scale-out. • You can choose your own partitioning scheme. • Service partitions are striped across machines in the cluster. • Replicas automatically scale out & in on cluster changes
  18. Service Fabric is a Container Orchestrator • Service Fabric doesn’t

    care what your workload is • Service Fabric performs the placement and failover of containers in the cluster • Service Fabric works everywhere – same primitives • Docker containers on Linux • Windows containers on Windows • Guest Exes and/or Service Fabric Services can exist inside the container • A container can register endpoints with Service Fabric for discoverability & communication
  19. Reference Solutions: IoT Microsoft Azure Admin application Ingestion application Field

    gateway IoT Hub Device 1 Device 2 Device x Service Fabric Customer application 1 Customer application 2 Customer application m ... Storage (Azure) Service admin Create instances Send device data Create instances Cold storage data offload Device batch data Device batch data Customer User https://azure.microsoft.com/en-us/documentation/samples/service-fabric-dotnet-iot/
  20. 1000s of VMs Azure Core Infrastructure Services built with Service

    Fabric Billions of transactions per week Azure Document DB 4 trillion requests each week Azure Event Hubs 1.6 million DBs Azure SQL Database 500 million evals/sec Bing Cortana 1.1M devices Microsoft Intune … and more IoT Hub Skype for Business Power BI CRM Dynamics
  21.  Service Fabric developer SDK  http://aka.ms/ServiceFabricSDK  Docs Learning

    map and overview videos  https://azure.microsoft.com/en-us/documentation/services/service-fabric/  Service Fabric course and lab  https://mva.microsoft.com/en-US/training-courses/building-microservices-applications-on-azure- service-fabric-16747  Learn from samples, free clusters and labs  http://aka.ms/ServiceFabricSamples  http://aka.ms/tryservicefabric  Lab: http://j.mp/2fYafCG  Questions? Comments? Issues?  https://stackoverflow.com/questions/tagged/azure-service-fabric  http://aka.ms/ServiceFabricForum  https://github.com/azure/service-fabric-issues