Page 40 - MSDN Magazine, July 2017
P. 40

MACHINE LEARNING
Scale Applications with Microsoft Azure Redis Cache and
Machine Learning
Stefano Tempesta
In a multi-tier application, bottlenecks can occur at any of the connection points between two tiers: at business logic and data access layers, client and service layers, presentation and storage layers, and so on. Large-scale applications can implement various levels of caching of information for improving performance and increasing scalability. Caching can be configured in memory or on some more permanent form of storage, in different sizes, and in diverse geographic locations. The open source Redis engine, as implemented in Azure, lets you intuitively configure and manage all these aspects, and use a variety of programming languages.
This article presents design best practices and code examples for implementing the Azure Redis Cache and tuning the per- formance of ASP.NET MVC applications, optimizing cache hit ratio and reducing “miss rate” with smart algorithms processed by Azure Machine Learning.
Azure Redis Cache
Let’s start by saying that Redis is not a Microsoft product. Redis is an open source project freely available for download from the Web site redis.io. Everyone can download the cache engine and install it on their servers. But Microsoft offers this, and much more, as a service in Azure. You can create a new Redis Cache instance in Azure in a few minutes and be ready to connect to it from your application.
What makes Redis different from other caching frameworks is its support for specialized data types, besides the typical key-value string pair, common in other cache engine implementations. You can run atomic operations on these types, such as appending to a string, incrementing the value in a hash, pushing an element to a list, computing set intersection, union and difference, or getting the member with highest ranking in a sorted set.
From an operational perspective, the Redis implementation in Azure lets you replicate cache instances in a two-node primary/secondary configuration, entirely managed by Microsoft. Redis also supports master-subordinate replication, with fast non-blocking first synchro- nization, auto-reconnection on net split, and so forth. Just to expand on the replication feature, which, for me, is a differentiation point:
• Redis replication is non-blocking on the master side. This means that the master will continue to handle queries when one or more slaves perform the initial synchronization.
• Replication is non-blocking on the slave side. While the slave is performing the initial synchronization, it can handle queries using the old version of the dataset.
Optionally, Redis supports persistence. Redis persistence lets you save data stored in Redis cache permanently to an allocated
This article discusses:
• Connecting to an instance of Redis Cache in Azure
• Typical Cache Design Patterns
• Demand Estimation in Azure Machine Learning
• Consuming an Azure Machine Learning Web service
Technologies discussed:
Microsoft Azure Redis Cache and Machine Learning, ASP.NET MVC, Linear Regression
Code download available at:
bit.ly/2qkV65u
34 msdn magazine












































































   38   39   40   41   42