1 / 48

Configuration as a Service and Redis Cache

Configuration as a Service and Redis Cache. Cache configuration and deployment. Who we are. Azure Cloud Studios. (A couple of Azure guys). Tonight’s Presenters. Robert Dytmire & Ed Hunkin. Agenda. Caching in Azure.

kevinrivera
Télécharger la présentation

Configuration as a Service and Redis Cache

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Configuration as a Service and Redis Cache Cache configuration and deployment

  2. Who we are Azure Cloud Studios (A couple of Azure guys) Tonight’s Presenters Robert Dytmire & Ed Hunkin

  3. Agenda Caching in Azure Who should use caching? What types of caching are available to us? How do you implement a cache? What are some considerations when using caching? Configuration as a Service Implement a Cache - Walkthrough Why we think data beats config files for deploying, managing and scaling your services. We’ll be discussing how we’re doing this and what enhancements we’re planning. Walk through the steps to impalement a Redis Cache. Configuring the cache in AzStudio. Using the cache in a Redis Cache tester. Some tricks to pop and push more than the Azure stated maximums. Life cycle of a cache item. AzStudio Q&A A very quick tour of our Azure enterprise suite. We’ll be using AzStudio plugins to demonstrate configuration and testing of a cache. Open the floor to questions.

  4. Configuration as a Service

  5. Configuration as a Service Configuration as a Service Replacing various configuration files with data services. Role asks for configuration data via a series of service calls. Minimal configuration in the project code.

  6. Configuration as a Service Configuration as a Service Replacing various configuration files with data services. Role asks for configuration data via a series of service calls. Minimal configuration in the project code. Easier Configuration changes are stored and managed via a centralized data store. Configuration changes do not require re-deployment and in many cases do not require role recycling.

  7. Configuration as a Service More Secure The configuration tasks can be delegated to a completely different team. Configuration changes in one environment can be delegated to the coder (Dev) but QA and Production can manage their own implementations. Configuration can be segmented by major function. Configuration as a Service Replacing various configuration files with data services. Role asks for configuration data via a series of service calls. Minimal configuration in the project code. Easier Configuration changes are stored and managed via a centralized data store. Configuration changes do not require re-deployment and in many cases do not require role recycling.

  8. Configuration as a Service More Secure The configuration tasks can be delegated to a completely different team. Configuration changes in one environment can be delegated to the coder (Dev) but QA and Production can manage their own implementations. Configuration can be segmented by major function. Configuration as a Service Better consistency Replacing various configuration files with data services. Role asks for configuration data via a series of service calls. Minimal configuration in the project code. Ever wondered if your XML was well-formed? Missing an attribute? Is the section something that is supposed to be in consistent and well understood? A database-driven interface eliminates a lot of confusion. Database tables can enforce data consistency, security, and redundancy. Easier Configuration changes are stored and managed via a centralized data store. Configuration changes do not require re-deployment and in many cases do not require role recycling.

  9. Configuration as a Service More Secure The configuration tasks can be delegated to a completely different team. Configuration changes in one environment can be delegated to the coder (Dev) but QA and Production can manage their own implementations. Configuration can be segmented by major function. Configuration as a Service Better consistency Replacing various configuration files with data services. Role asks for configuration data via a series of service calls. Minimal configuration in the project code. Ever wondered if your XML was well-formed? Missing an attribute? Is the section something that is supposed to be in consistent and well understood? A database-driven interface eliminates a lot of confusion. Database tables can enforce data consistency, security, and redundancy. Easier Scales Well Configuration changes are stored and managed via a centralized data store. Configuration changes do not require re-deployment and in many cases do not require role recycling. Once you have your configuration schema, it’s very easy to scale for small, medium and large projects. Your pattern is the same in all environments and all scales. Dev works and deploys the same as production.

  10. Overview Configuration Layer Configuration Tool (AzStudio) Configuration Admins Database Store API SQL Connection Service Call (REST / JSON) Modules Cache Data Queue SMTP Happy Coders

  11. Role / CaaS Process Boot – What am I? 01 Upon booting, the role needs to know what it actually is

  12. Role / CaaS Process Boot – What am I? Where am I? 02 01 Upon booting, the role needs to know what it actually is The role now needs to know what environment it is in

  13. Role / CaaS Process Boot – What am I? Where am I? Download Modules 02 03 01 Upon booting, the role needs to know what it actually is The role now needs to know what environment it is in The role needs to download it’s modules and start them. Composition / Dependency injection

  14. Role / CaaS Process Boot – What am I? Where am I? Download Modules Modules Initialize 02 03 01 Upon booting, the role needs to know what it actually is The role now needs to know what environment it is in The role needs to download it’s modules and start them. Composition / Dependency injection Each module contacts the configuration service it needs for information 04

  15. Role / CaaS Process Boot – What am I? Where am I? Download Modules Modules Initialize System Ready 02 03 01 Upon booting, the role needs to know what it actually is The role now needs to know what environment it is in The role needs to download it’s modules and start them. Composition / Dependency injection Each module contacts the configuration service it needs for information All modules running. Role is now fully functional 05 04

  16. Why was all that Important? Tonight’s Demo Our Redis cache demo uses AzStudio, which is our CaaS tool / product. We wanted you to understand the apparent non-standard configuration steps.

  17. Why was all that Important? Tonight’s Demo Our Redis cache demo uses AzStudio, which is our CaaS tool / product. We wanted you to understand the apparent non-standard configuration steps. Going Forward If permitted, we’d like to demonstrate more CaaS and code automation techniques in future presentations. Having this information will form a good foundation for more advanced techniques.

  18. Why was all that Important? General Trends Our team is convinced that CaaS will be an emerging trend in IaaS environments. It’s a natural progression of the toolsets as they respond to this new paradigm. Tonight’s Demo Our Redis cache demo uses AzStudio, which is our CaaS tool / product. We wanted you to understand the apparent non-standard configuration steps. Going Forward If permitted, we’d like to demonstrate more CaaS and code automation techniques in future presentations. Having this information will form a good foundation for more advanced techniques.

  19. Caching in Azure

  20. When you need Caching Speed You do not want the overhead of querying an SQL server or other storage container. This is especially true when data structure you’re referencing is complex, built from multiple queries or is small and easy to cache in memory. In-memory caching is very good for small sets of frequently referenced data that do not change very often.

  21. When you need Caching Speed You do not want the overhead of querying an SQL server or other storage container. This is especially true when data structure you’re referencing is complex, built from multiple queries or is small and easy to cache in memory. In-memory caching is very good for small sets of frequently referenced data that do not change very often. Reduce Load Reduce DTU’s! You want your SQL server to be the accessed only when it is absolutely necessary to read and write persistent data. Caching reduces redundant SQL work. Use caching to reduce loads on these systems.

  22. When you need Caching Reduce Costs It costs money to access SQL and other storage resources. Some resources, such as blobs and queues have absolute upper limits on instance access per minute. Speed You do not want the overhead of querying an SQL server or other storage container. This is especially true when data structure you’re referencing is complex, built from multiple queries or is small and easy to cache in memory. In-memory caching is very good for small sets of frequently referenced data that do not change very often. Reduce Load Reduce DTU’s! You want your SQL server to be the accessed only when it is absolutely necessary to read and write persistent data. Caching reduces redundant SQL work. Use caching to reduce loads on these systems.

  23. When you need Caching Reduce Costs Persistent Shared Data It costs money to access SQL and other storage resources. Some resources, such as blobs and queues have absolute upper limits on instance access per minute. When you want multiple roles to access the same data quickly and cheaply. For example: Complex session state data for your logged in users. Any data that is frequently accesses but produces significant query load is a candidate. Speed You do not want the overhead of querying an SQL server or other storage container. This is especially true when data structure you’re referencing is complex, built from multiple queries or is small and easy to cache in memory. In-memory caching is very good for small sets of frequently referenced data that do not change very often. Reduce Load Reduce DTU’s! You want your SQL server to be the accessed only when it is absolutely necessary to read and write persistent data. Caching reduces redundant SQL work. Use caching to reduce loads on these systems.

  24. Caching Technologies Available in Azure Local Cache In-Role Cache Managed Cache Service Redis • Data Center • Lifetime Management • Microsoft Recommended • Stable • Instance Only • No Lifetime Management • Concurrency considerations • Lightweight • Fastest • Role Shared • No Lifetime Management • Difficult to configure and manage • Inconsistent operation • Depreciated • Data Center • Lifetime Management • Inconsistent operation • Depreciated. You cannot create this service going forward.

  25. Have a Backup Plan Database Cache Use a simple SQL table to store a copy of your JSON data. Table Storage Use table storage for fast cache backup. We like this solution better than SQL. Not as flexible. Blob Storage If you use a consistent keying strategy then store the JSON as a blob. Re-Hydrate Slowest but necessary. Your code must know how to re-hydrate its state from original data.

  26. AzStudio

  27. AzStudio Unified Azure Configuration One stop application that allows us to manage all aspects of configuration. Any Azure / C# module can be configured for every environment.

  28. AzStudio Unified Azure Configuration One stop application that allows us to manage all aspects of configuration. Any Azure / C# module can be configured for every environment. Unified Application Management Any application we deploy to Azure can be managed via this toolset. Plugins allow us to extend the toolset for each client as necessary.

  29. AzStudio Code Generation Toolset We’ve taken our code blowers and turned them into Azure-Aware plugins. Single point of code creation and template management. Unified Azure Configuration One stop application that allows us to manage all aspects of configuration. Any Azure / C# module can be configured for every environment. Unified Application Management Any application we deploy to Azure can be managed via this toolset. Plugins allow us to extend the toolset for each client as necessary.

  30. AzStudio Code Generation Toolset Super Flexible Plugin Architecture We’ve taken our code blowers and turned them into Azure-Aware plugins. Single point of code creation and template management. Host app follows our best practices in Azure and allows plugins to quickly leverage this foundation. Unified Azure Configuration One stop application that allows us to manage all aspects of configuration. Any Azure / C# module can be configured for every environment. Unified Application Management Any application we deploy to Azure can be managed via this toolset. Plugins allow us to extend the toolset for each client as necessary.

  31. AzStudio

  32. Setting Up Redis Cache in Azure

  33. Create your Cache in Azure Note: This is the new portal. Ensure you are in the new “preview” portal

  34. Select your Pricing Tier Watch Expenses! Examine each offering, as it’s easy to select a caching size that’s much more than you need. We find the B1 service works pretty well for most businesses. Also keep in mind you need THREE of these caches (Dev, QA and Production) but your Dev and QA caches should be B0 tier in almost all cases. Scale up your cache before you federate. Carefully consider if you need replication or an SLA, as those cost more. Using the failsafe methods mentioned earlier are often more cost effective.

  35. Create the Cache Set your Resource Group and Location Select Create Wait for Deployment This let’s Azure know where you want the physical instance located. A tile will appear on your portal that looks like this: The portal will inform you when your cache is ready. This takes a bit of time.

  36. Take Note of Configuration Configuration Strategy Information you Need You’ll want to have your configuration strategy planned out at this point. For this demonstration, we’re going to use our CaaS strategy. There are many online tutorials on how to use configuration files and slightly different C# to accomplish the same tasks. Note the Hostname and access key. We find using secondary key to be the best practice.

  37. Create a Configuration String Configuration String format: Demo’s connection string would look like this: [hostname],ssl=true,password=[accesskey] presentation.redis.cache.windows.net,ssl=true,password=Mn4n/YsspnuKBSpK4VG/DXAa3TOuLlVP1mcmiADzN3B=

  38. Adding Redis Cache to your Project

  39. Install the Packages Install Json.NET if you plan to serialize objects (we do) and StackExchange.Redis, the Redis cache C# library.

  40. Create a Caching Class Create a Project and Class In your C# code, add the StackExchange.Redis and Newtonsfot.Json references.

  41. AzStudio’s Caching Class Static Class We use a static class that manages different cache instances. The cache instances each maintain a persistent cache connection and manage writing and reading from the Redis Instance. The ConnectionMultiplexer is the key class. Connect uses your connection string and produces a connection object. You should persist the connection object as it is meant to have a long life-cycle (it’s a heavy object to create).

  42. Create Set Method Now we have a connection. We can leverage the connection to write our own Get and Set methods. We like to use JSON encoders to serialize our object in and out of the cache. This seems to work for us fairly well. You can also serialize into a byte stream

  43. Create Get Method Get is pretty straightforward. We attempt to read the cache. If we find the value in the cache we de-serialize it into <T>. If the key is null or missing…or we encounter an exception de-serializing then it returns default(T).

  44. Quick Cache Facts

  45. Quick Redis Cache Facts Maximum Key Size Maximum Value Size Concurrent Connections? Lifespan You’ll want to keep your key size as small as possible. The Key and Value size count together A hard limit of 512 MB on key size. Max value is 512 MB for a serialized string. Keep in mind the key size counts towards this limit. But really, what are you doing caching a 512MB string?! Depends on cache size. Keep in mind that a 250MB cache runs on a A-0 size machine. The larger the cache size the larger the dedicated box to host the cache will be, so load test your app. The absolute limit is 10K. Note: We found that a 1GB cache size was sufficient to handle most of our smaller to mid-sized client’s modest caching needs. Set the MAXMEM policy in your cache settings, all settings. The default is volatile LFU. That is old values will be deleted after several minutes or if the cache needs to make room, the Least Frequently Used item will be deleted.

  46. Live Demo

  47. Summary CaaS Caching is Easy & Strategy is Less so Going forward, we see CaaS logically complementing IaaS. Consistent, data-checked and environment aware configuration tools will become more consistent and powerful. We’d like to present on this subject in more depth at a future date. Azure makes setting up and accessing a cache very easy. How you implement caching in your project is less so. Configuration can play a big role. Peak load, moving between environments simply, and coming up with a consistent fallback strategy are all import considerations.

  48. What Next? Takeaway Challenge We will now pass out your take-away. Use this as a quick guide to help you with our challenge. We challenge you to write your own Redis Cache test project this week. Place load on the system. See if you can break the I/O. Test the limits of different sizes. See what kind of performance you get. Report back on the Azure Meet-Up Group message board. Doing this yourself will educate you more than anything that I can stand here and yammer on about.

More Related