+ All Categories
Home > Documents > Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service...

Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service...

Date post: 05-Jan-2016
Category:
Upload: alaina-lloyd
View: 217 times
Download: 0 times
Share this document with a friend
Popular Tags:
47
Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright (c) 2010, Bill Wilder Boston Azure User Group http://bostonazure.org @bostonazure Bill Wilder http://blog.codingoutlou d.com @codingoutloud Boston West Toastmasters http://bwtoastmasters. com Not here with my day job Only Bill’s personal views Services & Patterns for Building Cloud-Native Applications on Microsoft’s Windows Azure Stack
Transcript
Page 1: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Cloud-Native in Azure

Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University

19-November-2010

Copyright (c) 2010, Bill Wilder

Boston Azure User Grouphttp://bostonazure.org@bostonazure

Bill Wilderhttp://blog.codingoutloud.com@codingoutloud

Boston West Toastmasters http://bwtoastmasters.com

Not here with my day jobOnly Bill’s personal views

Services & Patterns for Building Cloud-Native Applications on Microsoft’s Windows Azure Stack

Page 2: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Agenda

Azure provides Affordances that:-Nudge you towards scalable,-Cost-effective, -Durable application architectures

We will look at those services and “natural” patterns…

Page 3: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

[Azure] Cloud Platform• The rise of focused, specialized services– Really good at one thing– True of other Cloud Platforms

• “Scalable” Persistent Storage abstractions– Set of Services– Illusion of infinite scale out– Same performance with x clients as with 10x as with

100x as with 1000x as with …

• Billing model: pay only for what you use– Friction-free access to add’l or less storage

Page 4: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Part A

Storage services

Page 5: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Part A – Executive Summary

Use Azure Blobs and Tables and your DATA will be resilient to failure and will scale like crazy…

Page 6: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Persistent Storage Services – Options

Type of Data Traditional Azure Way

Relational SQL Server SQL Azure

Blob File System, or SQL Server

Azure Blobs

File File System Azure Drives, or Azure Blobs

Reliable Queue MSMQ (maybe) Azure Queues

Non-Relational Azure Tables

Page 7: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Storage and Services

• Family of specialized, complementary storage and messaging services– Clean abstractions– Specialized services

• Queues • Blobs, Drives, CDN• Tables • SQL Azure

Page 8: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure API

• RESTful interfaces for interacting with Queue, Table Storage, and Blob Storage

• SQL Azure is same as SQL Server• Client agnostic

• [Service Management API also exists and is RESTful]

Page 9: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

All Azure Storage is Durable

• Resilient in case of failure– “All data replicated multiple times” – Sriram Krishnan,

Programming Windows Azure, p130+– 3 copies

• SQL Azure supports full relational semantics– ACID = Atomicity, Consistency, Isolation, and Durability– Part of the PaaS-ness

• Blob Storage, Table Storage, Queues– Which of these support ACID?

Page 10: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Blob Storage• The place to put ANY LARGE OBJECT• Private or Public• Public blobs can be anonymously accessed– Images, videos, CSS files– Need not be binary

• Public blobs can be cached in Azure CDN– 20+ locations around the world– Different locations than data centers

• Time-limited signed-access available– “You have until tomorrow to download this video”

Page 11: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Blob Storage

• Two types of Azure Blobs1.“Block Blob”– Parallel upload scenarios– Resumable download/streaming scenarios– Up to 200 GB

2.“Page Blob”– Random read/write access scenarios– Azure Drives– Up to 1000 GB

Page 12: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Blob Storage

Storage Account

Container[*]

Blob[*]Unique URL

Properties [several]Metadata [255 entries]

Name/Value/Type

Page 13: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Table Storage

• Best place for granular, semi-structured data– No rigid database schema

• Fast and easy to instantiate– Strongly Consistent– No performance lag

• Programming model is WCF Data Services– All data access and data updates– LINQ

Page 14: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Table Storage

Storage Account

Table [*]

Entity [*, 1 MB data] PartitionKey + RowKey

Property [255x]Name/Value/Type

Up to 64k

Page 15: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Table Storage

• Partition Key– Along a “logical grouping” – a “shard”– PartitionKey value of up to 64 KB

• Row Key– Identify specific row within a partition– RowKey value is String of up to 64 KB

• Table access requires Partition Key + Row Key– Not to mention (cryptographic) Access Key (for the

digital signing of the http header)

Page 16: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Relational Data vs. Azure TablesApproach SQL Azure Azure Tables

Normalization Normalized Denormalized(Duplication) (No duplication) (Lots of duplication)

Structure Schema Flexible

Transactions Distributed Limited scope

Responsibility Database Developer

Knobs Many Few

Scale Up (or Sharding) Out

Cost Reasonable Less expensive

Page 17: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.
Page 18: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Pay As You Go – Storage

• Storage– $0.15 per GB stored per month– $0.01 per 10,000 storage transactions

• Applies equally to:– Queues– Tables– Blobs– Drives

Page 19: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Pay As You Go – Data Transfer

• North America and Europe regions– $0.10 per GB in– $0.15 per GB out

• Asia Pacific Region– $0.30 per GB in– $0.45 per GB out

• No charge for transfer within a data center

Page 20: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

What is Cost of 1 Byte?

• Azure Storage cost/byte = x• SQL Azure cost/byte = 66x• Practical multiplier might be 100x

Page 21: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Part B

Decoupling patterns

Page 22: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Part B – Executive Summary

Scale out, not up, and your COMPUTE will be resilient to failure and will scale like crazy…

Page 23: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Does Compute

Compute Services• Web Roles• Worker Roles

• VM Role (Nov 2010)

• Your Code Runs Here

Page 24: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

