Share Data across ASP.NET Farm Using Distributed Caching

April 3, 2012

If you have a web farm and you are using ASP.NET session State server or SQL Server for storing sessions then you can face the following issues.

Single point of failure (data loss)

In the case of Session State Server, all the function are performed on a single node. In other words, the whole web farm is dependent upon a single node and if that node goes down, the whole web farm will go down. it may leads to single point of failure.

Slow performance on peak loads

As all the operations are being performed on a single node, it may results in performance issue during the peak load time. When there are numbers of requests at the same, it may choked up which will not only effects it performance but also ultimately the whole node will go down, which means the complete data lose.

Scalability issues due to database bottlenecks

As Session State Server is a database driven application, database may become a bottleneck when its size will exceed from a certain limit. For every request, session state server has to make a trip to the database which can cause the scalability issues.

Solution:

In situations like these,you should move to a distributed caching solution like NCache so that you can improve your application performance and remove the limitations of Session State Server.

With NCache you can enable the distributed caching without changing your application code. You can plug-in the cache with a web.config change. NCache provides couple of topologies which are optimized for different types of applications. There is a powerful dynamic clustering feature which lets you add/remove cache servers at runtime without stopping your application.

Client-cache

client-optimization – Based on Hasing alog the client makes intelligent decisions for storing and finding the data. It directly talks to the server where the data is stored and in a single call it fetches the data and gives linear scalability as you add more servers to your cache cluster. For read intensive applications the performance can be boost further with the help of client cache because it reduces the network trips for fetching the data from the remote cache.

About Alachisoft:

Alachisoft, is located in San Francisco Bay Area, California, is a leading provider of NCache and StorageEdge. NCache is a high performance in-memory object caching solution for mission critical .NET and Java applications with real-time data access needs. While StorageEdge optimizes SharePoint storage and performance. It externalizes all BLOBs from SharePoint content database and reduces the database size by 95%.

Download Free Version of NCache


NCache Features which AppFabric does not have

March 9, 2012

If the performance of a .NET application is effected during the peak load times, it is the end users who will be effected ultimately. This is the reason why distributed caching has become a hot cake for the .NET developers. it not only boost the performance of the application during peak load times, but it also provides scalability and reliability. There are numbers of third party distributed cache providers which are doing very good job, NCache and App Fabric being the two most famous ones.

Below is a list of features which make NCache the premier distributed cache provider.

1- Rich set of object caching features:

a: Cache Dependency for data relationship mgmt:
i) Key based
ii) File based
iii)Custom

b: Database synchronized
i) .NET events based with sqlCacheDependency for SQL 2005/2008 or Oracle on Windows.
ii) Polling based for any OLEDB compliant database

c: Absolute expirations

d: Group/sub-group items

e: Searching
i) Object Query Languages
ii) LINQ based searching

f: Streaming API for audio/video content:

g: Event Notification
i) AppFabric Key based notifications are not flexible you cannot register for specific event. If you enable notification on a key you will be notified whenever one of the followings happens (AddItem, ReplaceItem, RemoveItem, CreateRegion, RemoveRegion, ClearRegion). NCache on the other hand lets you specify an exact event on which to be notified so your app is not overwhelmed with unnecessary notifications

ii) Custom notifications that are initiated by client apps and used for using NCache as a runtime data sharing platform among different apps.

h: Read-thru/Write-thru/Write-behind

i: Compact serialization
NCache 3.8 provides a dynamic compact serialization which does not require any programming but is faster and more compact than regular .NET serialization. It also allows you to cache third-party objects that are otherwise not serializable.

j: Cache Loader
to pre-populate the cache upon startup

2: Dynamic Clustering & quick Failover with consistent data:

i) AppFabric has a single point of failure if the server that contains your cluster information goes down the whole cluster shuts down failing your application completely. On the other hand, NCache has a peer to peer dynamic clustering without single point of failure. You can add/drop any servers at runtime without stopping your application. Partition-Replica is totally dynamic with high availability in NCache.

