You are on page 1of 6

Technical White Paper

Distributed Caching Using


Windows Azure AppFabric. .
Contents

Introduction ………………………………………………………………….................

What is Distributed Caching? ...............................................................

What is Windows Azure AppFabric Caching? ................................

Windows Azure AppFabric Caching......................................................

Under the hood ……………………………………………………………...........

Cache-aside pattern ……………………………………………………….........

Security………………………………………………………………………...............

Real-World Scenarios for using AppFabric Caching.....................

Conclusion …………………………………………………………………....................

References………………………………………………………………….....................

About YASH ………………………………………………………………....................


Introduction
Caching has always been an integral part of any data-driven web application from the times of traditional
computing. Caching is a process where data is stored in a component to be accessed in the future much
faster. It has always been a stand-alone mechanism from the very beginning. And, since applications are
highly scalable now and could span across multiple servers and multiple processors within each server,
independent caching techniques are not the most desired solution for performance optimization.

What is Distributed Caching?


In the world of highly scalable and high-performance applications, there comes the concept of distributed caching which
makes caching highly scalable by spanning across multiple servers. In other words, it is a form of caching where the caching
techniques are applied over a set of distributed servers, still giving a logical representation of a single cache. With the recent
advancement in technology and fall in hardware prices, distributed caching has been the best caching solution in the market
today. One of the distributed caching solutions readily available in the market is Windows Azure AppFabric Caching service.
Distributed caching could be used for storing application data, session state data, resource data, etc. which may be required
by the application at regular intervals. A distributed cache maintains a copy of this data in a temporary store which is meant
to store the data for a particular time frame ranging from a few minutes to a few hours or few days.

What is Windows Azure AppFabric Caching?


Windows Azure AppFabric Caching is a distributed, in-memory, application cache service for different cloud-based
applications. Since the cache is maintained in-memory, it allows the application high-speed access to the highly scalable
data. It is a managed service that is operated by Microsoft and has 99.9% monthly SLA.

• High Security: Caching service uses security tokens


from the Access control service for secured access and
authorization.
• Web applications acceleration: Caching service provides
pre-built ASP.Net providers for Session state and page
output caching. Hence, no modification is required in the
application code for using Caching service apart from a
few configuration changes.
Windows Azure AppFabric Caching
• Consistent development model: Windows Azure
The Caching service is built upon the core design principles AppFabric Caching service is built on the same underlying
of Speed and Scalability. In a nutshell, it provides a highly technology platform as Windows Server AppFabric
scalable in-memory cache which could be utilized by an Caching. It is designed to support automatic provisioning
application to improve its performance and throughput by and management of the cache in Windows Azure.
avoiding unnecessary round trips to the databases/ storage.
The caching service forms a part of PaaS offering from Further, the cache could be accessed via multiple machines
Microsoft, Windows Azure platform. It allows a reduction at same time. Alternatively, a local cache could be created
in latency and delivers great application performance at each client machine by making minimal configuration
anywhere in the world. changes. This eliminates the network latency since the
cached data is copied to the local client machines.
It supports the following capabilities:
Caching service presents a simple, easy-to-use and cost-
• High Scalability: The size of the cache could be increased effective distributed caching solution. It can be implemented
or decreased by simply modifying the configuration. with minimal configuration changes for ASP.Net providers or
minimal code changes to retrieve as well as store data from
• High Manageability: Developers just need to specify the cache via exposed APIs.
the cache size and geographical region. The rest of the
provisioning and cache management process is taken Being a part of Microsoft’s cloud offering, Caching Service
care of by the caching service internally. brings along all the benefits of using the cloud. The most
convincing is that it is based on a “Pay as you Use” model.
• High Flexibility: Caching service could be used to store You are billed for the amount of the cache that you have
any type of managed object data including CLR objects,
consumed.
Binary data and XML data.
Windows Azure AppFabric Caching
Windows Azure AppFabric Caching service is a highly scalable in-memory cache service running in
Microsoft’s cloud. It involves the following three main components for using caching service in a data
driven application:

Services
• Caching Service: Caching service is a virtual pool of
partitioned and shared memory that can be consumed. It
exposes a secure Windows Communication Foundation (WCF)
endpoint to talk to and an explicit highly scalable cache. It also
exposes various cache APIs which could be called from a cache
client to store and retrieve data from the cache. It automatically
partitions the data stored in the cache so as to reduce the data-
loss probability.

• Cache Client: It is a part of the application that acts as


a proxy for the caching service. It knows how to talk to the
caching service and it may or may not use the Service’s cache
APIs to store and retrieve data from the cache. If the session
data has to be stored in the cache, then the pre-built ASP.Net
provider can be used. Else, data could be stored and fetched
using the Cache APIs exposed by caching service.

• Connection between the Client and the Service:


The communication between the caching service and the cache
client takes place based on the WCF protocol which provides
a highly secure communication channel. A security token from
AppFabric Access Control is used for authorization purposes
and this token is used by the caching service to restrict access
to the cached data.
These three components adds to the simplicity of AppFabric cache and makes it easy-to use. Developers just need to utilise
the caching service either using the pre-built ASP.Net provider or through cache APIs.

Under the hood


Internally, whenever AppFabric Cache is provisioned in the
Windows Azure Data centre, it allocates a collection of cache
servers which combine with each other to give a representation of
a single unified in-memory cache system. For example, if a cache
of size 1 GB is configured, then Windows Azure blocks memory
of the specified size divided in a number of servers each forming
a part of the primary cache. This is helpful whenever there is a
server crash due to hardware or any other possible reason. Since
the cache is divided and provisioned in multiple servers, if one of
the servers crashes, then the data loss is limited to a particular
portion of the cache. As soon as a server crashes, Windows Azure
automatically allocates appropriate memory in another cache
server to the user.

