Distributed Caching Using Windows Azure AppFabric.
Upcoming SlideShare
Loading in...5
×
 

Distributed Caching Using Windows Azure AppFabric.

on

  • 2,669 views

Distributed Caching Using Windows Azure AppFabric - White Paper

Distributed Caching Using Windows Azure AppFabric - White Paper

Statistics

Views

Total Views
2,669
Views on SlideShare
2,665
Embed Views
4

Actions

Likes
2
Downloads
55
Comments
1

1 Embed 4

http://www.linkedin.com 4

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • The concept of distributed caching is not a new thing anymore. A distributed cache is essential for any application that demands fast performance during extreme transaction loads. An in-memory distributed cache is faster than a database. And, it can provide linear scalability in handling greater transaction loads because it can easily let you add more servers to the cache cluster that a database server cannot do. Now which distributed cache provider is the best among all, this question may requires some argument, but here is a comparison between the two widely used distributed cache providers in the market i.e. NCache Vs AppFabric.

    http://www.alachisoft.com/ncache/demos/ncache-vs-appfabric.html
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Distributed Caching Using Windows Azure AppFabric. Distributed Caching Using Windows Azure AppFabric. Document Transcript

  • Distributed CachingUsing Windows Azure AppFabric.Vaibhav Gujral
  • Document TitleGo to marketo to Market Proposaoll YASH TechnologiesContents1 Introduction ................................................................................................................................. 4 1.1 What is Distributed Caching? ...................................................................................................... 4 1.2 What is Windows Azure AppFabric Caching? ........................................................................... 42 Windows Azure AppFabric Caching ............................................................................................ 6 2.1 Under the hood ............................................................................................................................. 7 2.2 Cache-aside pattern ..................................................................................................................... 8 2.3 Security.......................................................................................................................................... 83 Pricing for AppFabric Caching .................................................................................................... 94 Real-World Scenarios for using AppFabric Caching ................................................................. 105 Conclusion ................................................................................................................................ 106 References................................................................................................................................ 117 Further Reading ........................................................................................................................ 118 About YASH .............................................................................................................................. 12©YASH Technologies Page 2 of 12
  • Distributed Caching-using Windows Azure AppFabric
  • Document TitleGo to marketo to Market Proposaoll YASH Technologies1 IntroductionCaching has always been an integral part of any data driven web application from the times oftraditional computing world. Caching is a process where data is stored in a component so that, infuture, it could be accessed in a much faster way. It has always been a stand-alone mechanismfrom the very beginning. And, since applications are highly scalable now and could span up tomultiple servers and multiple processors within each server, stand-alone caching techniques are notthe most desired solution for performance optimization.1.1 What is Distributed Caching?In the world of highly scalable and high performance applications, there comes the concept ofdistributed caching which makes caching highly scalable by spanning across multiple servers. Inother words, it is a form of caching where the caching techniques are applied over a set ofdistributed servers, still giving a logical representation of a single cache. With the recentadvancement in technology and fall in hardware prices, distributed caching has been the bestcaching solution present in the market today. One of the distributed caching solutions readilyavailable in the market is Windows Azure AppFabric Caching service.Distributed caching could be used for storing application data, session state data, resource data etcwhich may be required by the application at regular intervals. A distributed cache maintains a copyof this data in a temporary store which is meant to store the data for a particular time frame whichcould range from a few minutes to few hours to few days.1.2 What is Windows Azure AppFabric Caching?Windows Azure AppFabric caching is a distributed, in-memory, application cache service fordifferent cloud based applications. Since the cache is maintained in-memory, it provides theapplication high-speed access to the highly scalable data. It is a managed service that is operatedby Microsoft and has 99.9% monthly SLA. Cloud Cache Servers Databases Users Web Application Windows Azure AppFabric Caching©YASH Technologies Page 4 of 12
  • Document TitleGo to marketo to Market Proposaoll YASH TechnologiesThe Caching service is build upon the core design principles of Speed and Scalability. In a nutshell,it provides a highly scalable in-memory cache which could be utilized by an application to improveits performance and throughput by avoiding unnecessary roundtrips to the databases/storage.The caching service forms a part of PaaS offering from Microsoft, Windows Azure platform. It allowsreduction in latency and delivers great application performance anywhere in the world. The Cachingservice was released as a Community Technology Preview (CTP) at the Microsoft ProfessionalDevelopers Conference in 2010, and was refreshed in February 2011.It supports the following capabilities: 1. High Scalability: The size of the cache could be increased or decreased by simply modifying the configuration. 2. High Manageability: Developers just need to specify the cache size and geographical region. The rest of the provisioning and cache management process is taken care by the caching service internally. 3. High Flexibility: Caching service could be used to store any type of managed object data including CLR objects, Binary data and XML data. 4. High Security: Caching service uses security tokens from the Access control service for secured access and authorization. 5. 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 few configuration changes. 6. Consistent development model: Windows Azure AppFabric Caching service is built on the same underlying technology platform as Windows Server AppFabric Caching. It is designed to support automatic provisioning and management of the cache in Windows Azure.Further, the cache could be accessed via multiple machines at same time. Alternatively, a localcache could be created at each client machine by making minimal configuration changes. Thiseliminates the network latency since the cached data is copied to the local client machines.Caching service presents a simple, easy-to-use and cost-effective distributed caching solution. Itcan be implemented with minimal configuration changes for ASP.Net providers or minimal codechanges to store and retrieve data from the cache via exposed APIs.Being a part of Microsoft’s cloud offering, Caching Service brings along all the benefits of usingcloud. The most convincing is that it’s based on “Pay as you Use” model. You are billed for theamount of the cache that you have consumed.©YASH Technologies Page 5 of 12
  • Document TitleGo to marketo to Market Proposaoll YASH Technologies2 Windows Azure AppFabric CachingWindows Azure AppFabric Caching service is highly scalable in-memory cache service running inMicrosoft’s cloud. It involves the following three main components for using Caching service in data-driven application: 1. 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. 2. 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. 3. 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 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. Communication using WCF AppFabric Caching Service Cache ClientThese three components adds to the simplicity of AppFabric cache and makes it easy-to use.Developers just need to consume the caching service either using the pre-built ASP.Net provider orthrough cache APIs.©YASH Technologies Page 6 of 12
  • Document TitleGo to marketo to Market Proposaoll YASH Technologies2.1 Under the hoodInternally, whenever AppFabric Cache is provisioned in Windows Azure Data center, it allocates acollection of cache servers which combine with each other to give a representation of a singleunified in-memory cache system. For example, if a cache of size 1 GB is configured, then WindowsAzure blocks memory of specified size divided in a number of servers each forming a part of theoriginal cache. This is helpful whenever there is a server crash due to hardware or any otherpossible reason. Since the cache is divided and provisioned in multiple servers, if one of the serverscrashes, then the data loss is limited to a certain 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 cacheservers are used for provisioning of the cache. This can be depicted in the following figure whichhighlights how AppFabric cache is provisioned. Users Application Server Distributed In-Memory Cache Cache Servers Database ServersHere, cache is spread out across multiple cache servers (depending upon the size of the cache)and the user applications still access the cache as a single in-memory cache.©YASH Technologies Page 7 of 12
  • Document TitleGo to marketo to Market Proposaoll YASH Technologies2.2 Cache-aside patternAppFabric Cache supports the cache-aside pattern for development purposes. This patternspecifies the following steps for storing and fetching data from the cache: 1. Whenever data is looked up in cache, first of all, it is determined if the data exists in the cache. 2. If data exists in the cache, it is returned to the user application. 3. If data does not exist in the cache, then the original data source is queried to fetch the required data. Once the data is fetched, the cache is loaded with the data and the data is then returned to the user application.Hence, the cache is updated over time as the instances of the application requests for the data.Further, AppFabric cache supports different features including configuring the time frame for whichdata should reside in the cache.It should be noted that the cache-aside pattern doesnt allows the pre-population of data in thecache.2.3 SecurityWindows Azure AppFabric Caching Service works closely with the Windows Azure AppFabricAccess Control Service (ACS) for defining the security that is used to access the cache. In otherwords, the authentication for accessing the stored data is based on ACS. Caching serviceauthenticates applications based on ACS token. This means that applications without having ACStoken are not allowed to access any data in the cache, And once application produces ACS token, itis matched for authentication and accordingly the access is granted to the data stored in the cache.This security information necessary to connect to the cache is provided at the time of provisioningitself.By using ACS for security of the data, Azure AppFabric Caching service ensures that the data isfetched by only authenticated users/applications. As discussed earlier that the cache is spreadacross multiple servers and by design, Azure AppFabric caching supports multi-tenancy whichsupports sharing of resources between multiple users/applications. So, to ensure reliability andsecurity of cached data, AppFabric caching service makes use of ACS tokens. This way,applications can access only the data attached to a particular ACS token. This ensures that no datahacking takes place between different caches in Windows Azure data centers.Security being an important aspect of any data driven application, Microsoft has ensured thatcached data is exposed to only authenticated users/applications based on Access Control Servicewhich is a highly secured and reliable mechanism based on federated services.©YASH Technologies Page 8 of 12
  • Document TitleGo to marketo to Market Proposaoll YASH Technologies3 Pricing for AppFabric CachingCaching service is part of Windows Azure Platform offering from Microsoft. As a whole, WindowsAzure Platform follows “Pay as you use” model. Hence, when using caching service, it costs only forthe size of the cache that is used in a month.Depending upon the actual size of the cache selected in the configuration, the monthly chargesdiffer. The more the cache size, more will be the savings in the monthly charges. For Example, a128 MB cache costs $45. Based on this calculation, a 512 MB of cache space should cost $180.But, Microsoft charges only $75. This results in great savings based on the cache size, i.e., thesavings increases with an increase in the cache size.The cache size can be specified in the configuration and can be modified once a day according tothe need. For Example, for days when a website expects normal load, the cache can be set to 128MB and during the days having peak loads, the cache size could be configured to any higher sizedepending upon the requirement. At the month end, bill is calculated according to the usage.Caching is priced per cache size per month. For Example, a cache of size 128MB costs $45 permonth. Similarly, a cache of size 1 GB costs $110 per month. The complete charges are as givenbelow: Size/Meter Monthly Charges 128 MB cache $45.00 256 MB cache $55.00 512 MB cache $75.00 1 GB cache $110.00 2 GB cache $180.00 4 GB cache $325.00Hence, Windows Azure AppFabric Caching provides an affordable caching service which is highlyscalable, reliable and easy-to-use. It’s advisable to take a bigger chunk of cache then multiple smallcaches as this approach may help in cost-savings.©YASH Technologies Page 9 of 12
  • Document TitleGo to marketo to Market Proposaoll YASH Technologies4 Real-World Scenarios for using AppFabric CachingThe caching service is a simple, easy-to-use, highly flexible service and could be used to store anytype of managed objects. Some common data types include the following: 1. Reference Data: The data which is frequently changed and read by an application can be loaded into the cache and application can access this data from the cache rather than the original application database or other storage type. This result in improved performance coupled with increased scalability. For example: data representing product catalogue or a country list or stock tickers. 2. Activity-oriented Data: The data which is specific to a user session or a particular activity could be stored in cache. Caching service provides pre-built ASP.Net session state providers which could be used to store session state in in-memory cache provided by the caching service. 3. Shared Data: This includes an application’s resource data which is not user session specific and could be shared across the complete application. For Example, data representing Product inventories.In simplest terms, any managed data type which is serializable can be stored in Windows AzureAppFabric cache.5 ConclusionWindows Azure AppFabric Caching service forms a part of the comprehensive middleware servicesprovided by Microsoft as a part of its PaaS offering, Windows Azure Platform. AppFabric cachingservice provides a highly scalable, secure, easy to use, cost effective solution for all the distributedcaching needs.AppFabric Caching service provides pre-built ASP.Net providers and caching APIs to store andretrieve data from the cache. It requires minimal configuration/code changes for implementation.Further, it just 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 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 Windows Azure Platform. Thecache is distributed among multiple servers so as to ensure minimal data loss, but, overall, thecache is represented as a single, unified, highly scalable and reliable distributed in-memory cachingservice. Hence, it could be concluded that AppFabric Caching service has made distributed caching a loteasier for developers and IT professionals.©YASH Technologies Page 10 of 12
  • Document TitleGo to marketo to Market Proposaoll YASH Technologies6 References 1. http://msdn.microsoft.com/en-us/magazine/gg983488.aspx 2. http://www.windowsazure.com/en-us/home/tour/caching/7 Further Reading 1. http://msdn.microsoft.com/en-us/magazine/hh708748.aspx 2. http://msdn.microsoft.com/en-us/gg457897 3. https://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/ 4. http://weblogs.asp.net/shijuvarghese/archive/2011/05/04/using-windows-azure-appfabric- caching.aspx©YASH Technologies Page 11 of 12
  • Document TitleGo to marketo to Market Proposaoll YASH Technologies8 About YASH TechnologiesYASH Technologies was founded on the principles of lasting partnerships, accountability, andexceptional service and value. As a mid-sized organization that provides technology services andoutsourcing to global enterprises, YASH derives bottom line results for our customers by beingflexible in approach, agile in delivery, and focusing on customers success.Since 1996, YASH’s business has been to utilize technology to build robust solutions that help ourcustomers become more agile, boost performance, and deliver value throughout their ecosystemsto grow their organizations.About the author: Vaibhav Gujral, Technical Lead, YASH TechnologiesVaibhav Gujral is a technical lead, in YASH’s Microsoft practice. He has over five years ofexperience in software development using .Net framework and since the last 2 years has beenworking on Microsoft’s cloud computing platform, Windows Azure. Vaibhav has in-depthunderstanding of the architecture and internals of Windows Azure and is passionate about thefuture of cloud computing and its potential. Before joining YASH, he has worked with Indian ITservice providers like Infosys Technologies Ltd. and Mindtree Ltd. He is based out of YASH’sHyderabad, India office and can be reached at vaibhav.gujral@yash.com.©YASH Technologies Page 12 of 12