more cache for less cash (devlink 2014)

45
More Cache for Less Cash Michael S. Collier @MichaelCollier DevLink 2014 – August 27, 2014

Upload: michael-collier

Post on 02-Jun-2015

1.740 views

Category:

Technology


0 download

DESCRIPTION

Review of the various cache options available in the Microsoft Azure platform.

TRANSCRIPT

Page 1: More Cache for Less Cash (DevLink 2014)

More Cache for Less Cash

Michael S. Collier@MichaelCollier

DevLink 2014 – August 27, 2014

Page 2: More Cache for Less Cash (DevLink 2014)

Today’s Agenda

• Why Cache?• Cache Options in Azure• Demos• Monitoring and Scaling• Pricing and Features

3

Page 3: More Cache for Less Cash (DevLink 2014)

4

Why Cache?

Load on server increases with users

Add a load balancer and more web instances

Continue to scale out the web and business logic tiers

DB load starts to increase, becomes the bottleneck

Azure Load Balancer

Web Tier

Business Tier

Data Tier

Page 4: More Cache for Less Cash (DevLink 2014)

5

Why Cache?

Improve application performance

Reduce load on DB

Azure Load Balancer

Web Tier

Business Tier

Data Tier

Cache Cache Tier

Page 5: More Cache for Less Cash (DevLink 2014)

What is Azure Cache Service?

6

A distributed, in-memory, flexible cache for all data types that can be used to speed up Azure applications and reduce database load.Basically, cache helps your

app become faster.

Windows Azure Cache

Page 6: More Cache for Less Cash (DevLink 2014)

A Cache Story

Shared Cache

• Cloud Services

• Shared – quotas

• Lacked feature parity

• Multiple size options

• Expensive• Performance challenged• Throttling

• Deprecated August 2014

In-Role Cache

• Cloud Services

• Co-located (free)

• Dedicated ($$)

• Feature parity

• Good performance

• Not multi-tenant

Cache Service

• Cloud Services, Web Sites, or VMs

• Feature parity

• Managed infrastructure

• Price/capacity tiers

• Good performance (1ms read)

7

Page 7: More Cache for Less Cash (DevLink 2014)

A Cache Story

Shared Cache

• Cloud Services

• Shared – quotas

• Lacked feature parity

• Multiple size options

• Expensive• Performance challenged• Throttling

• Deprecated August 2014

In-Role Cache

• Cloud Services

• Co-located (free)

• Dedicated ($$)

• Feature parity

• Good performance

• Not multi-tenant

Cache Service

• Cloud Services, Web Sites, or VMs

• Feature parity

• Managed infrastructure

• Price/capacity tiers

• Good performance (1ms read)

8

Page 8: More Cache for Less Cash (DevLink 2014)

A Cache Story

Shared Cache

• Cloud Services

• Shared – quotas

• Lacked feature parity

• Multiple size options

• Expensive• Performance challenged• Throttling

• Deprecated August 2014

In-Role Cache

• Cloud Services

• Co-located (free)

• Dedicated ($$)

• Feature parity

• Good performance

• Not multi-tenant

Cache Service

• Cloud Services, Web Sites, or VMs

• Feature parity

• Managed infrastructure

• Price/capacity tiers

• Good performance (1ms read)

9

Page 9: More Cache for Less Cash (DevLink 2014)

A Cache Story

Shared Cache

• Cloud Services

• Shared – quotas

• Lacked feature parity

• Multiple size options

• Expensive• Performance

challenged• Throttling

• Deprecated August 2014

In-Role Cache

• Cloud Services

• Co-located (free)

• Dedicated ($$)

• Feature parity

• Good performance

• Not multi-tenant

Cache Service

• Cloud Services, Web Sites, or VMs

• Feature parity

• Managed infrastructure

• Price/capacity tiers

• Good performance (1ms read)

Redis Cache

• TBD

• TBD

• TBD

• TBD

10

http://aka.ms/MigrateFromSharedCaching

Page 10: More Cache for Less Cash (DevLink 2014)

In-Role Cache (Co-located)

11

Web Roles

300MB 300MB 300MB 300MB

1.2GB Distributed Cache

Source: Windows Azure Training Kit

Page 11: More Cache for Less Cash (DevLink 2014)

In-Role Cache (Dedicated)

12

24GB Distributed Cache

Web Roles

12GB CacheWorker Role

12GB CacheWorker Role

2Source: Windows Azure Training Kit

Page 12: More Cache for Less Cash (DevLink 2014)

In-Role Cache (Dedicated)

13

24GB Distributed Cache

Web Roles

12GB CacheWorker Role

12GB CacheWorker Role

4

12GB CacheWorker Role

12GB CacheWorker Role

48GB Distributed Cache

Source: Windows Azure Training Kit

Page 13: More Cache for Less Cash (DevLink 2014)

14

In-Role Cache

• Based on the AppFabric Cache engine• Released w/ Oct. 2012 release of Azure SDK 1.8• Cache part of your Cloud Service application• No quotas or throttling• Isolation, flexibility, and control• High performance

