Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

More Cache for Less Cash (DevLink 2014)

4,285 views

Published on

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

Published in: Technology
  • Be the first to comment

More Cache for Less Cash (DevLink 2014)

  1. 1. More Cache for Less Cash Michael S. Collier @MichaelCollier DevLink 2014 – August 27, 2014
  2. 2. Today’s Agenda • Why Cache? • Cache Options in Azure • Demos • Monitoring and Scaling • Pricing and Features 3
  3. 3. Why Cache? 4 Azure Load Balancer Web Tier Business Tier Data Tier
  4. 4. Why Cache? 5 Azure Load Balancer Web Tier Business Tier Cache Cache Tier Data Tier
  5. 5. What is Azure Cache Service? 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 6 become faster. Windows Azure Cache
  6. 6. 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
  7. 7. 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
  8. 8. 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
  9. 9. 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 http://aka.ms/MigrateFromSharedCaching 10
  10. 10. In-Role Cache (Co-located) 11 Source: Windows Azure Training Kit
  11. 11. In-Role Cache (Dedicated) 12 Source: Windows Azure Training Kit
  12. 12. In-Role Cache (Dedicated) 13 Source: Windows Azure Training Kit
  13. 13. 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 14
  14. 14. Create and Configure In-Role Cache Configure a Role in the Cloud Service to host the cache 15
  15. 15. 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 <dataCacheClients> <dataCacheClient name="default"> 16 <!--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
  16. 16. 17 DEMO TIME!!!
  17. 17. Recap 1. Select “Enable Caching” in Azure role configuration 2. Install NuGet package (Microsoft.WindowsAzure.Caching) 3. Set role name in web.config 4. Get/Set data 18
  18. 18. 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 Provides a single setting for cache servers and clients Configures levels for logs, traces, performance counters & crash dumps Full details at http://aka.ms/CacheDiagnostics 19
  19. 19. 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"> 20 <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
  20. 20. Monitoring the Cache public class WebRole : RoleEntryPoint { public override bool OnStart() { 21 // 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(); } }
  21. 21. 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
  22. 22. What’s the Azure Managed Cache Service? 23 App1 VM VM App2 Shared Azure Website Stamp VM IaaS VMs Cloud Services Azure Managed Cache Service 1. SLA backed 2. Microsoft Managed 3. Scalable & Resilient
  23. 23. 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 24
  24. 24. Create and Configure the Cache Service PS C:> New-AzureManagedCache -Name devlinkcache ` 25 -Location "East US" ` -Sku Basic ` -Memory 128MB
  25. 25. 26 DEMO TIME!!!
  26. 26. Recap 1. Create Managed Cache via PowerShell 2. Install NuGet package (Microsoft.WindowsAzure.Caching) 3. Set cache service endpoint & key in web.config 4. Get/Set data 27
  27. 27. Monitoring the Cache 28
  28. 28. Scaling the Cache 29 Dynamically scale without loosing any existing data
  29. 29. High Availability 30 Client Primary Secondary Read / Write Write Premium only Doubles required memory Increased latency & decreased throughput
  30. 30. Pricing Details 31 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
  31. 31. 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 apps 32
  32. 32. 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 33
  33. 33. Azure Redis Cache (Preview) 34
  34. 34. Monitoring and Alerts • Set metrics and timeframe to monitor • Pin to dashboard • Alert when threshold reached 35
  35. 35. 36 DEMO TIME!!!
  36. 36. Recap 1. Create Redis Cache via portal 2. Add Redis C# client (e.g. StackExchange.Redis) 3. Obtain Redis endpoint and password from portal 4. Determine formatter for .NET objects 5. Get/Set data 37
  37. 37. Common Architecture 38 Web Roles Storage Table 3. Write 1. Read Windows Azure Cache 2. Read
  38. 38. Common Architecture 39 Windows Azure Load Balancer Web Roles Worker Roles SQL Database (Azure) Read Azure Cache Read Preload the cache Carefully choose expiration and eviction settings
  39. 39. Common Architecture 40 Azure Load Balancer Web Roles Storage Queue Worker Roles Storage Table SQL Database (Azure) Azure Cache Write Read Write Read Write
  40. 40. Cloud Service Fundamentals - Caching • Factory implementation • Custom BinarySerializer class • protobuf-net • Fast and small http://mcollier.net/AzureCSF 41
  41. 41. What Cache? • Azure Shared Cache – out of service on September 1, 2014 42 New Development Need GA and SLA
  42. 42. Where to Cache? 43 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!
  43. 43. 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
  44. 44. 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
  45. 45. Ask your questions

×