Microsoft AppFabric
Dennis van der Stelt
Tellus
Introducing
• Tellus
– Lead generation
– 10k websites
– Looking for developers .NET Geeks

• Dennis van der Stelt
– http://bloggingabout.net/blogs/dennis/
– http://twitter.com/dvdstelt
– dennis@bloggingabout.net
Session objectives
Windows AppFabric

Azure AppFabric
Architectural choices
AppFabric
• Services to build and manage composite
applications
• Formerly known as
– BizTalk Services
– .NET Services
– Velocity
– Dublin
•Workflows
•Monitoring
•Troubleshooting
•Scaling out
•Scripting

•Distributed
•Enterprise scale
•Load balancing
•ASP.NET
Integration

Windows Server
AppFabric

•Connect
•Pass through
•Discoverable
•REST based

•Claim based
•Transformation
•Security Token
•REST based

Azure AppFabric
Windows Server AppFabric

SERVICE & WORKFLOW
MANAGEMENT
Brought my own whiteboard
Hosting services

Host

Client

WCF
Service

Databa
se

What are the current hosting capabilities of services?
Hosting services

Host

Client

WCF
Service
MyApp.exe

#1 – Your own application (Self hosted)
Easiest to deploy
No quality of service

Databa
se
Hosting services

Host

Client

WCF
Service
MyService.ex
e

#2 – Windows Service
Run in background, some monitoring
Hardly any quality of service

Databa
se
Hosting services

IIS

Client

WCF
Service
MyService.svc

#3 – Internet Information Services
Excellent quality of service
Supports only HTTP protocol

Databa
se
Hosting services

WAS

Client

WCF
Service

Databa
se

MyService.svc

#4 – Windows Process Activation Services
Excellent quality of service, multiple protocols
No support for hosting Workflows & true scalability
Enter Dublin…
Hosting services
AppFabric
Workflow

Client

WCF
Service

Databa
se

MyService.svc

#4 – Service & Workflow Management
Quality of Service from IIS/WAS
Hosting scalable workflow & WCF Services
Management Tools
IIS Manager Modules
PowerShell

Services

Persistence

Workflows

Hosting

Monitoring

Caching

Windows Server AppFabric

.NET Framework
Persistence

Runtime Databases

IIS/WAS

Windows Server

Monitoring
Scalable
Share workflow state across machines
AppFabric Hosting

Management
Service

Windows
Service +
AppFabric

Management
Service

Windows
Service +
AppFabric

Persistence
Database

Management
Service

Windows
Service +
AppFabric
Scalable
Retry mechanism for race conditions
AppFabric Hosting

Client
3F2504E0-4F89-11D3-1337-…

Management
Service

x

Management
Service

Windows
Service +
AppFabric

Windows
Service +
AppFabric

Persistence
Database
Windows Server AppFabric

CACHING
Let’s look at a problem
you might experience yourself…
AppFabric Caching

WebServer
Load Balancer

WebServer

WebServer

Databa
se
AppFabric Caching

WebServer
Load Balancer

WebServer

WebServer

x
Databa
se
AppFabric Caching

WebServer
Load Balancer

WebServer

WebServer

Solution is sticky sessions…

Databa
se
We’ll have uneven load balancing,
we might loose sessions,
etc…
AppFabric Caching

WebServer
Load Balancer

WebServer

Databa
se

WebServer

Another solution is using DBMS to store sessions
Doesn’t scale well,
we’ll have a performance bottleneck.
And clustering is costly and
fault sensitive!
What is AppFabric Caching?
• An explicit, distributed, in-memory application cache for
all kinds of data (CLR objects, XML, Binary data, etc.)
– Flows "memory" across machines into a unified cache
Clients can be spread
across machines or
processes

Unified Cache View

Clients Access the
Cache as if it was a
large single cache

Cache Layer
distributes data
across the various
cache nodes
AppFabric Caching

WebServer
Load Balancer

WebServer

WebServer

Databa
se
Why Velocity?
* Share data across applications
No more sticky routing

* Peformance
Operation
Read 2k
MSDN Forums

Throughput

Latency

30,000 / sec

3 – 4 ms

Write 2k
18,000 / sec
5 Velocity Servers, 40GB Cache
98% of all calls to database come from cache
Result is from 60% load on SQL Server, down to 2%
* Scale out

3 ms

Operation

Throughput

Read 2k

1

30,000 / sec

Read 2k

2

58, 600 / sec

Read 2k

Velocity

Servers

3

85, 500 / sec
Basic terminology in Velocity
•
•
•
•
•
•
•

Cache host
Cache cluster
Cluster configuration storage
Machine 1
Machine
Machine
Named cache
2Cache
2Cache
Cache
Cache
host A
host B
host C
host D
Region
Named cache : Product catalog
Named cache : ShoppingCart
Cache item
Tags
Region A
Working with Velocity
// Create instance of CacheFactory, which reads app.config
DataCacheFactory factory = new DataCacheFactory();
// Get a named cache from the factory
DataCache cache = factory.GetCache("default");
// Cache.Put(string key, object value)
cache.Add("SDN", new SDNSession());
// Cache.Get(string key);
var meeting = (SDNSession)cache.Get("SDN");

