Microsoft Azure provides a platform for ASP.NET applications in the cloud. Very often, these applications are high transaction and mission-critical in nature. Therefore, it is very important that these applications are scalable and result in no data loss if a web server goes down at any time.
NCache Details Distributed Caching in .NET Highly Available NCache
ASP.NET Session State Storage Options
ASP.NET Session State needs to be stored somewhere and its storage becomes a major performance and scalability bottleneck. In Microsoft Azure, you can store ASP.NET Session State in InProc, Azure Table, SQL Database, or in a Distributed Cache.
InProc
InProc session storage option doesn’t work well in Microsoft Azure architecture. Firstly, ASP.NET Session State is not shared between multiple instances of the Web Role in InProc mode. Secondly, you end up using sticky sessions in Microsoft Azure, which may result in uneven load distribution. Additionally, sticky sessions involve extra configurations on your end as Microsoft Azure doesn’t use sticky sessions by default. Moreover, any Web Role instance going down due to failure or for maintenance will result in session data loss and this is obviously not acceptable.
Azure Table
Azure Table Storage is a file based ASP.NET Session State provider, which is given on an ‘as-is basis’ as a code sample, meaning it is not officially supported by Microsoft. It is intended for storing entities that are structured. Even though it is a cheaper option it is still not an ideal place to store ASP.NET Session State primarily because of performance as it is file-based.
SQL Database
Microsoft Azure SQL Database can also be used as storage for ASP.NET Session State by using the conventional ASP.NET SQL Server Mode. But the ASP.NET Session State object is stored in the database as a BLOB and relational databases were never really designed for BLOB storage. This causes performance issues, and it is definitely a major scalability bottleneck for your Microsoft Azure ASP.NET application.
Distributed Cache
Distributed Cache provides an ideal storage for ASP.NET Session State in Microsoft Azure. For example, you can use NCache for Azure which is a Microsoft Azure Distributed Cache for .NET applications. It is extremely fast and more scalable than all other Microsoft Azure options mentioned above, and it also replicates sessions so there is no data loss if a cache server ever goes down. Moreover, you eliminate all issues related to session sharing as well as use equal load balancing that ensures full utilization of all of your Azure Web role instances.
Plug-in NCache as your ASP.NET Session State Provider. NCache is an extremely fast and scalable Open-Source distributed cache for .NET. It handles extreme transaction load by allowing you to add more cache servers at runtime and scale linearly. NCache also provides intelligent cache replication so you don’t lose any ASP.NET Session State if a web server or a cache server goes down.
NCache Details NCache Cloud for Azure Getting Started Guide
How to Configure NCache in Azure ASP.NET Session State Provider?
NCache in Azure has implemented the ASP.NET Session State provider that can be used by Microsoft Azure ASP.NET applications. NCache in Azure uses Microsoft Azure VMs and formulates a dedicated caching tier. ASP.NET applications in Microsoft Azure can then be directed to use this Azure Distributed Cache for ASP.NET Session State storage.
The highlight of using NCache in Azure ASP.NET Session State provider is that it doesn’t require any application code changes. Its configuration is very easy, just modify your application web.config file as follows to use NCache in Azure as your Distributed Cache for ASP.NET Session State:
1 2 3 4 5 6 7 8 9 10 11 12 |
<assemblies> <add assembly="Alachisoft.NCache.SessionStoreProvider, Version=x.x.x.x, Culture=neutral, PublicKeyToken=CFF5926ED6A53769"> </add></assemblies> <sessionstate cookieless="false" regenerateexpiredsessionid="true" mode="Custom" customprovider="NCacheSessionProvider" timeout="20"></sessionstate> <providers> <add name="NCacheSessionProvider" type="Alachisoft.NCache.Web.SessionState.NSessionStoreProvider" sessionappid="NCacheTest" cachename="TestCache" writeexceptionstoeventlog="false"> </add></providers> |
NCache in Azure
NCache is an extremely fast and scalable Microsoft Azure distributed cache for .NET applications. NCache in Azure provides intelligent multi-region ASP.NET Session State support for your ASP.NET applications deployed in multiple Microsoft Azure regions.
Here are a few important benefits you achieve when you use NCache for Azure as your distributed cache for storing ASP.NET Session State.
- Linear Scalability and Performance: NCache for Azure is based on dynamic clustering protocol, which allows you to add more servers to your cache at runtime. Your application can scale out linearly by adding more servers to your Azure Distributed Cache when your application load grows without changing application architecture.
- Session Replication: NCache for Azure provides reliability support with help of replication. You can take application instances offline for maintenance, patching, and for new releases without having to worry about any session data loss.
- High Availability: NCache for Azure provides fault tolerant support of high availability as it is based on hundred percent peer to peer architecture. It is guaranteed that you will not lose any data or have any application downtime in case of any node failure from distributed cache.
NCache Details Distributed Caching in .NET Highly Available NCache
Conclusion
Azure Distributed Cache such as NCache in Azure is the best option for storing ASP.NET Session State in Microsoft Azure primarily because of performance, scalability, reliability, and high availability features. Microsoft Azure Distributed Cache offered by NCache for Azure is very easy to use and doesn’t require any application code changes.
What a fantastic read on Azure Tutorial.This has helped me understand a lot in Azure Tutorial. Please keep sharing similar write ups on Azure Training. Guys if you are keen to know more on Azure Tutorial,must check this wonderful Azure Course and i’m sure you will enjoy learning on Azure Tutorial.:-https://www.youtube.com/watch?v=8_0qGTdHZSs&t=51s