Hence, user applications can work with a single in-memory cache


regardless of how many cache servers are used for provisioning
of the cache. This can be depicted in the following figure which
highlights how AppFabric cache is provisioned.

Here, cache is spread out across multiple servers (depending on the size of the cache) and the user applications still access
the cache as a single in-memory cache.
Cache-aside pattern Security
AppFabric Cache supports the cache-aside pattern Windows Azure AppFabric Caching Service works closely with
for development purposes. This pattern specifies the Windows Azure AppFabric Access Control Service (ACS) for
the following steps for storing and fetching data defining the security that is used to access the cache. In other
from the cache: words, the authentication for accessing the stored data is based
on ACS. Caching service authenticates applications based on
• Whenever data is looked up in ACS token. This means that applications without having ACS
cache, first of all, it is determined token are not allowed to access any data in the cache, and once
if the data exists in the cache. application produces ACS token, it is matched for authentication
and accordingly the access is granted to the data stored in the
• If data exists in the cache, it is cache. This security information necessary to connect to the
returned to the user application. cache is provided at the time of provisioning itself.

• If data does not exist in the cache, By using ACS for security of the data, Azure AppFabric Caching
then the original data source service ensures that the data is fetched by only authenticated
is queried to fetch the required users/applications. As discussed earlier, the cache is spread
data. Once the data is fetched, across multiple servers and by design, Azure AppFabric caching
the cache is loaded with the data supports multitenancy which supports sharing of resources
and the data is then returned to between multiple users/applications. So, to ensure reliability
the user application. and security of cached data, AppFabric caching service makes
use of ACS tokens. This way, applications can access only the
Hence, the cache is updated over time as the data attached to a particular ACS token. This ensures that no
instances of the application requests for the data. data hacking takes place between different caches in Windows
Further, AppFabric cache supports different features Azure data centres.
including configuring the time frame for which data
should reside in the cache. Security being an important aspect of any data driven
application, Microsoft has ensured that the cached data is
It should be noted that the cache-aside pattern exposed to only authenticated users/applications based on
doesn’t allows the pre-population of data in Access Control Service which is a highly secure and reliable
the cache. mechanism based on federated services.

Real-World Scenarios for using AppFabric Caching


The caching service is a simple, easy-to-use, highly flexible service and could be used to store any type
of managed objects. Some common data types include the following:

Reference Data Activity-oriented Data Shared Data

The data which is frequently changed and The data which is specific to This includes an application’s
read by an application can be loaded into a user session or a particular resource data which is not
the cache and application can access this activity can be stored in cache. user session specific and
data from the cache rather than the original Caching service provides pre- could be shared across the
application database or other storage built ASP.Net session state complete application. For
type. This result in improved performance providers which could be used example, data representing
coupled with increased scalability. For to store session state in a in- product inventories.
example, data representing a product memory cache provided by the
catalogue or a country list or stock tickers. caching service.

In simplest terms, any managed data type which is serializable can be stored in Windows Azure AppFabric
cache.
Conclusion
Windows Azure AppFabric Caching service forms a part of the comprehensive middleware services
provided by Microsoft as a part of its PaaS offering, Windows Azure Platform. AppFabric caching service
provides a highly scalable, secure, easy to use, cost effective solution for all distributed caching needs.
AppFabric caching service provides pre-built ASP.Net providers and caching APIs to store and retrieve
data from the cache. It requires minimal configuration/code changes for its implementation. Further, it
only requires developers to update the cache size and region in the Windows Azure Portal. The rest of
the management and provision process is taken care of by the caching service.
AppFabric Caching service ensures proper security of the cached data based on the ACS tokens. This
becomes more important considering the multi-tenancy model of the Windows Azure Platform. The
cache is distributed among multiple servers so as to ensure minimal data loss, but overall, the cache
is represented as a single, unified, highly scalable and reliable distributed in-memory caching service.
Hence, it could be concluded that AppFabric Caching service has made distributed caching a lot easier
for developers and IT professionals.

References
• http://msdn.microsoft.com/en-us/magazine/gg983488.aspx
• http://www.windowsazure.com/en-us/home/tour/caching/

For more information contact YASH today at info@yash.com or visit www.yash.com

About YASH Technologies


YASH Technologies focuses on customer success. As a leading technology services and outsourcing partner for large and fast growing
global customers, the company leverages technology and flexible business models to drive innovation and value throughout its customer’s
enterprise. YASH customer centric engagement and delivery framework integrates specialized domain and consulting capabilities with
proprietary methodologies and solution offerings to provision application, infrastructure and end user focused Right-Sourcing services.
YASH is a SEI CMMI (Level 5) and an ISO 9001:2015 certified company with U.S. and India headquarters and regional sales and development
offices globally with customers spread across 6 continents.
YASH-MS-Azure-WP-1217

YASH Technologies Global Presence www.yash.com/contactus


AMERICAS | EUROPE | APAC | MEA

World HQ: 605-17th Avenue East Moline IL 61244 USA | Toll Free: 877-766-8934 | Tel: 309-755-0433 | Fax: 309-796-1242 .

© 2017 YASH Technologies. All rights reserved. Referred products/ services may be registered trademarks of belonging companies.

You might also like