ii) AppFabric failover results in data loss whereas with NCache 100% consistent data is seamlessly available before and after the failover.

iii) AppFabric requires a minimum of 3 nodes to satisfy the “majority lead hosts” rule even for this partial failover with some data loss whereas NCache requires just 2 servers for loss-less quick failover.

3- Change cluster configurations on the fly:

i) Unlike AppFabric, where you have to stop the entire cluster and your application to do any change on cluster configurations, the dynamic clustering in NCache allows you to change cluster configurations on the fly with “Hot Apply Configuration” option.

ii) You can increase the size of your cluster if your user base increases without stopping your cluster or your application.

4- Caching Topologies for Scalability:

a: Mirrored Cache
A Mirrored Cache is almost as fast as a stand-alone Local Cache which has no clustering cost. But, at the same time, a Mirrored Cache provides reliability through replication in case the active cache server goes down.

b: Partition-Replica
Partition-Replica is totally dynamic in NCache where you don’t have to do anything to set it up. Unlike AppFabric, you can choose to have synchronous or asynchronous replication to improve your application performance.

c: Client Cache
Client Cache that is local to your app sever but actually synchronizes with clustered cache. App Fabric only has local stand-alone cache which doesn’t address the issue of data integrity.

d: Bridge Topology
Bridge Topology that allows you to replicate cache across WAN asynchronously and without slowing down your main caches in each location. I think you guys needed this feature if I am not mistaken

5- Self-Healing Dynamic Clustering for 100% Uptime:

NCache provides a totally dynamic cache cluster where you can add/remove cache servers at runtime without stopping the cache or your application. NCache cluster recovers automatically recovers from network shortages.

6- GUI based Administration/Monitoring:

a: NCache Manager
GUI based NCache Manager let you configure and administer all cache clusters and clients from one place. The GUI has gone through a lot of improvements.

b: NCache Monitor
A totally new dashboard-style monitoring tool that lets you monitor all the caches and also your application together with them.

c: Command Line Tools
A number of command line tools to let you script and automate cache deployment. Power Shell support provided.

d: Alerts
Various alerts provided through Windows Events and also Emails. You can specify alerts on the following:

i) Cache start
ii) Cache stop
iii) Cache size above a certain threshold
iv) State transfer start when a node is added/removed in Partitioned/Partition-Replica Cache
v) State transfer end
vi) Node joined cluster
vii) Node left cluster

e: Cache Configuration Options
i) Automatic GZip Compression based on an item size threshold
ii) Eviction policy options (Least Recently Used, Least Frequently Used, Priority, Do not Evict)

7- View State Caching:

View State Caching reduces your ASP.NET payload sent to the browser by the web server and improves your response times.

8- Output Caching:

This speeds up rendering somewhat static pages since their output is cached at the web server.

9- Active Directory based Security:

Unlike AppFabric, NCache gives you multi-level security on the cache cluster servers. So you can aurthorize your specific clients to talk to it and prevent any intruders to read/write to the cache or change cluster configurations.

10- JavaScript/CSS optimization

Minify & merge multiple Javascript files into one to reduce multiple HTTP calls that a browser makes to load multiple Javascript files.

11- Java & JSP Support:

i) Native Java API
ii) Support for storing Java/JSP sessions in NCache
iii) Unix clients for Java API


Dynamic Clustering in Distributed Caching

July 8, 2011

Distributed caching is the ultimate source of high performance, scalability and reliability for your application. Cache cluster is one of the notable features of distributed caching. A cache cluster is a collection of one or more cache servers with every server connected to every other server in the cluster. Runtime adjustment of clusters like increase or decrease in size of the cluster without stopping it is called dynamic clustering. It gives your application 100% up time all the time

