Need for AppFabric

As a trend Microsoft has always tried to come up with kind of programming models that are focused on faster business logic development thereby moving away the developers from intrinsic implementation details. Ideally developers shouldn’t spend their time creating infrastructure. The people who write business applications should focus primarily on creating business functions for their users and not infrastructure. Whatever infrastructure is required should be provided by the platform they’re building on.

With .Net 3.0 Microsoft came out with two new programming paradigms that are modeled to assist the developers to implement business logic more easily than ever with Windows Communication Foundation and Windows Workflow Foundation. WCF took SOA and interoperability to next level and WF provided platform for authoring and execution of long-running workflows. Till .Net 3.5 developers needed to write their own infrastructure stuffs.

Microsoft in its attempt to provide a platform for better application infrastructure rolled out Windows AppFabric. By providing a set of extensions to Windows Server, Microsoft aims at making it easier for Windows developers to create faster, more scalable, and more manageable applications. To come up with terms of the requirements of a complete ecosystem MS released two application development platforms: -

  • Windows Server AppFabric: This provides comprehensive infrastructure based on IIS 7.0 & WAS based platform to provide caching and WCF/WF services. AppFabric comes with limitation of targeting only IIS 7.0 and above. WAS provided several features that were always present on the wish list of the developers who work around the Service-oriented Architecture (SOA). Features like Message-based Activation, capability to recycle worker process, application management and easy configuration.
  • Windows Azure AppFabric: This provides a comprehensive cloud middleware platform for developing, deploying and managing applications on the Windows Azure Platform. It delivers additional developer productivity adding in higher-level Platform-as-a-Service (PaaS) capabilities on top of the familiar Windows Azure application model.

AppFabric is not the same “app server” both for Windows and the Cloud as there is absolutely no feature parity between the two. Windows Server AppFabric provides service hosting and caching, while Azure AppFabric provides Service Bus and Access Control. The two are "AppFabric" in name only. In this article we shall only cover Windows Server AppFabric. The idea of this article is to get started on configuring & understanding Windows Server AppFabric.

Introduction to Windows Server AppFabric

With the release of Windows Server AppFabric the IIS7 capabilities have evolved to introduce enhanced application hosting and administration tools for services developed on WCF and WF programming platforms. Along with this AppFabric introduced distributed cache capability which provides distributed in-memory caching of frequently used data across a cluster of machines. Advanced and smart routing algorithm with data replication promises high availability and runtime scale up and scale down capabilities. However these features were intended to off-burden the developer from consideration like deployment, management and custom monitoring solutions. Host activation and configuration of State persistence was still required to be accomplished by the developer itself.

Windows Server AppFabric Installation Requirements

Windows Server AppFabric can be installed on the following operating systems:

  • Windows 7
  • Windows Server 2008 R2
  • Windows Server 2008 Service Pack 2
  • Windows Vista Service Pack 2

Supported Architectures for AppFabric

  • 32-bit (x86)
  • 64-bit (x64)

Hardware requirements

  • Minimum Hard Disk Space: 2GB
  • Computer with an Intel Pentium-compatible CPU that is 1 GHz or faster for single processors; 900 MHz or faster for dual processors; or 700 MHz or faster for quad processors.

Prerequisite Software

All features of Windows Server AppFabric require a .NET Framework version to function. The specific version required is dependent on which features you wish to use:

  • Hosting services require Microsoft .NET Framework 4
  • Hosting administration requires Microsoft .NET Framework 4
  • Caching service requires Microsoft .NET Framework 4 and optionally requires Microsoft .NET Framework 3.5 Service Pack 1
  • Cache client requires either Microsoft .NET Framework 4 or Microsoft .NET Framework 3.5 Service Pack 1
  • Cache administration requires Microsoft .NET Framework 4
  • Internet Information Services (IIS) 7
  • Internet Information Services (IIS) 7 Hotfix #980423
  • IIS Web Deployment tool
  • Windows PowerShell 2.0 (final version) (this is not required for Windows 7 and Windows Server 2008 R2 users)

 

Configuration and setup

Get AppFabric

Go to http://msdn.com/appfabric and download it directly or just do it with the Web Platform Installer. Run the installer and select AppFabric Cache. If you’re on Windows 7, you’ll want to install the IIS 7 Manager for Remote Administration which is a little plugin that lets you manage remote IIS servers from your Windows 7 machine.

Install AppFabric

Open the installation wizard for initial installation running the file downloaded in the previous step. Don’t forget to right click and run as administrator step.

The setup window will pop up, and walk you through a small wizard. You can setup AppFabric Hosting Services for Monitoring, Workflow Persistence and Caching Services. Wizard for setup is shown below: -

Make sure to add the Caching Services, Cache Client and Cache Administrator for Cache services and add Hosting services for hosting services.

Hosting / Cache Services

