The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic...
Transcript of The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic...
Build always-on, hyper-scalable, microservice-based cloud applications
Session Objectives And TakeawaysSession Objective(s): Microservices introduction• Service Fabric introduction and positioning• Learn to build, deploy and upgrade Service Fabric applications
both locally and to Azure
Takeaways:• Microservices are key for scalable and evolving applications• Service Fabric is a platform for building applications with a
microservices design approach
The microservices approach
Why a microservices approach?
• Build and operate a service at scale• Continually evolving applications• Faster delivery of features and capabilities
to respond to customer expectations• Improved resource utilization to reduce
costs
• Scales by cloning the app on multiple servers/VMs/Containers
Monolithic application approach Microservices application approach
• A microservice application separates functionality into separate smaller services.
• Scales out by deploying each service independently creating instances of these services across servers/VMs/containers
• A monolith app contains domain specific functionality and is normally divided by functional layers such as web, business and data
App 1 App 2App 1
What is a microservice?
• Encapsulates a scenario• Are developed by a small engineering team • Can be written in any language and framework • Contain code plus state that is independently
versioned, deployed, and scaled• Interact with other microservices over well
defined interfaces and protocols such as http• Have a unique name (URL) that can be resolved• Remains consistent and available in the presence
of failures
Types of microservices from a Service Fabric perspective
• Stateless microservice• Has either no state or it can be retrieved from an external store • There can be N instances• e.g. web frontends, protocol gateways, Azure Cloud Services etc.
• Stateful microservice• Maintain hard, authoritative state• N consistent copies achieved through replication and local persistence• e.g. database, documents, workflow, user profile, shopping cart etc.
• Single monolithic database• Tiers of specific technologies
State in Monolithic approach State in Microservices approach
• Graph of interconnected microservices• State typically scoped to the microservice• Variety of technologies used
stateless services
stateless services with separate stores
stateful services
stateless presentation services
Azure Developer Platform
Azure Platform Services
Application Code
More control
Max control
Virtual Machines
Container Service
BLOB Storage
Azure Files
Premium Storage
CloudServices
ServiceFabic
Web Apps
SQLDatabase
RedisCache
DocumentDB
SQL DataWarehouse
Search
Tables
HDInsight
DataFactory
StreamAnalytics
MachineLearning
EventHubs
MobileEngagement
ServiceBus
StorageQueues
BiztalkServices
ActiveDirectory
Pro
duct
ivit
y
Contr
ol
Platform Services
App Service
Application Platform
Microsoft Azure Service FabricA platform for reliable, hyperscale, microservice-based applications
Service Fabric
High Availability
Hyper-Scale
Hybrid Operations
High Density
Microservices
Rolling Upgrades Stateful
services
Low LatencyFast startup & shutdown
Container Orchestration & lifecycle management Replication &
Failover
Simple programming models Resource
balancing
Self-healingData Partitioning
Automated Rollback
Health Monitoring
Placement Constraints
Azure Private cloud Other clouds
Demo: Building your first microservice with Service Fabric
Services built with Service Fabric
Azure Core Infrastruct
ure
thousands of machines
Power BI
Intune
800k devices
Azure SQL
Database
1.4 million databases
Bing Cortana
500m evals/sec
Azure Documen
t DB
billions transactions/wee
k
Skype for
Business
Hybrid Ops
Event Hubs
20bn events/da
y
IoT Suit
e
MICROSOFT CONFIDENTIAL – INTERNAL ONLY
300+ Service Fabric Preview Customers
MICROSOFT CONFIDENTIAL – INTERNAL ONLY
App1
App2
Service Fabric cluster with microservices
MICROSOFT CONFIDENTIAL – INTERNAL ONLY
Handling machine failures
App1
App2
MICROSOFT CONFIDENTIAL – INTERNAL ONLY
Stateful microservice
Application Package
PSSreplication
replication
PSS
Demo: Creating a Service Fabric cluster via the portal
Building and managing microservice applications
Azure Other clouds
Private cloud
Service Fabric Programming Models
Service Fabric
Scalability
Availability
Performance
Lifecycle manageme
nt
Portability Monitoring
Any code Reliable Services API
Reliable Actors API
What is an Actor?• An independent unit of compute and state with
large number of them executing in parallel
• Communicates with other actors using asynchronous messaging
• Has single threaded execution (turn based concurrency)
Create a Reliable Actor• Define Actor Interface
using (var fabricRuntime = FabricRuntime.Create()){ fabricRuntime.RegisterActor(typeof(HelloWorldActor));
public class HelloWorldActor : Actor, IHelloWorld {... }
public interface IHelloWorld : IActor {... }
Implement Actor Interface
Register Actor Implementation with Runtime
Demo: Building reliable actor applications
• Build stateless services using existing technologies such as ASP.NET, node.js, EXEs etc
• Manage concurrency and granularity of state changes with transactions in stateful services.
• Communicate with services using the technology of your choice (e.g Web API, WCF, [web]sockets, etc).
Reliable Services API
• Reliable collections make it easy to build stateful services.
• An evolution of .NET collections for the cloud.
Reliable Collections
Collections• Single machine• Single threaded
Concurrent Collections• Single machine• Multi threaded
Reliable Collections• Multi machine• Replicated (HA)• Persistence
(durable)• Asynchronous• Transactional
• Data is replicated and durably stored on multiple replicas.
• Atomically update one or more collections using transactions.
• Supports LINQ.
Reliable Collections
IReliableQueue<T>IReliableDictionary<K,V>
Service Fabric Stateful Service
Comparing Azure Cloud Services vs. Azure Service Fabric
Cloud Services OR Service Fabric Stateless Service
Azure Tables/NoSQL
Azure Queue
Demo: Building reliableservice applications
Comparing Azure Cloud Services vs. Azure Service Fabric
Azure Cloud Services (Web and Worker Roles)
Azure Service Fabric(Stateless, stateful or Actor services)
• 1 service instance per VM with uneven workloads
• Lower compute density• Slow in deployment & upgrades• Slower in scaling and disaster recovery
• Many microservices per VM• High microservices density• Fast deployment & upgrades• Fast scaling microservices across
the cluster
Example Customer Solutions
Benefits
Blinkbox, the UKs leading video-on-demand service delivering TV and movie content across multiple-devices
Agility - Ability to upgrade microservices independently and without downtime. No need to coordinate DB schema with app upgrades
Programming API - Using actors and reliable collections to easily orchestrate the encoding and resolution of the on-demand content
Scalability - Real time résolution for 30K titles, designed to scale for growth of users, devices and content
• Replacing existing IaaS/DB backed system with microservices solution
• 1.5 PB of for streaming content delivered to millions of customers using Azure Media Services
Microservices workflow for content encoding and resolution
DocumentDB(Ad-hoc searching, long term data storage)
Content Master App
Content Profile App
KeyStore App Resource Resolution App
Azure Media Services Job Management App
Encryption Job Management App
Service Fabric Cluster
Encoding Workflow App
Media Services
Batch Compute
ManagementAPI
Microservices workflow for content encoding
Actor
Actor
Activity
Service
Activity Step Service
Activity
ActorActivity Step
Actor
Content Master App
Content Profile App
KeyStore App Resource Resolution App
Service Fabric Cluster
Encoding Workflow App
ManagementAPI
Azure Media Services Job Management App
Encryption Job Management App
Batch Compute
Media Services
DocumentDB(Ad-hoc searching, long term data storage)
API Service
(OWIN/ASP.Net)
Microservices workflow for content encoding
Benefits
Schneider Electric develops connected technologies and solutions to manage energy and process in ways that are safe, reliable, efficient and sustainable
Density and Availability – VM utilization enables managing millions of devices with automatic failover
Actor Programming API – Service Fabric has the simplest-to-use actor model implementation in the market
Scale – Service Fabric simplifies scale. With millions of devices we need partitioning and resource balancing that makes this transparent
• Management & operation of devices. Query and execute commands, send commands from device to LOB apps
• Communicate with devices securely and in multiple protocols
• Processing and latency need to be sub-second
• Integration Azure services such as Event Hubs and storage.
Microservices IoT solution to manage uninterruptable power supplies (UPS)
LOBApp
Data Collection System
M2M Device
Identity Service
Storage
Management Service
DeviceActorsService
Command
s &State
Enquiry Connection
EgressTopic
ApplicationNotifications
Queue
IngressEvent Hub
SignalRNotification
Http Req
DeviceGatewa
y
Analysis Notifications Queue
StreamAnalytics
DeviceAdaptor Service
REST API Service
Service Fabric Cluster
Microservices IoT solution to manage devices
Other important topics in Service Fabric• Cluster scale-up and down and
different VM sizesCluster placement constraintsApplication rolling upgrades and
rollback Application health monitoring and
reporting• Application operational insights• Advance application resource
balancing and scheduling• Chaos and scenario testing in
production
• Download the Service Fabric developer SDK and build some microservice applications• http://aka.ms/ServiceFabric
• Learn from samples and complete solutions• http://github.com/Azure/ServiceFabric-Samples
• Learn from the tutorials and videos• http://aka.ms/ServiceFabricdocs
• Watch out for the Public Preview
Call to Action
Q&AMark FussellProgram ManagerMicrosoft Azure
© 2014 Microsoft Corporation. All rights reserved.
Diagnostics logging pipelines
ApplicationEventSource
ElasticSearch EventListener
ElasticsearchCluster
Event Hub (optional)
Service Fabric
Runtime
WADAzure Table
IaaS VM
Operational Insights Portal
OI Pipeline ELK Pipeline
OpInsights for diagnostics of application health
Platform Services
Infrastructure Services
OS/Server Compute Storage
Datacenter Infrastructure (24 Regions, 22 Online)
Web and Mobile
Web Apps
MobileApps
APIManagement
API Apps
Logic Apps
Notification Hubs
Media & CDN
Content DeliveryNetwork (CDN)
Media Services
Integration
BizTalkServices
HybridConnections
Service Bus
StorageQueues
HybridOperations
Backup
StorSimple
Azure SiteRecovery
Import/Export
Networking
Data
SQL Database
DocumentDB
RedisCache
AzureSearch
StorageTables
DataWarehouse Azure AD
Health Monitoring
Virtual Network
ExpressRoute
BLOB Storage
AzureFiles
PremiumStorage
Virtual Machines
AD PrivilegedIdentity Management
Traffic Manager
AppGateway
OperationalAnalytics
Services Compute
Cloud Services
BatchRemoteApp
ServiceFabric
Developer Services
Visual Studio
AppInsights
Azure SDK
VS Online
ContainerService
DNS VPN Gateway
Load Balancer
Domain Services
Analytics & IoT
HDInsight MachineLearning
StreamAnalytics
Data Factory
EventHubs
MobileEngagement
Data Lake
IoT Hub
Data Catalog
Security & Manageme
nt
Azure ActiveDirectory
Multi-FactorAuthentication
Automation
Portal
Key Vault
Store/Marketplace
VM Image Gallery& VM Depot
Azure ADB2C
Scheduler