Business needs vary throughout the year. Heavy load is experienced on special occasions like Christmas, New Year, and during holiday seasons. On such events, runtime demand increases (In situations like these, you’ve to make frequent runtime adjustments in your application  which demands high performance, reliability and scalability. So, use distributed caching which provides you dynamic clustering.

If any of the cache server goes offline for maintenance reasons, the whole application will go down which is not acceptable in any situation so use distributed caching as it is the best available choice. NCache is a distributed caching solution which provides you dynamic clustering. NCache uses peer-to-peer architecture in which each node is interconnected. If one node goes down then the other takes its responsibility and you don’t experience any down times.

Dynamic clustering helps you get 100% uptime. It also improves reliability, performance and scalability of your application. You can even maintain your cache server, by keeping your application live. Your application won’t go offline during the whole process.

When you make any change on the cluster like addition or removal of cache server, it should be intelligent enough to know the changes made on cluster. Similarly client should be up to date about cache changes too. Otherwise your application will perform oddly.

NCache does not use any OS-based clustering (like Windows Clustering) but instead it creates its own TCP based dynamic cluster of cache servers which helps NCache to provide you 100% uptime without going offline at any stage.

Failover Support by NCache:

When a cache cluster is created, it appoints a cluster coordinator that manages all members of the cluster. The coordinator is the senior-most server in the cluster. If the coordinator ever goes down, this duty passes on to the next senior-most server in the cluster. This auto recovery dynamic cluster of NCache provides your application full failover support.

There are two types of failovers that NCache supports:

  • Failover support within cluster: When a cache server is added or removed from the cluster, the cluster members are updated about the change within cluster so each cache server adjusts its connections to all other cache servers.
  • Failover support for cache clients: This means that all the cache clients also automatically adjust themselves if a cache server is added or removed.

Benefits are:

  • 100% application uptime
  • Reliability
  • Self healing
  • Load balancing
  • Satisfied/happy customer

Reduce ASP.NET Payload with View State Caching

April 21, 2011

Dramatically improve ASP.NET response times by reducing the payload returned to web clients. ASP.NET applications have to deal with View State becoming a performance overhead. And, NCache helps you cache View State on the web servers and send a much smaller payload to the user’s browser containing only a unique token for this ViewState.

Why Cache View State?

View State is an encrypted text string containing the state of web form controls and widgets and is sent to the user’s browser to preserve this state across post-backs. For forms with lot of controls, DataGrid control, or some other complex controls, the View State can become quite large. Here are some reasons why you should consider caching the View State.

View State is large (tens of kb) on large forms & DataGrid
• Large View State slows down page download time
• Large View State slows down post-back request time
• Can cache View State on WFE servers & send only a token to user
• View State cache is distributed to all WFE servers in the farm

How NCache Caches View State?

View State is included in the response of a web request as a hidden form field called __VIEWSTATE. On all page visits during the save view state stage, the Page class gathers the collective view state for all of the controls in its control hierarchy and serializes the state to a base-64 encoded string. Below is an example of a View State.And, since the in-memory cache is distributed and synchronized across all WFE servers, even if the post-back request goes to a different WFE server in the farm than the original server where the View State was created, NCache is able to find the View State value in the cache.


Secondary (L2) Cache with NHibernate – Taking Performance to the Next Level

April 11, 2011

The fast, reliable and mature O/R mapping features that NHibernate comes with provides a remarkable reduction in the overall development cycle. However, as the application grows in complexity and the data on which they thrive upon becomes complex, the generality of such OR mapping engines may lead to various performance and scalability bottleneck. Applications cannot scale linearly with the increasing transactional requirements. Caching is one approach that provides just the right solution to address such issues. Infect the fact that caching does provide a remarkable performance boost to applications performance is recognized by the makers of NHibernate. NHibernate provides some caching infrastructure. By default it provides a standalone InProc (in process) first-level (L1) cache, or session-level cache. However in addition, , NHibernate also supports a second-level cache to be plugged in to exploit the benefits of a sophisticated enterprise-grade caching infrastructure.

Why is Secondary (L2) Cache Required with NHibernate

NHibernate provides a basic, not-so-sophisticated in-process L1 cache out of box. However, it doesn’t provide features that a caching solution must have to have a notable impact on the application performance. Some of the areas which NHibernate lacks in are:
1.Cannot handle ASP.NET worker process recycling: Worker process recycling destroys and recreates the entire cache which has a negative performance impact on your app.
2.Cannot handle ASP.NET web gardens:ASP.NET app runs in multiple worker processes in a web garden configuration. This creates multiple in-process copies of the cache that are not synchronized with each other and lead to data integrity errors.
3.Cannot handle ASP.NET web farms: ASP.NET apps frequently run in web farms for scalability reasons. A stand-alone cache is unaware of multiple servers and cache instances and is not synchronized. This leads to data integrity problems.
4. Cannot handle application scalability:If your application (ASP.NET, .NET web service, distributed app, grid computing app, or an N-tier app) needs to scale up and run on multiple servers, your cache must be distributed. Otherwise, it would lead to data integrity problems.
5.Cannot handle large cache size: In-process cache means it cannot grow more than what your app process can handle. A distributed cache on the other hand can grow in size through distribution.

Thus it surly requires a secondary level caching infrastructure which can not only address the above mentioned problems but also boost its performance.

NCache – Pluggable Cache for NHibernate

NCache provides just the right solution to problems highlighted above. It is extremely fast, enterprise-grade and highly scalable level-2 distributed cache for NHibernate. It is an in-memory object cache for .NET that lets you improve NHibernate performance and scalability without any code change. Some of the immediate benefits are:

• Scale up with Mirrored, Replicated, Partitioned, and Client Cache topologies
• Software appliance for NHibernate (no code change required)
• Database synchronization of cache thru SqlDependency

NCache acts as a 2nd Level distributed cache that lets you improve your application performance and also scales out very nicely when your application needs to scale out. Below are some of the benefits of using clustered sessions:
1.Handles ASP.NET worker processes well: NCache can be used out-of-process. This means multiple ASP.NET worker processes can share a common out-of-process cache. This also addresses worker process recycling problem because the cache is not affected by it.
2.Handles ASP.NET web farms: NCache creates a clustered cache that can live on multiple servers. This allows your ASP.NET apps and .NET web services to run in web farm configuration without worrying about cache synchronization issues.
3. Highly scalable: You have a rich set of clustering topologies (replicated, partitioned, and client nodes) that allows you to scale up to 100’s of web servers in your farm without compromising on performance.
4.No single point of failure (high availability): Clustering the cache allows you to eliminate all single points of failures from your environment. This makes your application highly available.
5.100% Native .NET: NCache is a 100% native .NET product. This means that you can expect us to stay on top of all additions and changes to .NET as compared to a non-.NET solution.


Boost the performance of your .Net app with the help of a distributed cache

April 7, 2011

The classic ASP.NET is stand alone and inProc in nature so it has some limitations. It is good for smaller web farms only but when your app is running in a multi-server environment, it may ends up with some performance and scalability issues. So the use of a third party distributed is recommended as the cache in this case is distributed over multiple servers so it not only boost the performance of the app but also provides the scalable data all the time. Even MicroSoft itself realized this factor and they have introduced MS AppFabric. But when it comes to distributed aching, NCache is a matures and well established distributed cache provider.

NCache is an in-memory object caching solution for .NET applications with real-time data access needs. It not only lets you cache read-only data but also complex transactional data with relationships. As a result, your application can cache most of its data and improve performance. NCache helps remove performance& scalability bottlenecks related to your data storage and databases and scale your .NET and Java apps to extreme transaction processing (XTP)

Alachisoft, the makers of NCache and StorageEdge for SharePoint has recently released the latest version of NCache i.e. NCache 3.8 SP4. In this release, the following features have been added along with the features of earlier edition, NCache 3.8 SP3,

1. String sharing between Java and .NET (vice versa)
2. SQL Cache Dependency Custom Queue/Notification Service

There are three different editions of NCache are available which are,
NCache Express
NCache Professional
NCache Enterprise

You can learn more about the different features of these editions from the edition comparison list.

Download NCache


%d bloggers like this: