storage options on windows azure

43
Database options on Azure Himanshu Desai Principal Consultant, Technical Specialist (WCF) 1

Upload: himanshu-desai

Post on 15-Jul-2015

87 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Storage Options on Windows Azure

Database options on Azure

Himanshu Desai

Principal Consultant, Technical Specialist (WCF)1

Page 2: Storage Options on Windows Azure

Page

Agenda› Understand Azure Database Offering

› Overview of Azure SQL Database

› Overview of Azure Table Storage

› Overview of DocumentDB

› Suitability of Each options

/ Copyright ©2014 by Readify Pty Ltd2

Page 3: Storage Options on Windows Azure

Page / Copyright ©2015 by Readify Pty Ltd4

DB

SQL

DB

SQL

DB

SQL

App

SQL Azure

DB

Virtual Machine

SQL Server

Document DB

Partition KeyPartition

1

2

A

Table Storage

1

A

Row Key

Entity

Page 4: Storage Options on Windows Azure

Page

Who is responsible?› Developers

› Testers

› Operations

/ Copyright ©2014 by Readify Pty Ltd5

Page 5: Storage Options on Windows Azure

SQL Azure

Page 6: Storage Options on Windows Azure

Page

Features› Database as a service

› Elastic Scale with Sharding*

› Predicatableperformance

› Availability backed by replica and SLA

› Data protection via auditing, restore and geo-replication

› Self managed

› Three replica are running at one time (one primary and two or more seconday)

› Availability in 3 Tiers: Basic (2GB), Standard (250GB) & Premium (500GB)

/ Copyright ©2014 by Readify Pty Ltd7

Page 7: Storage Options on Windows Azure

Page

Sharding – Why?› The total amount of data is too large to fit within the constraints of a single database

› The transaction throughput of the overall workload exceeds the capabilities of a single

database

› Tenants may require physical isolation from each other, so separate databases are needed

for each tenant

› Different sections of a database may need to reside in different geographies for

compliance, performance or geopolitical reasons.

/ Copyright ©2014 by Readify Pty Ltd8

Page 8: Storage Options on Windows Azure

Page

Horizontal Vs Vertical Scaling

/ Copyright ©2014 by Readify Pty Ltd9

Page 9: Storage Options on Windows Azure

Page

Single Vs Multi-Tenant

/ Copyright ©2014 by Readify Pty Ltd10

Page 10: Storage Options on Windows Azure

Page

Backup & Restore› Point in time restore

› Geo-Restore

› Standard Geo -replication

› Active Geo-replication.

/ Copyright ©2014 by Readify Pty Ltd11

Page 11: Storage Options on Windows Azure

Page

Management› SQL Management Studio

› REST API’s

› Powershell Scripts

› Azure Management portal

/ Copyright ©2014 by Readify Pty Ltd12

Page 12: Storage Options on Windows Azure

Page

What is not supported› https://msdn.microsoft.com/en-us/library/azure/ee336281.aspx

/ Copyright ©2014 by Readify Pty Ltd13

Page 13: Storage Options on Windows Azure

Page

Demo

/ Copyright ©2014 by Readify Pty Ltd14

Page 14: Storage Options on Windows Azure

Page

Azure Table Storage

/ Copyright ©2014 by Readify Pty Ltd15

Page 15: Storage Options on Windows Azure

Page

What is Table Storage› Auto-sharded, key value store

› Single table can contain upto 500TB at a cost of

7c/Gb/month

› Scalability Target of 20K ops/second

/ Copyright ©2014 by Readify Pty Ltd16

Page 16: Storage Options on Windows Azure

Page

Key Features› Schema less with only 3 predefined fields

› Structured Storage

› Massively scalable tables

› Highly available and durable

› Data is replicated several times

› Usage via REST API or Windows Azure Storage client

libraries

› Storing data for efficient retrieval and presistence/ Copyright ©2014 by Readify Pty Ltd17

Page 17: Storage Options on Windows Azure

Page

Required Entity Properties› PartitionKey & RowKey

› Uniquely Identifies an entity

› Defines the sort order

› Use them to scale your app

› Timestamp

› Readonly

› Optimistic concurrency

/ Copyright ©2014 by Readify Pty Ltd18

