Thursday, May 29, 2014

Understanding Caching

Understanding Caching

Caching Approach
Characteristics
Advantages
Disadvantages
Comments
Caching Services
Out of Process
In Memory
Distributed
Accessible by all types of Azure technologies. Scalable.
Extra cost for Service
For building high-performance, scalable cloud systems.
Azure In-Role Caching
Out of Process
In Memory
Distributed
Can run in the memory space of existing Roles
Only available to Web/Worker Roles within Cloud Services.
Suitable for adaptation to existing applications migrated to Azure.
ASP.NET/IIS Cache
In-Process
In Memory
Single-Locale
Runs in the memory space of the existing application.
Requires cache synchronization to work with scalable Azure applications.
Will require adaptations to use distributed caching when used with Azure load balancing.
Azure SQL Database
Out of Process
Out of Memory
Distributed
Data is persistently stored in a database table.
Requires custom coding to serialize data, and for management such as expiration.
Slower than in-memory applications, may be throttled in periods of high request.
Azure Table Storage
Out of Process
Out of Memory
Distributed
Data is persistently stored in Azure table storage.
High performance for very large datasets, cost-effective. Requires custom code.
Slower than in-memory, but faster than SQL. May be throttled in periods of high requests.
Azure Blob Storage
Out of Process
Out of Memory
Distributed
Data is persistently stored in Azure Blob storage.
Can leverage geo-redundant persistent storage. Requires custom code.
Slower than in memory, but easy to make highly distributed.

Tuesday, May 13, 2014

ASP.NET Azure Session State in Azure

ASP.NET Azure Session State in Azure

In addition to the data caching, we can also use Windows Azure Caching as the storage mechanism for ASP.NET Session State and ASP.NET Page Output Caching. The Session State Provider for Windows Azure Caching and the Output Cache Provider for Windows Azure Caching are the out-of-process storage for ASP.NET applications which will greatly work with Windows Azure load balancers. To use Windows Azure Caching as the storage mechanism for ASP.NET Session State and ASP.NET Page Output Caching, first you need to configure Cache Cluster (using one of the two approaches explained above) and then you need to configure your ASP.NET application to use the Windows Azure Caching. After you have configured the Cache Cluster, you can use Windows Azure Caching for ASP.NET Session State and ASP.NET Page Output Caching by adding necessary configuration setting in the web.config file.
The following configuration setting in the web.config allows to use the Session State Provider for Windows Azure Caching for web applications.

  
              type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
          cacheName="default"
          useBlobMode="true"
          dataCacheClientName="default" />
  
The cacheName specifies the name of the Cache used for persisting Session State data.
The following configuration setting in the web.config configures the Session State Provider for Windows Azure Caching for web applications

  
    
                     type="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache"
            cacheName="default"
            dataCacheClientName="default" />