Windows Azure Caching

Last updated

an in-memory, distributed caching feature designed for Microsoft Azure applications. Caching was available as a part of the Windows Azure SDK. The Azure Managed Cache and In-Role Cache services were retired, and Microsoft recommended migration to Azure Redis Cache.

Contents

Architecture

Windows Azure Caching allows a cloud service to host Caching on a Windows Azure role. [1] The cache is distributed across all running instances of that role. Therefore, the amount of available memory in the cache is determined by the number of running instances of the role that hosts Caching and the amount of physical memory reserved for Caching on each instance. [2]

There are two deployment topologies for Caching:

Dedicated topology

In the dedicated topology, you define a worker role that is dedicated to Caching. This means that all of the worker role's available memory is used for the Caching and operating overhead.

The following diagram shows Caching in a dedicated topology. The cloud service shown has three roles: Web1, Worker1, and Cache1. There are two running instances of each role. In this example, the cache is distributed across all instances of the dedicated Cache1 role.

Windows Azure Caching (Dedicated).jpg

A dedicated topology has the advantage of scaling the caching tier independently of any other role in the cloud service. [5] For the best Caching performance, a dedicated topology is recommended because the role instances do not share their resources with other application code and services. [3]

Co-located topology

In a co-located topology, you use a percentage of available memory on existing web or worker roles for Caching. [4]

The following diagram shows Caching in a co-located topology. The cloud service has two roles: Web1 and Worker1. There are two running instances of each role. In this example, the cache is distributed across all instances of the Web1 role. Because this role also hosts the web front-end for the cloud service, the cache is configured to use only a percentage of the physical memory on each instance of the Web1 role.

Windows Azure Caching (Co-located).jpg

A co-located cache is a cost-effective way to make use of existing memory on a role within a cloud service. [4]

Examples

The following sections show Windows Azure Caching configuration and code examples.

Configuration example

In Visual Studio, Caching is configured in the Caching tab of the properties of the role that hosts Caching. [6] This makes underlying changes to the ServiceConfiguration.cscfg file. [7] These settings determine the topology used (dedicated or co-located) and the number of named caches [8] and their settings.

Other roles must be configured to use Caching. [9] One way to do this is with a NuGet package. This includes modifying the web.config to contain a properly configured dataCacheClients [10] section. The following example dataCacheClients section specifies that the role that hosts Caching is named “CacheWorker1”.

<dataCacheClients><dataCacheClientname="default"><autoDiscoverisEnabled="true"identifier="CacheWorkerRole1"/></dataCacheClient></dataCacheClients>

Code examples

Note that the code samples in this section are shown in C#.

When hosting Caching on roles, the DataCache class constructor can be used to specify both the named cache and the dataCacheClient section for the cache client settings. The following code shows how to create a named cache, NamedCache2, using the settings from a dataCacheClient section named customClient.

varcache=newDataCache("NamedCache2","customClient");

The following method shows how to use the Cache object to retrieve data from the cache. In this example, a user identifier (userid) is the key for the associated user information object. The code first attempts to get this user information from the cache using the userid key. If that does not succeed, the code retrieves the information with a database query and then stores the returned user data in the cache. The next time the same code is run, the user information will be returned from the cache rather than the database. This assumes that the cached data has not been expired or evicted.