Page 18: Storage Options on Windows Azure

Page

Table Storage Concepts

/ Copyright ©2014 by Readify Pty Ltd19

BooksOnline

Users

Books

Email

Name

Email

Name

Title

ISBN

Title

ISBN

Accounts Tables Entities

Page 19: Storage Options on Windows Azure

Page

Table Data Model› Table

› A Storage account can create many tables

› Table name is scoped by account

› Set of entities (i.e. rows)

› Entity

› Set of properties (columns)

› Required properties

› PartitionKey, RowKey & Timestamp/ Copyright ©2014 by Readify Pty Ltd20

Page 20: Storage Options on Windows Azure

PagePage / Copyright ©2014 by Readify Pty Ltd21

Partition Key

1

A

Row Key

Entity

Partition: ABC / Machine 1

1

2

A

Partition: DEF / Machine 2

1

2

A

Partition : HIJ / Machine 3

1

2

A

PartitionId RowKey Name Address Timestamp

ABC 1 …

ABC 2 ….

ABC 3 ….

PartitionId RowKey Name Address Timestam

p

DEF 4

DEF 5

DEF 6

PartitionId RowKe

y

Name Address Timestam

p

HIJ 7

HIJ 8

HIJ 9

Page 21: Storage Options on Windows Azure

Page

PartitionKey and Partitions› PartitionKey

› Used to group entities in the table into parititions

› A table partition

› All entities with same partition key value

› Unit of scale

› Control entity locality

› Row key provides uniqueness within a partition

/ Copyright ©2014 by Readify Pty Ltd22

Page 22: Storage Options on Windows Azure

Page

Partitioning Tables- Why› Scale

› Each individual partitions are distributed across multiple storage nodes

› System monitors the partitions usage and automatically balances

partitions across multiple storage nodes

› A partitions i.e. all entities with same partition key, will be served by a

single node

› Entity group transactions

› Allow the application to auto perform multiple Create/Update/Delete

operations across multiple entities using batch request

/ Copyright ©2014 by Readify Pty Ltd23

Page 23: Storage Options on Windows Azure

Page

Query Speed› Fast

› Single paritionkey and rowkey with equality

› Medium

› Single partion but a small range of rowkey

› Entire partition or table that is small

› Slow

› Large single scan

› Large table scan

› “OR” predicates on keys => no query optimisation =>results in scan

› Expect Continuation tokens/ Copyright ©2014 by Readify Pty Ltd24

Page 24: Storage Options on Windows Azure

Page

Make Faster Queries› Large Scans

› Split the range and parallelize queries

› Create and maintain own views that help queries

› “Or” Predicates

› Execute individual query in parallel

› User Interactive

› Cache the result to reduce scan frequency

/ Copyright ©2014 by Readify Pty Ltd25

Page 25: Storage Options on Windows Azure

Page

Continuation token› Max of 1k rows in a response

› At the end of partition range boundary

› Max of 5 secs to execute the query

› Expect continuation token always

› If the query times out, Server returns continuation token so that client

can make another query

› When the scan crosses the partition boundaries, continuatin token is

returned.

/ Copyright ©2014 by Readify Pty Ltd26

Page 26: Storage Options on Windows Azure

Page

Pagination› Use IQueryable<>.Take(N) to fetch the top results

› Use continuation

› http://<serviceUri>/Something?<originalQuery>&NextPartitionKey=<

someValue>&NextRowKey=<someOtherValue>

/ Copyright ©2014 by Readify Pty Ltd27

Page 27: Storage Options on Windows Azure

Page

Retrieve latest value› Have the row key as

› DateTime.MaxValue.Ticks-DateTime.UtcNow.Ticks

/ Copyright ©2014 by Readify Pty Ltd28

Page 28: Storage Options on Windows Azure

Page

Prefix based retrieval› Use CompareTo and ‘>’ and ‘<‘ function effectively

› myTable.Partitionkey.CompareTo(“somekey”)>=0

/ Copyright ©2014 by Readify Pty Ltd29

Page 29: Storage Options on Windows Azure

Page

Demo

/ Copyright ©2014 by Readify Pty Ltd30

Page 30: Storage Options on Windows Azure

Page

DocumentDB

