61
Windows Azure Platfor Windows Azure Platfor Design considerations for storing data in the cloud with Windows Azure Eric Nelson Microsoft UK Blog: http://geekswithblogs.net/iupdateable Twitter: http://twitter.com/ericnel and http://twitter.com/ukmsdn Podcast: http://bit.ly/msdnpodcast Newsletter: http://msdn.microsoft.com/en-gb/flash Slides, links and background “diary” posts can be found on my blog

Design Considerations For Storing With Windows Azure

Embed Size (px)

DESCRIPTION

Final deck for Software Architect 2009. Download is now enabled.

Citation preview

Page 1: Design Considerations For Storing With Windows Azure

Windows Azure PlatformWindows Azure Platform

Design considerations for storing data in the cloud with Windows Azure

Eric NelsonMicrosoft UK

Blog: http://geekswithblogs.net/iupdateableTwitter: http://twitter.com/ericnel and http://twitter.com/ukmsdnPodcast: http://bit.ly/msdnpodcast Newsletter: http://msdn.microsoft.com/en-gb/flash

Slides, links and background “diary” posts can be found on my blog

Page 2: Design Considerations For Storing With Windows Azure

Windows Azure Platform

2

Windows Azure Platform

• Windows Azure Platform 101• Storage in the Cloud• Blobs• Tables• Relational• Queues

• Lesson learned

Agenda

Page 3: Design Considerations For Storing With Windows Azure

Windows Azure Platform

WINDOWS AZURE PLATFORM 101Just in case you had something better to do over the last 18months

Page 4: Design Considerations For Storing With Windows Azure

Windows Azure Platform

3 Important Services• Windows Azure– Compute and

Storage• SQL Azure– Storage

• .NET Services– Connecting

3 Critical Concepts• Computation– Web and Worker

• Storage– Table, Blob,

Relational• Messaging– Queues, Service Bus

Page 5: Design Considerations For Storing With Windows Azure

Windows Azure PlatformA simple site

Web TierBrowserRequest

B/L Tier Database

Response

“Wow! What a great site!”

Page 6: Design Considerations For Storing With Windows Azure

Windows Azure PlatformUnder load

Web Tier B/L Tier Database

Browser

Browser

Browser

Browser

Browser

“Server Busy”

Page 7: Design Considerations For Storing With Windows Azure

Windows Azure PlatformUnder load

Web Tier B/L Tier Database

Browser

“Timeout”

Browser

Browser

Browser

Browser

Page 8: Design Considerations For Storing With Windows Azure

Windows Azure PlatformSolve using on-premise

Browser

Browser

Browser

Browser

Browser

B/L Tier

B/L Tier

B/L Tier

N L B

Database

p1 p2 p3

Web Tier

Web Tier

Web Tier

N L B

Page 9: Design Considerations For Storing With Windows Azure

Windows Azure PlatformHowever…

Browser B/L Tier

B/L Tier

B/L Tier

N L B

Database

p1 p2 p3

Web Tier

Web Tier

Web Tier

N L B

“Not so great now…”

“Hmmm... Most of this stuff is sitting idle...”

“That took a lot of work - and money!”

Page 10: Design Considerations For Storing With Windows Azure

Windows Azure PlatformSolve using the Cloud aka Windows Azure Platform

Web Role

AzureStorag

e

Browser

Browser

Browser

Browser

Browser

Web Role

Web Role

N L B

Worker Role

Worker RoleN

L B

p1 p2 p3

You don’t see this bit

You don’t see this bit

You don’t see this bit

Worker Role

or…Maybe you do

Page 11: Design Considerations For Storing With Windows Azure

Windows Azure PlatformSolve using the Cloud aka Windows Azure Platform

Web Role

AzureStorag

e

Browser

Browser

Browser

Browser

Browser

Web Role

Web Role

N L B

Worker Role

Worker RoleN

L B

p1 p2 p3

You don’t see this bit

You don’t see this bit

You don’t see this bit

Worker Role

Ok, you

definitely do

SQLAzure

Page 12: Design Considerations For Storing With Windows Azure

Windows Azure Platform

DEMO: WINDOWS AZURE PORTAL

Page 13: Design Considerations For Storing With Windows Azure

Windows Azure Platform

STORAGE IN THE CLOUD…

Windows Azure Storage and SQL Azure

Page 14: Design Considerations For Storing With Windows Azure

Windows Azure Platform

BLOBS, TABLES, RELATIONAL

Page 15: Design Considerations For Storing With Windows Azure

