Your SlideShare is downloading. ×
Scale Your Data Tier with Windows Server AppFabric
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Scale Your Data Tier with Windows Server AppFabric


Published on

Published in: Technology

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide
  • In the future we will be bringing these capabilities to the cloud and bringing some of the cloud capabilities such as service bus and access control to the on-premise server solution as well.
  • Transcript

    • 1. Scale Your Data Tier withWindows Server AppFabricChris Dufour, ASP MVPSoftware Architect,
    • 2. AgendaThe ProblemA Possible SolutionNew PossibilitiesWhat to do next
    • 3. SimpleDo the simplest thingthat will possibly work
    • 4. ScalabilityAble to support therequired quality ofservice as the systemload increases-Wiktionary
    • 5. Typical Web Architecture•Need to get routed tosame machine (i.e. stickysessions)Users•Each machine round tripsfor data•Data that is cached isstored in the memory ofone serverWebTier•CPU and disk can getsaturated due to traffic•Service access is slowDataTier
    • 6. Web ExplosionDatabaseIIS/ASP.NETApplicationWebSite’s tooslow!!Database ishot!!Where didmyshoppingcart go?IIS/ASP.NETApplicationIIS/ASP.NETApplicationServers arecrashingServices areslow
    • 7. AgendaThe ProblemA Possible SolutionNew PossibilitiesWhat to do next
    • 8. Data Near ProcessingDatabaseSmart Client BrowserCacheCacheCacheCacheCache
    • 9. Good but… Cache is scoped to machine / process◦ Machines die◦ Processes recycle Cache memory is limited
    • 10. What if? You could have as much cache as youwanted? You could share a giant cache acrossservers, services and even clients? What if this was something you couldsimply add to the platform for1free?1Some features may requirecertain editions of WindowsServer
    • 12. Unified Cache ViewWhat is AppFabric Caching? An explicit, distributed, in-memoryapplication cache for all kinds of dataCaching clientscan be acrossmachines orprocessesClients Accessthe Cache as if itwas a largesingle cacheCache Layerdistributes dataacross thevarious cachenodes
    • 13. AppFabric Cache•No need for sticky sessionsUsers•Cached data available to allserversWebTier•Multiple machines meansscale and high-availability•Lots of cache memoryCachingTier•Reduces load on database•Duplicate Service CallseliminatedDataTier
    • 14. Data Distribution - Partitioned Cache… Web TierCacheTierCacheServiceCacheServiceCacheServiceA C EDB G IHFASP.Net AppCaching ClientASP.Net AppCaching ClientASP.Net AppCaching ClientAC ED BGI HF Scale on Data Size◦ More machines => More memory to cache Scale on Cache Throughput◦ More machines => keys distributed across more machines => betterthroughput
    • 15. Scale Test OutputLoadThroughputLatency1 Cache ServerAs load increases,throughput failsto scalelatency increasesCachingTier
    • 16. Add a Second Cache ServerLoadThroughputLatencyLoad MaxThroughputincreasesLatency decreasesCachingTier
    • 17. Add a Second Cache ServerLoadThroughputLatencyCachingTier
    • 18. Associated Press Caches metadataand news Serves 16 millionhits per day Increased theamount of cacheddata 6 times.
    • 19. System.Web.Cache
    • 20. AppFabric DataCache
    • 21. CachingServiceCachingServiceCachingServiceConfiguration StoreInstallAppFabricCopy Client DLLs…Application Application Application<hosts><host name="BL1CDB8083714“cachePort="22233"cacheHostName="DistributedCacheService"/>…..</hosts><localCache isEnabled=“true" ../><security … />Caching AccessLayerCaching AccessLayerCaching AccessLayer.NET 3.5 SP1 OR .NET 4ConfigureAppFabric.NET 4Update Web.configDeployment
    • 22. Usage Pattern – Cache Aside(Explicit Caching)// Read from CacheToy toyObj = (Toy)catalog.Get("toy-101");ApplicationCachingServiceDatabase// If Not present in the cacheif (toyObj == null){// Read from backend..toyObj = ReadFromDatabase();// Populate Cachecatalog.Put("toy-101", toyObj);return toyObj;}Caching AccessLayer
    • 23. Administration PowerShell cmdlets are used to administerthe cache cluster Rich set of cmdlets for◦ Cache cluster management◦ Cache creation and monitoring
    • 24. Hello AppFabric Cache
    • 25. Using PowerShellRemember – PowerShell can alsobe called from .NET Code!
    • 26. Security Domain Based Security Option◦ Domain Account / Local Account basedAuthentication◦ Only authorized servers can join the cluster◦ Only authorized clients can connect to thecluster Transport Level Security◦ Turn on/off Signing or Encryption Can turn off Cache Security◦ Use Firewalls, IPSec, VLANs to protect cachegrant-cacheallowedclientaccount RedDomainMachine1$grant-cacheallowedclientaccount RedDomainJohn
    • 27. Logical Hierarchy Machine Host◦ Physical processes hostingAppFabric Caching instance. Named Caches◦ Can span across machines◦ Defined in the configuration file Regions◦ Physically co-located Container ofCache Items◦ May be implicit or explicitly created Cache Item◦ Key, Payload (Object ), Tags, TTL,Timestamps, VersionRegionsRegion AKey Payload Tags121 xxxx “Toy” “Child”123 yyyy “Toy” “Chair”..AppFabricCachingServiceNamed Cache : Product CatalogNamed Cache : Electronics InventoryAppFabricCachingServiceAppFabricCachingServiceAppFabricCachingService
    • 28. AppFabric Caching API// Create instance of cachefactory (reads appconfig)DataCacheFactory fac = new DataCacheFactory();// Get a named cache from the factoryDataCache catalog = fac.GetCache("catalogcache");// Simple Get/Putcatalog.Put("toy-101", new Toy("Puzzle", .,.));// From the same or a different clientToy toyObj = (Toy)catalog.Get("toy-101");// Region based Get/Putcatalog.CreateRegion("toyRegion");// Both toy and toyparts are put in the same regioncatalog.Put("toy-101", new Toy( .,.), “toyRegion”);Catalog.Put("toypart-100", new ToyParts(…), “toyRegion”);Toy toyObj = (Toy)catalog.Get("toy-101“,"toyRegion");
    • 29. Access APIs – Tagging ItemsTag hotItem = new Tag("hotItem");catalog.Put("toy-101", new Toy("Puzzle"),new Tag[]{hotItem}, “toyRegion”);catalog.Put("toy-102", new Toy("Bridge"), “toyRegion”);// From the same or a different clientList<KeyValuePair<string, object>> toys =catalog.GetAnyMatchingTag("toyRegion", hotItem);
    • 30. Types of DataReference Activity ResourcePrimary Read Only Read-Write NotsharedRead-Write, SharedCatalog Data Shopping Cart Auction Data/SeatAssignmentWeb TierDistributed CacheShopping CartGroceryCatalogGroceryInventoryGrocery Shop
    • 31. ApplicationApplicationAppFabric Caching ClientReference Data – Performance Catalog data doesn’t change often Unnecessary network cost to access from different machines Solution – Local CachePut(K2, v3)Routing TableCache2Cache1Primary for K2,V2K2, V2Primary for K1,V1K1, V1Cache3Primary for K3,V3K3, V3AppFabric Caching ClientLocal CacheRouting TableK2,V2Get(K2)Get(K2)K2, V3
    • 32. Reference Data – Bulk Get Bulk Fetch from region◦ 200-300k ops per second◦ Fewer network callsCatalog.BulkGet(new List<string>(){“toy-101”, “toy-102”} ,“toyRegion”);
    • 33. Activity Data – Session Integration…Session Statestored inAppFabricCachingCacheServiceCachingServiceLoad Balance RequestsNo more sticky routingCachingServiceScale yourSession StoreDynamicallyHighlyAvailableDrop in AppFabricCachingSessionStoreProviderAllows session state to be shared amongst multiple applicationsApplicationCaching AccessLayerApplication ApplicationCaching AccessLayerCaching AccessLayer<sessionState mode="Custom“customProvider="SessionStoreProvider"><providers><add name="SessionStoreProvider"type=“Microsoft.Data.Caching.DataCacheSessionStoreProvider,ClientLibrary“cacheName="<YourNamedCache>"/></providers></sessionState>
    • 34. ApplicationApplication(K2, V2)Cache2Cache1 Cache3Primary forActivity Data - AvailabilityGet(K2)Primary for Primary forK3, V3AppFabric Caching ClientRouting TableK2,V2PUTSecondary forK2, V2K1, V1Secondary forK3, V3Secondary forK1, V1AppFabric Caching ClientRouting TableK2, V2Replication AgentK2, V2
    • 35. Resource Data - Optimistic Locking GetCacheItem returns a version object Every update to an object internally increments its version Supply the version obtained along with the Put/Remove Put/Remove will succeed only if the passed in version matchesthe version in the cacheVersion Based UpdateTime Client1 Client2 (Different Thread orprocess)T0 CacheItem item =catalog.GetCacheItem(“PlayerRegion”, ”Zune”);CacheItem item =catalog.GetCacheItem(“PlayerRegion”,”Zune”);T1 ((ZuneObject)item.Object).inventory --;((ZuneObject)item.Object).inventory--;T2 catalog.Put(“PlayerRegion”,“Zune”,item.Object,item.Version);T3 catalog.Put(“PlayerRegion”,“Zune”,item.Object,item.Version);// Version mismatch// Client must retry againTwo clients access the sameitemBoth update the itemSecond Client gets in first;put succeeds because itemversion matches; atomicallyincrements the versionFirst client tries put;Fails because the versionsdon’t match
    • 36. K1Resource Data - Pessimistic Locking Take locks on non-existent keys◦ Allows you to co-ordinate calls for dataClient1:GetAndLock ("k1")Client2:GetAndLock ("k1")Client3:Get ("k1")Regular GetsucceedsGetAndLock gets lockhandleOther GetAndLock onsame item fails
    • 37. Data RaceGET GETGET
    • 38. Lock Non-Existent KeyGET/LOCK GET/LOCKGET/LOCKCacheServiceCachingServiceCacheService
    • 39. Composite RaceCALL WAITWAITCacheServiceCachingServiceCacheService
    • 40. Composite RacePUTUNLOCKGETGETCacheServiceCachingServiceCacheService
    • 41. Resource/Activity Data– Tracking Changes Cache Event notifications Register on any client to notify changes Batched NotificationsDataCache.RegisterCacheLevelCallback(int filter, DataCacheChangeCallback delegate);DataCache.RegisterRegionLevelCallback(String region, int filter, DataCacheChangeCallback delegate);DataCache.RegisterKeyLevelCallback(String region, String key, int filter, DataCacheChangeCallback delegate);
    • 42. ApplicationCache2Cache1Primary forK2, V2Primary forK1, V1Cache3Primary forK3, V3Scalable NotificationsAppFabric Caching ClientRouting TableRegister Notification for Key“K3"Map Keysto PartitionPollRequired NodesNodes Return List of ChangesLSN OrderPartition: P2Last LSN: 19Call DelegateStore Last LSNChange LogPartition P11 Add K22 Del K32Change Log(Partition P2)18 Del K3219 Del K43Change Log33 Add K134 Del K22
    • 43. AgendaThe ProblemA Possible SolutionNew PossibilitiesWhat to do next
    • 44. Data CenterPre-FetchHospital
    • 45. Data CenterPre-FetchHospitalRemote ClinicWANSlow!!
    • 46. Data CenterPre-FetchHospitalRemote ClinicCacheServiceWAN
    • 47. AgendaThe ProblemA Possible SolutionNew PossibilitiesWhat to do next
    • 48. Web Platform Installer
    • 49. Select Enterprise
    • 50. Install AppFabric
    • 51. Install AppFabric
    • 52. AppFabric on MSDN
    • 53. Thanks to our contributors