Maximizing Azure SQL Database performance with a globally distributed Redis write-behind cache

Abhiman Tiwari
Microsoft Azure
Published in
4 min readNov 21, 2022

Azure SQL Database is a fully managed platform as a service (PaaS) relational database service. With Azure SQL Database, you can create a highly available and high-performance data storage layer for the applications and solutions in Azure. SQL Database can be the right choice for a variety of modern cloud applications because it enables you to process both relational data and non-relational structures, such as graphs, JSON, spatial, and XML. You can also take advantage of advanced query processing features, such as high-performance in-memory technologies and intelligent query processing.

Database caching is a very well-known concept, when applications want to boost their performance further. Services like Azure Cache for Redis complement database services like Azure SQL DB, by allowing your data layer to scale. Using some standard caching techniques, you can store and distribute the most common application queries and improve the performance and scale of your application. Not only does caching help with improving latency, but it also reduces the load on the database, lowering the need to overprovision and thereby saving costs.

Distributed caching is a technique that allows the cache to scale across multiple nodes, allowing it to grow both in terms of size and throughput. Globally distributed cache is a network of geographically separated processing nodes, each having access to a common replicated database such that all nodes can participate in a common application ensuring local low latency with each region being able to run in isolation.

In this blog we will use a scalable, real-time leaderboard application to see how you can use Azure Cache for Redis Enterprise as a write-behind cache, in combination with Azure SQL Database to speed up your data tier performance. We will also see how you can use the active geo-replication (Active-Active) feature of Redis Enterprise to globally distribute your application while enjoying the low, local Redis latencies.

Architecture of the leaderboard application

Here is how this whole application is configured. We are using a backend Azure SQL Database to store the leaderboard data. We have deployed one Azure SQL DB instance. Since, the leaderboard data is frequently accessed (mostly reads), we cached it in Azure Cache for Redis — Enterprise instance to improve application latencies and avoid accessing the backend storage layer all the time.

This is market cap data for companies, which can be accessed globally, we distributed our cache in 2 regions — US East and US West. Note that you can distribute the cache in up to 5 regions. But, for this sample we have distributed in 2 regions only. Active geo-replication creates multi-primary instances, that is, the application can read / write to any of these instances. The application can be configured to interact with the closest cache instance and therefore, enjoys local read / write latencies. The Redis software takes care of maintaining the consistency of data and replicating the data across all the instances.

Architecture

Installation and Pre-requisites

You can read the pre-requisites and installation steps for this sample application on our github repo.

Here is an ARM template to deploy the entire solution to Azure.

Summary

Caching is a useful technique when it comes to reducing application latencies and saving costs, by lowering the need to overprovision the database layer for better scale. In this example, we saw how you can configure a globally distributed write-behind cache with Azure Cache for Redis Enterprise for your Azure SQL Database. This not only helps improve application latencies, but it also helps you make your underlying database globally available. The application always enjoys local read/write latencies, by reading/writing to the closest cache instance, while also taking advantage of Azure SQL database’s security, performance, high availability, and other great capabilities.

We have also extended the example to show how you can use Redis as a read-through cache. If you have a read heavy application, your application may benefit from this caching pattern.

As a next step, check how you can boost your database performance by up to 800% using Azure Cache for Redis and some other caching architectures.

--

--