2. The Need For Speed
A Developer’s Guide to
Distributed Caching with
Velocity Windows Server AppFabric
Phil Pursglove
@philpursglove
http://philpursglove.blogspot.com
3. Agenda
• What is AppFabric?
• Why a Distributed Cache?
• Configuring a client
• Configuring a server
• Managing a cache
• Concurrency
• High availability / load balancing
5. What is AppFabric?
• A combination of two projects:
– A distributed cache
• One logical cache shared across a number of physical servers
• Already being used by:
– MSDN Forums. Xbox Live, MSN
• An ASP.NET session state provider
• In .NET 4.0, a cache provider
– A workflow host
• V1 released to web 4th June
– Servers must be .NET 4.0, clients can be .NET 3.5/4.0
6. Why a Distributed Cache?
• Bigger cache
– Many physical servers contribute to one
logical cache
• Increased throughput
– Many servers available to fulfil requests
• High availability
– Multiple servers = fault tolerance
7. What Data Can I Cache In
AppFabric?
• Any serializable .NET object
– Reference Data (Shared Read)
• e.g. Product categories
– Activity Data (Exclusive Write)
• e.g. Shopping Basket
– Resource Data (Read and Write)
• e.g. product stock data
8. Configuring the AppFabric Client
• Two assembly references to add:
– Microsoft.ApplicationServer.Caching.Client.dll
– Microsoft.ApplicationServer.Caching.Core.dll
• Cache hosts can be hard-coded or in
web.config/app.config
• Clients
– Routing vs Simple
– Local caches
9. Using AppFabric
• Add/Remove
• Concurrency
– Optimistic
• Version-based
– Pessimistic
• Lock-based
• Tags
• Regions
– Live inside a cache
– Use for a set of logically related cached items e.g. Products
– Tie a group of cached objects to a specific node
10. Configuring an AppFabric Server
• Cluster configuration can be held:
– On a network share (XML Provider)
– In a SQL Server DB (SQL Provider)
• Integrated Security only
– AppFabric servers must be inside a domain
11. Managing An AppFabric
Cluster
• Powershell integration
– Can start/stop a whole cluster or individual
servers
– Create new named caches
• But not regions
– Get cache statistics
• MDCAdmin tool
– WPF app sitting on top of Powershell
12. Summary
• AppFabric brings the cloud inside your
organisation!
• Distributed caching is a powerful way to
bring scalability to your applications
– Throughput
– High availability