// Via indexers is also an option
cache["what"] = new Object();
Object o = cache["what"];
Tags
var starWarsTag = new DataCacheTag("StarWars");
var tags = new List<DataCacheTag>();
tags.Add(starWarsTag);
tags.Add(new DataCacheTag("Force"));
tags.Add(new DataCacheTag("Sith"));

cache.Add("MyKey", "A New Hope", tags, "StarWarsRegion");
var result =
cache.GetObjectsByTag(starWarsTag, "StarWarsRegion");

foreach (var item in result)
{
Console.WriteLine("{0} has value of {1}",
item.Key, item.Value);
}
Optimistic locking
DataCacheItemVersion versionWillChange;
DataCacheItemVersion versionWithError;
// First get the current version 2 times
cache.Get("MyKey", out versionWillChange);
cache.Get("MyKey", out versionWithError);

// We change the key, version hasn't changed in Velocity yet.
cache.Put("MyKey", "MyNewValue", versionWillChange);
// Version has changed with previous update, this will #fail
cache.Put("MyKey", "MyErrorValue", versionWithError);
Pessimistic locking
DataCacheLockHandle lockHandle = null;
DataCacheLockHandle secondLockHandle = null;
// Lock our object
cache.GetAndLock("MyKey", new TimeSpan(0, 0, 10), out
lockHandle);

// This will still work
string result = (string)cache.Get("MyKey");
// Try to lock for 2nd time -> #fail
cache.GetAndLock("MyKey", new TimeSpan(0, 0, 10), out
secondLockHandle);
// This will break the lock!!!
cache.Put("MyKey", "MyNewValue");
Notification callback
DataCacheOperation filter = DataCacheOperation.AddItem;
cache.AddItemLevelCallback("MyKey", filter, callback);
cache.AddRegionLevelCallback("Region", filter, callback);
cache.AddFailureNotificationCallback(failCallback);
cache.Add("MyKey", "MyInitialValue");
public static void callback (string myCacheName,
string myRegion, string myKey,
DataCacheItemVersion itemVersion,
DataCacheOperation OperationId,
DataCacheNotificationDescriptor nd)
{
//display some of the delegate parameters
Console.WriteLine("Region : " + myRegion);
Console.WriteLine("Key
: " + myKey);
}
ASP.NET Session integration
• SessionStoreProvider class
– Plugs into ASP.NET Session store
– Stores session state in Velocity

• Scale
– Session information available at all ASP.NET
Nodes

• High availability
– Session data is backed up on addditional
machines
– Resilient to machine or process failures
Azure AppFabric
• Webbased services
• Yes, in the cloud!
• Allow you to easily connect applications
Azure AppFabric

SERVICE BUS
Azure Service Bus
Azure Service Bus

Let’s open a port
and do some
forwarding
Azure Service Bus

Oh, what about
NAT, Proxies, etc?
Azure Service Bus

Service Bus
Azure Service Bus
App
Service Bus
Features
• Services discoverable through SB url
• Full duplex channels supporting
bi-directional communiction
• Full-duplex p2p sessions
– with network-boundary traversal create direct
end-to-end connectivity through NAT

• Multiple publishers & subscribers
• REST based (non .NET platform support)
Azure AppFabric LABS
http://portal.appfabriclabs.com/
Azure AppFabric

ACCESS CONTROL
Azure Access Control

Service Bus

Federated Identity
Azure Access Control

Service Bus
Access
Control

ID
Azure Access Control

Service Bus
Access
Control

App

ID
Access Control
• Two new protocols
– Created by Microsoft, Google, Yahoo, etc
– Oauth WRAP & SWT
– Authentication in HTTP Headers
– Usable even via JavaScript
– Ready for Geneva/WIF
Access Control
•
•
•
•

The future
No WS* available yet… or no longer?
CardSpace
Support for other web identity providers
– Windows Live
– Google
– Yahoo
– OpenId
Azure Pricing
• Access Control
– $1.99 / 100K transactions

• Service Bus Connections
– $3.99 per connection
– $9.99 for a pack of 5 connections
– $199 for a pack of 100 connections

• Data Transfers
– $0.10 in / $0.15 out per Gigabyte
Example (real world) architecture
Example architecture

SQL

Website
Example architecture

SQL

Website
“Server Busy”
Example architecture

Website
SQL

Website
Website

N
L
B
Example architecture

Website
SQL

Website

“Timeout”

Website

N
L
B
An important change was made…
Example architecture

Isolated servers

One way!
SQL

Sync
Framework

Website
Website
Website

Prepublished Databases using SQL Express

N
L
B
How to submit state changes to backend?
Example architecture

Website
Website

Sync
Framework

Website
AppFabric Hosting
Backend
WCF
Service

MSMQ

Cache

SQL

N
L
B
Example architecture
SB

AC

The near future?
REST Based Service Layer
Website
Website

Sync
Framework

Website
AppFabric Hosting
Backen
d
Servic
e

MSMQ

Cache

SQL

N
L
B
Summary
•
•
•
•

Different AppFabric components
Difference Azure & Windows AppFabric
New architectural choices
Do you see benefits or opportunities?
questions
Resources:
• .NET Magazine maart 2010 & SDN Magazine
• http://www.microsoft.com/windowsazure/
• http://bit.ly/1P6f5D
• http://bloggingabout.net/blogs/dennis/

App fabric introduction