dataTypeGetUserData(stringuserId){dataTypedata=null;// Attempt to retrieve the user data from the cache:objectdataObject=Cache.Get(userId);if(dataObject!=null)data=(dataType)dataObject;else{// If it doesn't exist in the cache, retrieve it from the database:data=GetUserDataFromDatabase("SELECT * FROM users WHERE userId = @userId",userId);// Put the returned data in the cache for future requests:Cache.Add(userId,data);}returndata;}

The following method shows how to update data that is already in the cache.

voidUpdateUserData(stringuserId,dataTypedata){// Update the user information in the database:result=UpdateUserDataInDatabase(userId,data);if(result){// If successfully updated, update the cache:Cache.Put(userId,data);}}

The following call removes the item from the cache.

Cache.Remove(userId);

Shared Caching

Windows Azure Shared Caching provides caching as a managed service. [11] Unlike co-located or dedicated topologies, the cache is not hosted on Windows Azure roles in a single cloud service deployment. Instead, the cache is provided as a multitenant service with usage quotas. [12] The service is divided into tiers that range from 128 MB to 4 GB. [13] In addition to storage capacity, each tier provides increasing processor and network capabilities. [13] Shared Caching provides a way for multiple cloud services to access the same cache.

History

Windows Azure Caching has its roots in an on-premises technology, AppFabric. It was originally released as one of several Windows Azure AppFabric services, but the AppFabric designation in Windows Azure has since been abandoned. Many of the assembly names, namespaces, and APIs are identical between Windows Azure Caching and AppFabric Caching. [14] The first release of Caching for Windows Azure in April 2011 provided caching as a managed service in Windows Azure. [15] This offering is now called Shared Caching.

In October 2012, support was added for hosting Caching on roles within a cloud service deployment. [16] This is now called Windows Azure Caching.

Windows Azure Caching is related to other Microsoft caching technologies. These technologies share similar features, such as the assembly name, namespace, and types. [14] However, there are some differences. The table below describes these technologies.

Caching TechnologyTargetInstalled ByDescription
AppFabric Caching On-Premises AppFabric Distributed on-premises cache that uses servers that the user provisions and manages.
Windows Azure Caching Cloud Windows Azure SDK Caching is distributed across the instances of a single role in a Windows Azure cloud service deployment.
Windows Azure Shared Caching Cloud Windows Azure SDK Caching is provided as a multitenant service for use by Windows Azure cloud services.

Related Research Articles

Active Directory (AD) is a directory service developed by Microsoft for Windows domain networks. It is included in most Windows Server operating systems as a set of processes and services. Initially, Active Directory was used only for centralized domain management. However, Active Directory eventually became an umbrella title for a broad range of directory-based identity-related services.

<span class="mw-page-title-main">Windows 2000</span> Personal computer operating system by Microsoft released in 2000

Windows 2000 is a major release of the Windows NT operating system developed by Microsoft and oriented towards businesses. It was the direct successor to Windows NT 4.0, and was released to manufacturing on December 15, 1999, and was officially released to retail on February 17, 2000. It was Microsoft's business operating system until the introduction of Windows XP Professional in 2001.

Memcached is a general-purpose distributed memory-caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source must be read. Memcached is free and open-source software, licensed under the Revised BSD license. Memcached runs on Unix-like operating systems and on Microsoft Windows. It depends on the libevent library.

Microsoft Exchange Server is a mail server and calendaring server developed by Microsoft. It runs exclusively on Windows Server operating systems.

Remote Desktop Protocol (RDP) is a proprietary protocol developed by Microsoft which provides a user with a graphical interface to connect to another computer over a network connection. The user employs RDP client software for this purpose, while the other computer must run RDP server software.

Windows Presentation Foundation (WPF) is a free and open-source graphical subsystem originally developed by Microsoft for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was initially released as part of .NET Framework 3.0 in 2006. WPF uses DirectX and attempts to provide a consistent programming model for building applications. It separates the user interface from business logic, and resembles similar XML-oriented object models, such as those implemented in XUL and SVG.

Microsoft Servers is a discontinued brand that encompasses Microsoft software products for server computers. This includes the Windows Server editions of the Microsoft Windows operating system, as well as products targeted at the wider business market. Microsoft has since replaced this brand with Microsoft Azure, Microsoft 365 and Windows 365.

As the next version of Windows NT after Windows 2000, as well as the successor to Windows Me, Windows XP introduced many new features but it also removed some others.

The Microsoft Enterprise Library is a set of tools and programming libraries for the Microsoft .NET Framework. It provides APIs to facilitate proven practices in core areas of programming including data access, logging, exception handling and others. Enterprise Library is provided as pluggable binaries and source code, which can be freely used and customized by developers for their own purposes. It also ships with test cases and quickstarts.

Azure DevOps Server is a Microsoft product that provides version control, reporting, requirements management, project management, automated builds, testing and release management capabilities. It covers the entire application lifecycle, and enables DevOps capabilities. Azure DevOps can be used as a back-end to numerous integrated development environments (IDEs) but is tailored for Microsoft Visual Studio and Eclipse on all platforms.

<span class="mw-page-title-main">SharePoint</span> Web application platform

SharePoint is a web-based collaborative platform that integrates natively with Microsoft Office. Launched in 2001, SharePoint is primarily sold as a document management and storage system, but the product is highly configurable and its usage varies substantially among organizations.

<span class="mw-page-title-main">Visual Studio</span> Code editor and IDE

Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms such as Windows API, Windows Forms, Windows Presentation Foundation, Windows Store and Microsoft Silverlight. It can produce both native code and managed code.

Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications—which may run either on the same computer or on another computer across a network. Microsoft markets at least a dozen different editions of Microsoft SQL Server, aimed at different audiences and for workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users.

<span class="mw-page-title-main">Microsoft Azure</span> Cloud computing service created by Microsoft

Microsoft Azure, often referred to as Azure, is a cloud computing platform operated by Microsoft for application management via around the world-distributed data centers. Microsoft Azure has multiple capabilities such as software as a service (SaaS), platform as a service (PaaS) and infrastructure as a service (IaaS) and supports many different programming languages, tools, and frameworks, including both Microsoft-specific and third-party software and systems.

Some of the new features included in Windows 7 are advancements in touch, speech and handwriting recognition, support for virtual hard disks, support for additional file formats, improved performance on multi-core processors, improved boot performance, and kernel improvements.

<span class="mw-page-title-main">Redis</span> Open-source in-memory key–value database

Redis is an in-memory data structure store, used as a distributed, in-memory key–value database, cache and message broker, with optional durability. Redis supports different kinds of abstract data structures, such as strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indices. The project was developed and maintained by Salvatore Sanfilippo, starting in 2009. From 2015 until 2020, he led a project core team sponsored by Redis Labs. Salvatore Sanfilippo left Redis as the maintainer in 2020. It is open-source software released under a BSD 3-clause license. In 2021, not long after the original author and main maintainer left, Redis Labs dropped the Labs from its name and now is known simply as "Redis".

AppFabric is a set of middleware technologies for Windows Server, released by Microsoft. It consists of two main feature areas: AppFabric Hosting and AppFabric Caching. Microsoft support for these ended in November 2017. A newer version of the product from Microsoft is Service Fabric.

AppFabric Caching provides an in-memory, distributed cache platform for Windows Server. Microsoft developed AppFabric Caching and released it as part of AppFabric.

Azure Web Apps is a cloud computing based platform for hosting websites, created and operated by Microsoft. It is a platform as a service (PaaS) which allows publishing Web apps running on multiple frameworks and written in different programming languages, including Microsoft proprietary ones and 3rd party ones. Microsoft Azure Web Sites became available in its first preview version in June 2012, and an official version was announced in June 2013. Microsoft Azure Web Sites was originally named Windows Azure Web Sites, but was renamed as part of a re-branding move across Azure in March 2014. It was subsequently renamed "App Service" in March 2015.

The history of Microsoft SQL Server begins with the first Microsoft SQL Server database product – SQL Server v1.0, a 16-bit relational database for the OS/2 operating system, released in 1989.

References

  1. "Caching in Windows Azure". MSDN Library. Microsoft. Retrieved 12 February 2013.
  2. "Capacity Planning Considerations for Windows Azure Caching". MSDN Library. Microsoft. Retrieved 13 February 2013.
  3. 1 2 "Windows Azure Caching on Dedicated Roles". MSDN Library. Microsoft. Retrieved 13 February 2013.
  4. 1 2 3 "Windows Azure Caching on Existing Roles". MSDN Library. Microsoft. Retrieved 13 February 2013.
  5. "About Windows Azure Caching, Cache Cluster". MSDN Library. Microsoft. Retrieved 13 February 2013.
  6. "How to Use Windows Azure Caching". Windows Azure Website. Microsoft. Retrieved 13 February 2013.
  7. "Windows Azure Caching Role Configuration Settings (ServiceConfiguration.cscfg)". MSDN Library. Microsoft. Retrieved 13 February 2013.
  8. "About Windows Azure Caching, Named Caches". MSDN Library. Microsoft. Retrieved 13 February 2013.
  9. "Getting Started with Development for Windows Azure Caching, Configure the Clients". MSDN Library. Microsoft. Retrieved 13 February 2013.
  10. "Windows Azure Caching Client Configuration Settings (Web.config), dataCacheClients". MSDN Library. Microsoft. Retrieved 13 February 2013.
  11. "About Windows Azure Shared Caching". MSDN Library. Microsoft. Retrieved 13 February 2013.
  12. "Understanding Quotas for Windows Azure Shared Caching". MSDN Library. Microsoft. Retrieved 13 February 2013.
  13. 1 2 "Windows Azure Shared Caching FAQ". MSDN Library. Microsoft. Retrieved 13 February 2013.
  14. 1 2 "Differences Between Caching On-Premises and in the Cloud". MSDN Library. Microsoft. Retrieved 13 February 2013.
  15. "Introducing the Windows Azure Caching Service". MSDN Magazine. Microsoft. Retrieved 13 February 2013.
  16. "Windows Azure Caching Release Notes (October 2012)". MSDN Library. Microsoft. Retrieved 13 February 2013.