• Features: named cache, regions, tagging, HA, local, notifications

• Pro: You manage as part of your application• Con: You manage it; only available to Cloud Service roles

in same deployment

Page 14: More Cache for Less Cash (DevLink 2014)

Create and Configure In-Role Cache

Configure a Role in the Cloud Service to host the cache

15

Page 15: More Cache for Less Cash (DevLink 2014)

Configure the Cache Clients

• Use NuGet to configure the cache clients• Microsoft.WindowsAzure.Caching• Settings placed in web.config or app.config• Modify to point to the cache server role

16

<dataCacheClients> <dataCacheClient name="default"> <!--To use the in-role flavor of Windows Azure Cache, set identifier to be the cache cluster role name --> <!--To use the Windows Azure Cache Service, set identifier to be the endpoint of the cache cluster --> <autoDiscover isEnabled="true" identifier="MyScores.Web" /> <!--<localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />--> </dataCacheClient></dataCacheClients>

Role Name

Page 16: More Cache for Less Cash (DevLink 2014)

17

DEMO TIME!!!

Page 17: More Cache for Less Cash (DevLink 2014)

18

Recap

1. Select “Enable Caching” in Azure role configuration

2. Install NuGet package (Microsoft.WindowsAzure.Caching)

3. Set role name in web.config4. Get/Set data

Page 18: More Cache for Less Cash (DevLink 2014)

Monitoring the Cache

Diagnostic Level

Data Collected

0 Critical/catastrophic server logs only

1 Data to help in assessing usage patterns, cache health, and potential errors. Default.

2 Fine grain data for all requests and important system information

3 Diagnostic data with more verboseness and system information

4 Highest verbosity logs for all requests and system information

19

Provides a single setting for cache servers and clientsConfigures levels for logs, traces, performance counters & crash dumps

Full details at http://aka.ms/CacheDiagnostics

Page 19: More Cache for Less Cash (DevLink 2014)

20

Monitoring the Cache

• Set cache diagnostic level in configuration or portal

• Level (1-4) controls verbosity, perf counters, & crash dumps.

• Start at 1 and increase as needed<Role name="WorkerRole1"> <Instances count="1" /> <ConfigurationSettings> <!– Cache Server --> <Setting name="Microsoft.WindowsAzure.Plugins.Caching.DiagnosticLevel“ value="1" />

<!– Cache Client--> <Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" value="1" /> </ConfigurationSettings></Role> Full details at http://mcollier.net/AzureCacheDiag

Page 20: More Cache for Less Cash (DevLink 2014)

Monitoring the Cache

21

public class WebRole : RoleEntryPoint{    public override bool OnStart()    {             

// Enable cache diagnostics       DiagnosticMonitorConfiguration dmConfig =              DiagnosticMonitor.GetDefaultInitialConfiguration();

      // Configure collection of cache diagnostic data.       CacheDiagnostics.ConfigureDiagnostics(dmConfig);

      DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString",  dmConfig);

      return base.OnStart();     }}

Page 21: More Cache for Less Cash (DevLink 2014)

Considerations

• Unable to create DataCache in RoleEntryPoint

• Max object size is 8MB post serialized

• Default serializer is NetDataContractSerializer

• Cost only for role instances

• Only accessible from within same Cloud Service• Deployment will impact the cache (instances recycle)

22

Page 22: More Cache for Less Cash (DevLink 2014)

23

What’s the Azure Managed Cache Service?

Shared Azure Website Stamp

App2

App1 VM VM

VM

IaaS VMs

Cloud Services

Azure Managed Cache Service

1. SLA backed2. Microsoft Managed3. Scalable &

Resilient

Page 23: More Cache for Less Cash (DevLink 2014)

24

Create and Configure the Cache Service

• Based on AppFabric Cache engine

• Create via PowerShell only • Manage in Azure management portal

• Choose an offering• Basic (128MB to 1GB in 128MB units, 1 named cache)• Standard (1GB to 10GB in 1GB units, notifications, and 10 named

caches)• Premium (5GB to 150GB in 5GB units, notifications, HA, and 10

named caches)

• Locate in same region as client for best perf and cost

Page 24: More Cache for Less Cash (DevLink 2014)

Create and Configure the Cache Service

25

PS C:\> New-AzureManagedCache -Name devlinkcache ` -Location "East US" `

