The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic...

41
Build always-on, hyper-scalable, microservice-based cloud applications

Transcript of The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic...

Page 1: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Build always-on, hyper-scalable, microservice-based cloud applications

Page 2: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 3: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

The microservices approach

Page 4: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 5: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

• 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

Page 6: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 7: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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.

Page 8: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

• 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

Page 9: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 10: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 11: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Demo: Building your first microservice with Service Fabric

Page 12: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 13: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

MICROSOFT CONFIDENTIAL – INTERNAL ONLY

300+ Service Fabric Preview Customers

Page 14: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

MICROSOFT CONFIDENTIAL – INTERNAL ONLY

App1

App2

Service Fabric cluster with microservices

Page 15: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

MICROSOFT CONFIDENTIAL – INTERNAL ONLY

Handling machine failures

App1

App2

Page 16: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

MICROSOFT CONFIDENTIAL – INTERNAL ONLY

Stateful microservice

Application Package

PSSreplication

replication

PSS

Page 17: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Demo: Creating a Service Fabric cluster via the portal

Page 18: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Building and managing microservice applications

Page 19: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 20: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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)

Page 21: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 22: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Demo: Building reliable actor applications

Page 23: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

• 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

Page 24: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

• 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

Page 25: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

• 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>

Page 26: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Service Fabric Stateful Service

Comparing Azure Cloud Services vs. Azure Service Fabric

Cloud Services OR Service Fabric Stateless Service

Azure Tables/NoSQL

Azure Queue

Page 27: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Demo: Building reliableservice applications

Page 28: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 29: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Example Customer Solutions

Page 30: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 31: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 32: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 33: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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)

Page 34: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 35: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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

Page 36: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

• 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

Page 37: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Q&AMark FussellProgram ManagerMicrosoft Azure

Page 38: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

© 2014 Microsoft Corporation. All rights reserved.

Page 39: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

Diagnostics logging pipelines

ApplicationEventSource

ElasticSearch EventListener

ElasticsearchCluster

Event Hub (optional)

Service Fabric

Runtime

WADAzure Table

IaaS VM

Operational Insights Portal

OI Pipeline ELK Pipeline

Page 40: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

OpInsights for diagnostics of application health

Page 41: The microservices approach Scales by cloning the app on multiple servers/VMs/Containers Monolithic application approach Microservices application.

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