When we complete the installation of Windows Server AppFabric three supporting Windows Services get installed which are: -

  • AppFabric Caching Service: – AppFabric Caching service gets installed on the servers that are chosen to work as cache providers.
  • AppFabric Event Collection Service: – Based upon the configured monitoring level, its role is to gather WCF and WF instrumentation events emitted by the .NET Framework runtime into an Event Tracing for Windows (ETW) session. The Event Collection service then stores these events in the monitoring database. AppFabric uses event data to aggregate information about overall status of applications to assist in performance monitoring and troubleshooting.
  • AppFabric Workflow Management Services: – The Workflow Management service activates a workflow service instance in an instance store when the instance is eligible to be activated. The Workflow Management service retrieves commands from a message queue that is written to by an instance control provider, executes the commands, and then deletes commands from the queue if the command execution is successful.
Configure Hosting Services
  • On the Configure Hosting Services page, you can configure AppFabric monitoring and persistence services. By default the Event Collector service is NT Authority\LocalService you can change it as it is done in following snap shot.
  • Check monitoring and persistence checkbox to configure these services.

For monitoring configuration

  • Select System.Data.SqlClient as Monitoring Provider and Click configure button to Configure SQL Monitoring Store.
  • Select the Register AppFabric monitoring store in the root web.config check box to register the monitoring store identified by the connection string.
  • You can also check the Initialize the Monitoring Store check box to initialize the monitoring database identified in the connection string.
  • Click OK to apply the selected settings for the AppFabric Monitoring Store.

For Persistence configuration

  • On the Configure Hosting Services page you can also set AppFabric persistence configuration by selecting the Set persistence configuration check box.
  • Under the list of all available persistence providers choose the persistence provider you would like to configure; for example, sqlStoreProvider. Then click Configure.
  • Check the Register AppFabric persistence store in the root web.config check box to register the persistence store identified by the connection string
  • Type in or select existing SQL database to configure the AppFabric Persistence connection string and to initialize the persistence database.
  • Click OK to apply the selected settings for the AppFabric persistence store.

Configure Cache Services

Caching Service can be configured with Database as well as XML

  • Check Set Caching Service Configuration.
  • Select SQL Server Store Provider as option for Caching service configuration provider.
  • Click on configure to create and register AppFabric Caching Service configuration database with MSSQL Server.
  • Choose the Server you want to register AppFabric Caching Service with.
  • Check the Create AppFabric Caching Service configuration database to create DB with the name provided.

Configure AppFabric Cache Node

Here we can specify on which ports the Cache Nodes are available.

 

Understanding Caching & Hosting Services

Caching Services

The cache provides a distributed, in-memory application cache for developing extensible, available, and very high performance applications. Any serializable CLR object created with .NET languages such WCF / ASP.NET / WF can use the distributed cache to Get/Put items from/into the cache. Developers use the Microsoft.Data.Caching APIs to interact with the cache service. As shown below we can make a distributed cluster of machines to provide a unified view of cache.

Distributed Cache Service runs across multiple machines and forms a tight cluster offering data replication and data consistency across multiple machines. The Distributed Cache Service can run on the same machine as the application code or run in a remote dedicated farm of machines.

Logical Hierarchy of AppFabric caching consists of Machine -> Cache Host -> Named Caches -> Regions -> Cache Items -> Objects

  • Machine are servers which run Cache Hosts
  • Cache Hosts are the physical processes hosting AppFabric Caching instance.
  • Named Caches are the logical entities which can span across machines
  • Regions are physically co-located Container of Cache Items and they may be implicit or explicitly created
  • Cache Item are the key, Payload (Object) and they have associated Tags, TTL, Timestamps, Version
Hosting Services(WCF and WF) in AppFabric

A workflow service is a combination of a WCF and WF hosted on IIS and monitored and administered using AppFabric dashboard that is built right into the IIS Management Console.

Windows workflow foundation (WF) provides developers a framework where service logic can be provided declaratively. WF is a set of tools for declaring your workflow (business logic), activities to help define the logic and control flow, and a runtime for executing the resulting application definition. In short, WF is about using a higher level language for writing applications, with the goal of making developers more productive, applications easier to manage, and change quicker to implement.

The WF runtime executes workflows, provides services and features important when writing application logic such persistence of state, bookmarking and resumption of business logic. This leads to process agility enabling scale up and scale out of business processes.

Monitoring and Troubleshooting

AppFabric provides visibility into running WCF and WF services. The application emits WCF and WF monitoring and troubleshooting events and the Event Collector Service uploads events to a Monitoring Store.

  • We can get overall statistics such as # of errors, average response time per service, etc.
  • We can get individual events correlated across deployed services, messages and workflow activities.

Above image shows IIS integration for AppFabric Monitoring. AppFabric provides an out-of-the-box SQL based Monitoring Store, with support for other database technology via an extensible provider model.

 

Next Steps

After downloading, configuring and understanding AppFabric, it is time to get hands dirty on code. Microsoft has provided with really exhaustive list of samples which can be downloaded from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=DB665003-44C5-4E25-9CE1-C53512F24492 and tested. They cover almost all the aspects of Caching & Hosting.

Share and Enjoy

  • Facebook
  • Google Plus
  • Twitter
  • LinkedIn
  • RSS
Tagged with:
 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>