Overview Of Azure Redis Cache

Introduction

 
In this article, we are going to learn various caching techniques and how to implement them in the Azure cloud. Let us first understand the need for caching with an example scenario.
 
Suppose, we have a web application that is hosted on the server. Now, when the users are trying to use it,  they are sending the request to the app server and the request calls the database to get the data. When a user reads and writes the data from and to the database, most of the time, a user interacts with the database which takes time to complete the operation because when we are reading the data from a database, the application has to execute the queries to get the desired information. Similar things happen when we write data to the database and the data may need to be updated in multiple tables. Also, the indexes may need to get updated properly.
 
Azure Redis Cache
 
Normally, data is stored in local disks in the database server and when a user requests the data, the same needs to be populated from the disk and should be available in memory. Here comes the role of caching. Caching is the use of virtual memory. When we implement caching, it will act as a database and store the data on a local virtual space that is always available in in-memory, so the data retrieval would be very fast. The cached data is stored in a key-value pair so the users or the application don’t have to execute complex queries to get the data.
 

Redis Cache Features

  • Increase Application performance
  • Increase availability (Geo-Replication)
  • Provides in-memory data
  • Fully managed by Azure and based on the open source
  • Data Backups
  • Stores data in:

    • Strings (max 521 mb)
    • Hashes (unordered)
    • Lists (ordered by sequence)
    • Sets (only unique values)

Keys to remember

  • Store simple data that is needed often
  • Set the right policies to delete/update when is required
  • Pre-populate the cache data

Implement Azure Redis Cache in the portal

 
Step 1
 
Log in to the Azure portal by using your credentials and go to the marketplace. There, search for Azure Redis Cache.
  • DNS Name: enter the unique name
  • Subscription: choose your subscription
  • Resource group: Create new /choose existing one from the dropdown value
  • Location: choose your location
  • Pricing tier: In Azure, there are 3 types of tiers available, i.e., Basic, Standard, and Premium. For this demo, I am using the basic tier

    • Basic tier comes with shared service
    • SSL supports by default, but we can change later if we don’t want.
    • Normally used for the development phase

  • Standard and Premium

    • Comes with 99.9% SLA
    • Dedicated service
    • Redis cluster
    • Data Persistence
    • Virtual network
Step 2
 
Once the deployment is done, open the Redis Cache window; by default, the SSL port is disabled.
 
Schedule updates feature allows us to configure the time frame in which Azure should provide the update. This allows planning the maintenance so that the availability is optimized.
 
Import and Export Data allows us to export the data to another cache or pre-populate our cache. If the cache fails for any reason, then the cache data will be rebooted from there.
 
Access Keys - We will be getting the connecting string in order to connect the Azure Redis Cache to our web application or other apps.
 
Azure Redis Cache
 
Azure Redis Cache
 
Azure Redis Cache
 

Cache Invalidation

 
So, we have a cache object that will store the cookie data. In some scenarios, we may need to update the cached information frequently so we need to remove the existing cached information and update the same with new values. When a user requests the data, the application gets the data from the database if cache data is not available. We can invalidate a cache in many ways. The most common approach is to delete the cache in the application side or set the absolute expiration.
 

Summary

 
In this article, we have learned how to create Azure Redis Cache on the Azure portal. Also, we looked into the feature and options available for Redis Cache in the Azure portal.


Similar Articles