velocity - edge ug
DESCRIPTION
TRANSCRIPT
![Page 1: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/1.jpg)
The Need For Speed
A Developer’s Guide to
Distributed Caching with
Velocity AppFabric
Phil Pursglove
http://philpursglove.blogspot.com
http://www.philippursglove.com/Velocity
http://twitter.com/philpursglove
http://slideshare.net/philpursglove
![Page 2: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/2.jpg)
Agenda• What is AppFabric?
• Why a Distributed Cache?
• Configuring a client
• Configuring a server
• Managing a cache
• Concurrency
• High availability / load balancing
![Page 3: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/3.jpg)
Caching Review• .NET 1.1
– ASP.NET Cache
• .NET 2.0
– SqlCacheDependency
– Enterprise Library Caching Application Block
• .NET 4.0
– System.Runtime.Caching assembly
– AppFabric
![Page 4: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/4.jpg)
Cache-Aside• The cache-aside pattern
– See if the item you want is in the cache
– If it isn’t (a cache miss),
• Go and get it i.e. from the DB
• Put it in the cache
– If it is,
• Cast it to the desired type and return it
![Page 5: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/5.jpg)
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
• A session state provider
• In .NET 4.0, a cache provider– A workflow host
• Beta 2 released 1st March 2010– Servers must be .NET 4.0, clients can be .NET 3.5/4.0
![Page 6: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/6.jpg)
Why a Distributed Cache?
• Bigger cache
– Many physical servers contribute to one
logical cache
• High availability
– Multiple servers = fault tolerance
• Increased throughput
– Many servers available to fulfil requests
![Page 7: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/7.jpg)
Terminology
• Cluster
– A number of servers running Velocity
– Not related to Windows clustering
• Cache
– A named cache on a cluster
• Region
– A named part of a cache associated to a
single server
![Page 8: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/8.jpg)
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
![Page 9: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/9.jpg)
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
![Page 10: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/10.jpg)
Using AppFabric
• Add/Remove
• Concurrency– Optimistic
– Pessimistic
• Regions– Live inside a cache
– Tie a group of cached objects to a specific node
– But adds extra options (Tags) for retrieving the object
![Page 11: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/11.jpg)
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
![Page 12: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/12.jpg)
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
![Page 13: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/13.jpg)
Summary
• Velocity is going to be great
… in v2
• v1 is worth looking at as a session
state provider
– The end of sticky load-balancing
![Page 14: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/14.jpg)
Questions?
http://philpursglove.blogspot.com
http://www.philippursglove.com/Velocity
http://twitter.com/philpursglove
http://slideshare.net/philpursglove
![Page 15: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/15.jpg)
References• Documentation on MSDN
– http://tinyurl.com/msdnappfabric
• Velocity team blog – http://blogs.msdn.com/velocity
• AppFabric blog for IT Pros– http://blogs.technet.com/appfabric/
• TechEd videos– http://tinyurl.com/velocityteched
• Mix 09 video– http://tinyurl.com/velocitymixvideo
• Mix 10 video– http://tinyurl.com/velocitymix10video
• ARCCast Video– http://tinyurl.com/velocityscotthavideo
• ScottHa on Velocity– http://tinyurl.com/velocityhanselminutes
![Page 16: Velocity - Edge UG](https://reader036.vdocument.in/reader036/viewer/2022081820/545826d8b1af9fc15d8b49ab/html5/thumbnails/16.jpg)
References• AppFabric coverage on StackOverflow
– http://tinyurl.com/stackoverflowvelocity– http://tinyurl.com/stackoverflowappfabric
• DotNetRocks– http://tinyurl.com/dotnetrocksappfabric
• Other .NET distributed caches– NCache - http://tinyurl.com/ncache– Memcached - http://tinyurl.com/smoe– Oracle Coherence – http://tinyurl.com/oraclecoherence– SharedCache – http://codeplex.com/sharedcache
• Extensions Project– http://tinyurl.com/mscacheext
• Admin Tool– http://mdcadmintool.codeplex.com/