-Sku Basic ` -Memory 128MB

Page 25: More Cache for Less Cash (DevLink 2014)

26

DEMO TIME!!!

Page 26: More Cache for Less Cash (DevLink 2014)

27

Recap

1. Create Managed Cache via PowerShell2. Install NuGet package

(Microsoft.WindowsAzure.Caching)3. Set cache service endpoint & key in

web.config4. Get/Set data

Page 27: More Cache for Less Cash (DevLink 2014)

28

Monitoring the Cache

Page 28: More Cache for Less Cash (DevLink 2014)

29

Scaling the Cache

Dynamically scale without loosing any existing data

Page 29: More Cache for Less Cash (DevLink 2014)

30

High Availability

Client Primary

Secondary

Read / Write

Write

Premium only

Doubles required memory

Increased latency & decreased throughput

Page 30: More Cache for Less Cash (DevLink 2014)

31

Pricing Details

Basic Standard Premium

Price Per Unit(Preview)

$25/month(prorated hourly)

$100/month(prorated hourly)

$400/month(prorated hourly)

Cache Size 128 MB 1 GB 5 GB

Scale Up to 8 units Up to 10 units Up to 30 units

Named Caches 1 10 10

High Availability Notifications

See http://mcollier.net/AzureCachePricing

Page 31: More Cache for Less Cash (DevLink 2014)

Benefits of the Azure Managed Cache Service• Use from any app types (VM, Web Site, Mobile Service, Cloud

Service)• Each instance deployed within dedicated VMs (fast, predictable

performance)• No quotas or throttling• Store up to 150GB per cache instance• Avg. retrieval time of 1ms. Insert in about 1.2ms• Highly available / distributed across multiple servers• Managed service – focus on apps not infrastructure• Same .NET cache API used with in-role cache for Cloud

Services• Support for ASP.NET Session State and Page Output Caching• Unique cache service instance for each app, or share across

apps32

Page 32: More Cache for Less Cash (DevLink 2014)

33

Azure Redis Cache (Preview)

• Secure, dedicated Redis cache• Hosting and monitoring by Microsoft

• 250MB – 26GB (Preview)

• Tiers• Basic – single node; dev/test and non-critical

workloads• Standard – provides master/slave replication

Page 33: More Cache for Less Cash (DevLink 2014)

Azure Redis Cache (Preview)

34

Page 34: More Cache for Less Cash (DevLink 2014)

35

Monitoring and Alerts

• Set metrics and timeframe to monitor

• Pin to dashboard

• Alert when threshold reached

Page 35: More Cache for Less Cash (DevLink 2014)

36

DEMO TIME!!!

Page 36: More Cache for Less Cash (DevLink 2014)

37

Recap

1. Create Redis Cache via portal2. Add Redis C# client (e.g.

StackExchange.Redis)3. Obtain Redis endpoint and password from

portal4. Determine formatter for .NET objects5. Get/Set data

Page 37: More Cache for Less Cash (DevLink 2014)

38

Common Architecture

Web Roles

Storage Table

Windows Azure Cache

3. W

rite

1. R

ead

2. Read

Page 38: More Cache for Less Cash (DevLink 2014)

39

Common Architecture

Windows Azure Load Balancer

Web Roles Worker Roles

SQL Database (Azure)

Azure Cache

Read

Read

Writ

e

Preload the cache

Carefully choose expiration and eviction settings

Page 39: More Cache for Less Cash (DevLink 2014)

40

Common Architecture

Azure Load Balancer Web Roles Storage Queue Worker Roles

Storage Table SQL Database (Azure)

Azure Cache

Write Read

Wri

te

Read

Write

Wri

te

Page 40: More Cache for Less Cash (DevLink 2014)

Cloud Service Fundamentals - Caching

• Factory implementation• Custom BinarySerializer

class• protobuf-net• Fast and small

41

http://mcollier.net/AzureCSF

Page 41: More Cache for Less Cash (DevLink 2014)

What Cache?

42

• Azure Shared Cache – out of service on September 1, 2014

New Development

Need GA and SLA

Page 42: More Cache for Less Cash (DevLink 2014)

43

Where to Cache?

Mix cache solutions for price / manageability / features

Azure Load Balancer Web Roles

Azure Cache

Read

• Data shared by other services/apps

• General application data

In-role cache

• Session / Page Output Cache

• FREE!

Page 43: More Cache for Less Cash (DevLink 2014)

Summary

• In-Role Cache• Cloud Services only• Co-located (free) or Dedicated ($$$)• Isolated cache-related workload

• Cache Service• Microsoft managed service, dedicated tenant, SLA backed• Cloud Services, Web Sites, and VMs• Full parity with in-role cache (SDK)

• Redis Cache• Microsoft managed Redis Cache• Master/Slave replication in Standard tier• Normal Redis features/functionality

44

Page 44: More Cache for Less Cash (DevLink 2014)

More Resources

• Azure Cache Options Overview• http://msdn.microsoft.com/en-us/library/azure/gg278356.aspx

• Which Azure Cache Offering is right for me?• http://msdn.microsoft.com/en-us/library/azure/dn766201.aspx

• Cloud Service Fundamentals – Caching Basics• http://azure.microsoft.com/blog/2013/10/03/cloud-service-fundamentals-caching-basics/

• Capacity Planning Spreadsheet (In-Role Cache)• http://msdn.microsoft.com/en-us/library/hh914129

• Lap around Azure Redis Cache• http://azure.microsoft.com/blog/2014/06/04/lap-around-azure-redis-cache-preview/

45

Page 45: More Cache for Less Cash (DevLink 2014)

Q &

A

Ask your questions