/ Copyright ©2014 by Readify Pty Ltd31

Page 31: Storage Options on Windows Azure

Page

What is DocumentDB?› Document database that supports fully manage

storage of JSON documents in a highly performant

way.

› Fully managed distributed database.

› (Still in preview and available in West US,North & West

Europe, cost around 73 cents a day which includes 50%

discount.)

/ Copyright ©2014 by Readify Pty Ltd32

Page 32: Storage Options on Windows Azure

Page

Key Features› Schema less, NoSQL document database

› Fully managed, with provisioned capacity

› Allows for SQL like queries on Semi structured data (i.e. JSON files)

› Supports strong consistency for transactional applications

› Designed to scale into petabytes

› Includes libraries for Node,.NET, REST,Javascript (Client & Server),Python

› Includes Hekaton technologies (In Memory SQL)

/ Copyright ©2014 by Readify Pty Ltd33

Page 33: Storage Options on Windows Azure

Page

Management› Supported in new portal

› Manage database account, collections, users etc

› View consumption statistics

› http://portal.azure.com

› Use tools like

› Query explorer

› Document explorer

› DocumentDB studio

/ Copyright ©2014 by Readify Pty Ltd34

Page 34: Storage Options on Windows Azure

Page

Overview of DocumentDB

/ Copyright ©2014 by Readify Pty Ltd35

Page 35: Storage Options on Windows Azure

Page

Database Accounts

/ Copyright ©2014 by Readify Pty Ltd36

Page 36: Storage Options on Windows Azure

Page

Resource Model› Database Account

› Database

› Collection

› Document

› Attachment

› Stored Procedure

› Trigger

› User-defined functions

› User

› Permission

› Media/ Copyright ©2014 by Readify Pty Ltd37

Page 37: Storage Options on Windows Azure

Page

Resource Addresssing› Restful

› Unique ID

› API Url:

› https://{databaseaccount}.documents.azure.com

› Document Path

› /dbs/{database id}/colls/{collectionid}/docs/{documentid}

› Client libraries

› .NET

› Javascript

› Python/ Copyright ©2014 by Readify Pty Ltd38

Page 38: Storage Options on Windows Azure

Page

Capacity Unit› Database accounts comes with administrative quota of

› 100 databases

› 500,000 users

› 2,000,000 permissions

It includes quota for collections*

If you run out of CU, add more. They are stackable backed by SSD.

Each CU comes with 3 elastic collections,2000 RU & 10 GB of SSD

backed document storage

› Elastic by default. Document portioned by collection can have unlimited

storage. Not scoped to machine. Acts as a transaction domain

/ Copyright ©2014 by Readify Pty Ltd39

Page 39: Storage Options on Windows Azure

Page

REST API› Standard Operations

› Create,Delete,Put,Get,Post

› Permanent Uri on Create

› HMAC authentication using management or resource

key

› DocumentDB request headers

/ Copyright ©2014 by Readify Pty Ltd40

Page 40: Storage Options on Windows Azure

Page

.NET Development› You need following from the portal after provision a

database

› Endpoint Url

› Authorization key

› Nu-get package

› Install-Package Microsoft.Azure.Documents.Client –

Pre

› Use them to create DocumentClient/ Copyright ©2014 by Readify Pty Ltd41

Page 41: Storage Options on Windows Azure

Page

Demo

/ Copyright ©2014 by Readify Pty Ltd42

Page 42: Storage Options on Windows Azure

PagePage / Copyright ©2014 by Readify Pty Ltd43

Table Storage SQL Azure DocumentDB

Semi-structured Fully Structured Semi-Structured

Loosely typed Strongly typed Document Based Access

Non-Relational (Not RDMS) Relational (RDMS) Non-Relational

Massively scalable Highly Scalable Massively Scalable

REST API & Client SDK for

querying

Full SQL Support Good SQL Support for

querying hierarchical data

within a collection

N/A Stored Procs, UDFs etc Stored Procs, UDFs etc

Each CU comes with 3

collections. In Preview,

collection can grow upto

10GB and 2K RU of

throughput.

Page 43: Storage Options on Windows Azure

Page

Thank you

Himanshu Desai

[email protected]

/ Copyright ©2014 by Readify Pty Ltd44