“Out” is the New “Up”

• Scaling Out has hard limits at CPU, Memory– Architecturally more limiting

Page 25: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Storage Services in Concert

Page 26: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Queue Storage

• In Azure’s architecture, part of Storage Family of Services– Builds on Blob Storage

• In Your architecture, it is your Messaging between loosely-coupled system components– Compute + Storage + Messaging

Page 27: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Key Pattern: Roles + Queues

WebRole(IIS)

WebRole(IIS)

WorkerRole

WorkerRole

Queues

BlobsTables

Page 28: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Canonical Example: Thumbnails

WebRole(IIS)

WebRole(IIS)

WorkerRole

WorkerRole

Queues

BlobsTables

Page 29: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Adding to Queue - Conceptual

Page 30: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Blob Storage

Adding to Queue - Actual

314159 265358 979323

Page 31: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Roles + Queues: API

WebRole(IIS)

WebRole(IIS)

WorkerRole

WorkerRole

Queues

queue.AddMessage( new CloudQueueMessage( payloadStringOrByteArray));

CloudQueueMessage statusUpdateMessage = queue.GetMessage( TimeSpan.FromSeconds(10));

… queue.DeleteMessage(statusUpdateMessage);

Page 32: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

General Case: Rolesn + Queuesn

RnQnRn

WebRole(IIS)

WebRole(IIS)

WorkerRole

WorkerRole

Queues

WebRole(IIS)

WebRole(IIS)

WebRole(IIS)

WebRole(IIS)

WebRole(IIS)

WebRole(IIS)

WorkerRole

WorkerRoleWorker

RoleWorker

RoleWorker

Role Type 1

WorkerRole

Type 1

WorkerRole

WorkerRoleWorker

RoleWorker

RoleWorkerRole

WorkerRoleWorker

Role Type 2

WorkerRole

Type 2

Page 33: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Look @ WorkerRole.csThumbnailing Code

public class WorkerRole : RoleEntryPoint {

public override void Run() { … }}

Page 34: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Azure Queues – by the numbers

• Service for RELIABLE message delivery• 7 days = default TTL for item to stay in queue• 30 seconds = default “invisibility window”• 8 KB = max size of a queued item• 500 = approx number of transactions a queue

can handle per second– Beware of “spinning” – may get throttled, disabled

• What happens if you need more than 500 tps?

Page 35: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Key Metric

• Queue length (and trend) is key data point for tuning Role deployment numbers–Available programmatically for

monitoring–May vary across queue types

Page 36: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

RnQnRn enables Responsive

• Response to interactive users is as fast as a work request can be persisted

• Time consuming work done off-line• Same total resource consumption, better

subjective experience• UX challenge – how to express Async to users?– Communicate Progress– Display Final results

Page 37: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

RnQnRn enables Scalable

• Loosely coupled, concern-independent scaling• Blocking is Bane of Scalability– Decoupled front/back ends insulate from other

system issues if…– Twitter down– Email server unreachable– Order processing partner doing maintenance– Internet connectivity interruption

Page 38: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

RnQnRn enables Distribution• Scale out systems better

suited for geographic distribution

– More efficient and flexible because more granular

– Hard for a mega-machine to be in more than one place

– Failure need not be binary

Page 39: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Optimization is optional• Individual role utilization may be low– Role is a VM – lots of resources– You pay by instance, not resource use within

• Make sure VM instances are “right sized”– XS ($0.05/hr), Small ($0.12/hr), Medium, Large, XL

• Make sure enough roles for uptime– SLA requires minimum of 2 instances

• Business Trade-Off for further optimizations– Optimize for CPU utilization (multiple threads)– Combine types of processing into fewer role types

Page 40: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

RnQnRn requires Idempotent

• If we do a task twice, end result same as if we did it once

• App-specific concerns dictate approaches– Compensating transactions– Last in wins– Many others possible – hard to say

• Example with Thumnailing

Page 41: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

RnQnRn requires Poison Message Strategy

• A Poison Message is not able to be processed– Error condition– Non-transient reason– CloudQueueMessage.DequeueCount property

• Strategy One: – Fall off the queue (TTL)– Message stays in queue for 7 days (default)

• Strategy Two:– Specify retry threshold– Remove poison messages

Page 42: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

RnQnRn enables Resilient

• And Requires that you “Plan for failure”• There will be role restarts• Bake in handling of restarts– Not an exception case! Expect it!– Restarts are routine, system “just keeps working”

• If you follow the pattern, the payoff is substantial…

Page 43: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

What’s Up?Aspirin-free Reliability as EMERGENT PROPERTY

Typical Site Any Azure Role Overall SystemOperating System UpgradeApplication Update / DeployChange TopologyHardware FailureSoftware Bug / Crash / FailureSecurity Patch

Page 44: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Questions?

?

Page 45: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

BostonAzure.org

• Boston Azure cloud user group• Focused on Microsoft’s cloud solution• Next meeting: 6-8:30 PM Mon Dec 13sh 2010– Hacking on “Boston Azure Project”– Silverlight and Azure – better together

• Meetings usually 4th Thursday of month– No cost; food; great topics; growing community; wifi

• Join email list: http://bostonazure.org• Follow on Twitter: @bostonazure

Page 46: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Slides available from Bill’s blog

http://blog.codingoutloud.com-or-

http://hmbl.me/3KTBOE

Note: hmbl.me is a URL shortening service running on Azure.

Page 47: Cloud-Native in Azure Zoran B. Djordjevic’s CSCI E-175 Cloud Computing and Software as a Service class at Harvard University 19-November-2010 Copyright.

Bill Wilder@codingoutloudhttp://blog.codingoutloud.com


Recommended