Monday, December 31, 2012

AppFabric Caching: Not noise, but a flawless initiative

Application state  is one of the  most underrated aspect of any software development. Developers want to solve problems quickly enough and ship the next generation of software into the market without ever considering how maintaining application state cross servers or domain could be a plus, one of the most demanding software success criteria of today. Because software engineers are so much in haste and there are several pushes from top management, engineers sincerely bend the rules of good principles and shippable product that meets the market demand. How we manipulate and use data should be the paramount goal of any successful application, Are we doing it? how do we fail over? what happens if a sever is down? Will my session pick-up from where it stopped? Is the appkication stateful or stateless? How do we Increase the capacity of the software without changing any code? Can we administer our cache as part of infrastructural benefits?

Every software application conduct the activity of data processing at one particular time or the other. Because software components need to process data to function efficiently, some of these data should be readily available to the software. In fact, data processing brings more sense to the use of computers. Will computer be meaningful without data processing? Despite differences in software platforms, operating systems, user base, software application tend to face the same problem over the cause of time, Data!

Different types of application consumes/dispense data using varieties of formats, platforms, serializations. The realization that bringing data closer to where it is needed, has gainfully helped several applications in the area of performance.

Enter enterprise computing (The problem statement)
Enterprise development is more focused on efficient data usage. Software Applications commanding thousands/millions of user base falls under this category, so as software application that require intensive data processing. Banking software, media data processing/CMS, financial applications, ERPs, e-commerce, m-commerce and pure engineering based software applications, belong to this category.

With the growing number of complexities in today's business and engineering world, data  need to be safe, efficiently delivered, durable and highly available. We need to access and process data when it is required. Without heavy reliance on the database system/and other data sources, data can span multiple computers in the same co-location, and can also span multiple disparate systems to form a cluster of data which are readily available for the enterprise.

It is now becoming more challenging for the enterprise to set-up the infrastructure for proper real time data manipulation, relational database is losing its popularity and paving ways for NoSQL initiatives and memory databases which are now gaining the momentum. Software need data to be its closet allies and not travel across tiers and layers before data can be reached. With this known challenges, if you are using the right tool and encouraging your development team to focus more on data efficacies, then you are one step close to high availability of data and prevention of data loss.

AppFabric Caching, once code named Velocity, is a Microsoft initiative to solve the problems faced by distributed computing, it enables enterprise development to cater for heavy throughput which is one of the demanding factors of todays successful businesses. Efficient use of data is the bedrock of any per formant application and the ability to process these data using good principles without painfully stressing out data sources would give you a first class win in today's competitive and aggressive market place.  whether you are operating a software shop, or you are buying from a software shop, or you have your own in-house/outsourced developments or you want to build future application which can scale across multiple computers (This includes mobile, web and desktop applications).  The caching solution brought to the table by Microsoft owns AppFabric should not be underrated. 

With the growing number of Microsoft enterprise product stack, AppFabric caching is an addition to the family which we get for free and also builds on-top of existing technologies. It enable clusters of cache servers to act as a single application cache, by allowing a distributed caching systems which scales across multiple caching cluster through a single cache system point (Referred as the entry point). AppFabric can automate installation of itself on any other computer  without user interaction, if the current appFabric caching service need to scale to another computer using the same configuration, you can easily run a command line task which will process the installation while also suppressing any GUI messages.

Good bye sticky session welcome AppFabric
Asp.NET begins a session throughout the duration of connection to the server using either in process state provider, out process state provider or SQL Server sate provider, these three are the default state session store supported by ASP.NET out of the box. User Session can become idle if there was no interaction with the web server within a duration. Each time a user initiates a requests to the server, the users session is renewed and all user objects that are in that session gets automatic promotion to the next expiry time. session provides each connected client with a unique session id which is stored in the client cookie for request and response identification, although can operate in the  a cookie less session mode, this is not so friendly because of the generated url. Cookie less session adds the session id to the url using the following format: ID here)/home.aspx 

AppFabric caching builds untop of existing technology and provides for a high end state store, which does not only leverage on high availabilities of data but readily available at all time. By adding configurations (for xml configuration) or using code based configuration, and also using the AppFabric session state provider, you will have appfabric readily available to you. Sticky sessions are more useful for small applications whose user based are quite small and does not store heavy data into the session. Because sticky session makes use of memory web server memory, then that means the session cannot scale into other computer, there are no ability to add new cluster for higher throughput. If the web server is down, the session goes dow.

Caching Advantage
The AppFabric caching is readily available for use in any .NET languages, each caching sever is hosted using windows service, you can run commands on the service using windows power shell using AppFabric Cmdlets. There is also an open source software out there, the AppFabric management admin tool which you can leverage to administer your cache clusters.

I started using the caching service since it was code named Velocity (a beta product then in 2009), the latest version available can be used in production ready environment. Setting up a cache server couldn't have been more easier with AppFabric caching, the relevant components are: the cache server (a windows 7, 2008, 20012 server), the cache host (A windows service) and the cache configuration which is a per cluster configuration.

Although, cache configurations can be located in a shared folder using an XMl file format, or using Microsoft SQL server, or using a custom provider. Cache clients  need to reference AppFabric dlls to communicate with the cache clusters. Also cacheable objects need to be marked serializable or be marked with the DataContract attribute and all its serializable memebers marked with DataMember attribute.

I will be providing another post on how to use and setup basic AppFabric cluster.


Rajanikanth said...

Excellent post. waiting for another article on how to configure app fabric.

Ahmed Salako said...

Thanks Raj. How is it going on your side.

Rajanikanth said...

Thanks for asking. Still on hunt.