Windows Azure Platform

BLOBS, TABLES, RELATIONAL

Page 16: Design Considerations For Storing With Windows Azure

Windows Azure Platform

16

Windows Azure Platform

Blobs stored in Containers 1 or more Containers per account

• Scoping is at container level• …/Container/blobpath

Blobs• Capacity 50GB in CTP• Metadata, accessed independently

Private or Public container access

Blobs

Page 17: Design Considerations For Storing With Windows Azure

Windows Azure PlatformPut a Blob

Client Azure Blob

Storage

REST API

PutBlob PUT http://account.blob.core.windows./net/containername/blobname

Blob Container

http://account.blob.core.windows.net/containername/blobname

Page 18: Design Considerations For Storing With Windows Azure

Windows Azure PlatformGet a Blob

Client Azure Blob

Storage

REST API

GetBlob GET http://account.blob.core.windows./net/containername/blobname

Blob Container

http://account.blob.core.windows.net/containername/blobname

Page 19: Design Considerations For Storing With Windows Azure

Windows Azure PlatformGet part of a Blob

Client Azure Blob

Storage

REST API

GetBlob GET http://account.blob.core.windows./net/containername/blobnameRange: bytes=329300 - 730000

Blob Container

http://account.blob.core.windows.net/containername/blobname

Page 20: Design Considerations For Storing With Windows Azure

Windows Azure PlatformPut a LARGE Blob

Client Azure Blob

Storage

REST API

PutBlock(blobname, blockid7, data)PutBlockList(blobname, blockid1, …, blockidN)

Blob Container

http://account.blob.core.windows.net/containername/blobname

PutBlock(blobname, blockid1, data)

Page 21: Design Considerations For Storing With Windows Azure

Windows Azure Platform

BLOBS, TABLES, RELATIONAL

Page 22: Design Considerations For Storing With Windows Azure

Windows Azure Platform

22

Windows Azure Platform

Provides structured storage• Massively scalable tables (TBs of data)• Self scaling• Highly available• Durable

Familiar and easy-to-use API, layered• .NET classes and LINQ• ADO.NET Data Services – .NET 3.5 SP1• REST – with any platform or language

Introduction to Tables

Page 23: Design Considerations For Storing With Windows Azure

Windows Azure Platform

23

Windows Azure Platform

No join No group by No order by “No Schema”

Not a Relational Database

Page 24: Design Considerations For Storing With Windows Azure

Windows Azure Platform

24

Windows Azure Platform

Table• A Table is a set of Entities (rows)• An Entity is a set of Properties (columns)

Entity• Two “key” properties form unique ID• PartitionKey – enables scale• RowKey – uniquely ID within a partition

Data Model

Page 25: Design Considerations For Storing With Windows Azure

Windows Azure Platform

25

Windows Azure Platform

Getting all of dunnry’s blog posts is fast• Single partition

Getting all posts after 2008-03-27 is slow• Traverse all partitions

Key Example – Blog PostsPartition Key

AuthorRow Key

PermalinkProperty 3ChangedOn

Property 4Title

smarx i-love-tables 2009-07-04 I Love Tables!

smarx tables-are-awesome 2009-07-12 Tables are

Awesome!

dunnry cheetos 2008-03-27 I Love Cheetos

dunnry blogging-again 2009-07-15 Finally Blogging

Again

dunnry phluffyfotos 2008-04-09 PhluffyFotos!

Partition 1

Partition 2

Page 26: Design Considerations For Storing With Windows Azure

Windows Azure PlatformQuery a Table

Worker Role

AzureTable

Storage

http://account.table.core.windows.net

REST: GET http://account.table.core.windows.net/Customer?$filter=%20PartitionKey%20eq%20value LINQ:var customers = from o in context.CreateQuery<customer>(“Customer”) where o.PartitionKey == value select o;

Page 27: Design Considerations For Storing With Windows Azure

Windows Azure Platform

27

Windows Azure Platform

Tradeoff between locality and scalability Considerations

• Entity group transactions• Query efficiency• Scalability• Flexible Partitioning

Choosing a Partition Key

Page 28: Design Considerations For Storing With Windows Azure

Windows Azure Platform

28

Windows Azure Platform

Pick potential keys (common query filters) Order keys by importance If needed, include an additional unique key Use two most important keys as PK, RK Consider concatenating to form keys

A Method of Choosing Keys

Page 29: Design Considerations For Storing With Windows Azure

Windows Azure Platform

29

Windows Azure Platform

Non-key queries are scans Improve performance by scoping

• Usually by partition key• But what about by table?

3 tables• Top 1,000 popular items• Top 10,000 popular items• Everything

Now arbitrary “top 1,000” queries are fast Better locality than clever partition keys

Write many is one approach

Page 30: Design Considerations For Storing With Windows Azure

Windows Azure Platform

DEMO: WINDOWS AZURE STORAGE

Page 31: Design Considerations For Storing With Windows Azure

Windows Azure Platform

31

Windows Azure Platform

Azure tables are *not* a relational database• Requires a mind shift• Azure tables scale• 3 - 9s availability• Azure tables support exactly one key• PartitionKey + RowKey

• Case Matters• No foreign keys• No referential integrity• No stored procedures

Lessons LearnedAzure Storage

Page 32: Design Considerations For Storing With Windows Azure

Windows Azure Platform

32

Windows Azure Platform

Azure Storage Client Library• No longer just a “sample”

Azure storage is available via REST• Not limited to Azure hosted apps• Not limited to Microsoft platform or tools• Getting the signature correct is the hard part

Lessons LearnedAzure Storage

Page 33: Design Considerations For Storing With Windows Azure

Windows Azure Platform

33

Windows Azure Platform

REST is *not* TDS• Be prepared to parse• LINQ and XML classes help• Sometimes, string parsing is the best choice

Azure storage names are picky• So are Azure key values• It’s possible to create an entity in a table and not be able to

update or delete it

Lessons LearnedAzure Storage - RESTful

Page 34: Design Considerations For Storing With Windows Azure

Windows Azure Platform

34

Windows Azure Platform

Often better to pull back more than you need vs. multiple roundtrips

LINQ on results in memory is fast & flexible• foreach works well too

Sort and cache tables on the web tier

Lessons LearnedAzure Storage – Roundtrips are expensive

Page 35: Design Considerations For Storing With Windows Azure

Windows Azure Platform

35

Windows Azure Platform

Different Entity types in the same table E.g. PK = CustomerId

• Customer, Order and OrderDetails in the same table

Lessons LearnedAzure Storage – Entity Group Transactions

PK RK

Cust1 Cust1 Name=“MSFT” Desc=“...”

Cust1 Order1 Date=“25/12/09”

Cust1 OrdeDetail1 Product=12 Quantity=6

Cust1 OrderDetail2 Product=13 Quantity=1

Cust2 Cust2 Name=“IBM” Desc=“...”

Page 36: Design Considerations For Storing With Windows Azure

Windows Azure Platform

BLOBS, TABLES, RELATIONAL

Page 37: Design Considerations For Storing With Windows Azure

Windows Azure Platform

SQL Azure (July 2009)aka SQL Data Services

aka SQL Server Data Services

Page 38: Design Considerations For Storing With Windows Azure

Windows Azure PlatformOn Premise Programming Model

SQL Server

Client RDBMS

TDSData

This is what we do on-premise...

Page 39: Design Considerations For Storing With Windows Azure

Windows Azure PlatformSame for the cloud?

SQL Server

Client RDBMS

TDSData

So, is this is what we would like to do in the cloud...

Page 40: Design Considerations For Storing With Windows Azure

Windows Azure PlatformSQL Azure can do this

SQL Azure

Client RDBMS

TDSData

Page 41: Design Considerations For Storing With Windows Azure

Windows Azure PlatformSQL Azure can also do this

SQL Azure

Browser RDBMS

TDSWeb Role

HTTP

Page 42: Design Considerations For Storing With Windows Azure

Windows Azure PlatformAnd this!

SQL Azure

Browser RDBMS

TDS

Web RoleHTTP

Worker Role

Queue

Page 43: Design Considerations For Storing With Windows Azure

Windows Azure PlatformWhich means you can easily migrate from this

Browser RDBMS

Web TierHTTP

Bus. Logic

“The Data Center”

SQL Server

TDS

Page 44: Design Considerations For Storing With Windows Azure

Windows Azure PlatformTo this… Windows Azure and SQL Azure

SQL Azure

Browser RDBMS

TDS

Web RoleHTTP

Worker Role

Queue

“The Cloud”

Page 45: Design Considerations For Storing With Windows Azure

Windows Azure Platform

DEMO: SQL AZURE

Page 46: Design Considerations For Storing With Windows Azure

Windows Azure Platform

46

Windows Azure Platform

From the database “down” it’s just SQL Server• Well, almost …• Many tools don’t work today

• System catalog is different

Above the database is taken care of for you• You can’t really change anything

Lessons LearnedSQL Azure

Page 47: Design Considerations For Storing With Windows Azure

Windows Azure Platform

47

Windows Azure Platform

Tooling• SSMS partially works – “good enough”• Can not create connection using Visual Studio designer• Other tools may work better• No BCP (currently)

DDL• Must be a clustered index on every table• No physical file placement• No indexed views• No “not for replication” constraint allowed• No Extended properties• Some index options missing (e.g. allow_row_locks, sort_in_tempdb ..)• No set ansi_nulls on

Lessons LearnedSQL Azure

Page 48: Design Considerations For Storing With Windows Azure

Windows Azure Platform

48

Windows Azure Platform

Types• No spatial or hierarchy id• No Text/images support.

• Use nvarchar(max)• XML datatype and schema allowed but no XML index or schema

collection.

Security• No integrated security

Lessons LearnedSQL Azure

Page 49: Design Considerations For Storing With Windows Azure

Windows Azure Platform

49

Windows Azure Platform

Development• No CLR• Local temp tables are allowed • Global temp tables are not allowed• Cannot alter database inside a connection• No UDDT’s• No ROWGUIDCOL column property

Lessons LearnedSQL Azure

Page 50: Design Considerations For Storing With Windows Azure

Windows Azure Platform

50

Windows Azure Platform

SQL Server is very familiar• SQL Azure *is* SQL Server in the cloud

Windows Azure Storage is…very different Make the right choice

• Understand Azure storage• Understand SQL Azure• Understand they are totally different

You can use both

Lessons LearnedSQL Azure vs Windows Azure Tables

Page 51: Design Considerations For Storing With Windows Azure

Windows Azure Platform

51

Windows Azure Platform

SQL Azure is not always the best storage option SQL Azure costs more

• Delivers a *lot* more functionality

SQL Azure is more limited on scale

Lessons Learned SQL Azure vs Windows Azure Tables

Page 52: Design Considerations For Storing With Windows Azure

Windows Azure Platform

52

Windows Azure Platform

Can be done• Many 10GB databases

Not fun

Lessons Learned SQL Azure and Sharding

Page 53: Design Considerations For Storing With Windows Azure

Windows Azure Platform

QUEUES

Page 54: Design Considerations For Storing With Windows Azure

Windows Azure Platform

54

Windows Azure Platform

Simple asynchronous dispatch queue• Create and delete queues

Message:• Retrieved at least once• Max size 8kb• Operations:• Enqueue• Dequeue• RemoveMessage

Queues

Page 55: Design Considerations For Storing With Windows Azure

Windows Azure PlatformUsing the Cloud for Communications

ClientREST

Azure Queue

http://app.queue.core.windows.net/

Page 56: Design Considerations For Storing With Windows Azure

Windows Azure PlatformUsing the Cloud for Communications

Client

RESTAzure Queue

http://app.queue.core.windows.net/

Client

Company 1

Company 2

Page 57: Design Considerations For Storing With Windows Azure

Windows Azure PlatformUsing the Cloud for Communications

Client

RESTAzure Queue

http://app.queue.core.windows.net/

Client

Company 1

Company 2x

Page 58: Design Considerations For Storing With Windows Azure

Windows Azure PlatformUsing the Cloud for Communications

Client

RESTAzure Queue

http://app.queue.core.windows.net/

Client

Company 1

Company 2

Web Role

Page 59: Design Considerations For Storing With Windows Azure

Windows Azure Platform

IN SUMMARY

Page 60: Design Considerations For Storing With Windows Azure

Windows Azure Platform

Windows Azure Platform Benefits

Windows Azure• High Level of Abstraction

– Hardware– Server OS– Network Infrastructure– Web Server

• Availability– Automated Service Management

• Scalability– Instance & Partitions

• Developer Experience– Familiar Developer Tools

SQL Azure• Higher Level of Abstraction

– Hardware– Server OS– Network Infrastructure– Database Server

• Availability– Automated Database

Management & Replication

• Scalability– Databases Partitioning

• Developer Experience– Familiar SQL Environment

Page 61: Design Considerations For Storing With Windows Azure

Windows Azure Platform

Resources

• Slides, links and more– http://geekswithblogs.net/iupdateable– Azure Training Kit (August update)

• www.azure.com– Sign up, links to resources etc

• http://www.azureadvantage.co.uk/ – Rapid provisioning of Windows Azure