• Save
Scale Your Data Tier with Windows Server AppFabric
Upcoming SlideShare
Loading in...5
×
 

Scale Your Data Tier with Windows Server AppFabric

on

  • 469 views

 

Statistics

Views

Total Views
469
Views on SlideShare
467
Embed Views
2

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 2

http://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 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.

Scale Your Data Tier with Windows Server AppFabric Scale Your Data Tier with Windows Server AppFabric Presentation Transcript

  • Scale Your Data Tier withWindows Server AppFabricChris Dufour, ASP MVPSoftware Architect, Compuwarechris.dufour@wigets.net
  • AgendaThe ProblemA Possible SolutionNew PossibilitiesWhat to do next
  • SimpleDo the simplest thingthat will possibly work View slide
  • ScalabilityAble to support therequired quality ofservice as the systemload increases-Wiktionary View slide
  • 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
  • Web ExplosionDatabaseIIS/ASP.NETApplicationWebSite’s tooslow!!Database ishot!!Where didmyshoppingcart go?IIS/ASP.NETApplicationIIS/ASP.NETApplicationServers arecrashingServices areslow
  • AgendaThe ProblemA Possible SolutionNew PossibilitiesWhat to do next
  • Data Near ProcessingDatabaseSmart Client BrowserCacheCacheCacheCacheCache
  • Good but… Cache is scoped to machine / process◦ Machines die◦ Processes recycle Cache memory is limited
  • 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
  • Windows Server AppFabricAppFabricCACHINGMONITORINGWORKFLOW HOSTINGSERVICE HOSTINGSCALE OUTHIGH AVAILABILITY MANAGEMENT
  • 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
  • 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
  • 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
  • Scale Test OutputLoadThroughputLatency1 Cache ServerAs load increases,throughput failsto scalelatency increasesCachingTier
  • Add a Second Cache ServerLoadThroughputLatencyLoad MaxThroughputincreasesLatency decreasesCachingTier
  • Add a Second Cache ServerLoadThroughputLatencyCachingTier
  • Associated Press Caches metadataand news Serves 16 millionhits per day Increased theamount of cacheddata 6 times.
  • System.Web.Cache
  • AppFabric DataCache
  • 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
  • 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
  • Administration PowerShell cmdlets are used to administerthe cache cluster Rich set of cmdlets for◦ Cache cluster management◦ Cache creation and monitoring
  • Hello AppFabric Cache
  • Using PowerShellRemember – PowerShell can alsobe called from .NET Code!
  • 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
  • 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
  • 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");
  • 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);
  • Types of DataReference Activity ResourcePrimary Read Only Read-Write NotsharedRead-Write, SharedCatalog Data Shopping Cart Auction Data/SeatAssignmentWeb TierDistributed CacheShopping CartGroceryCatalogGroceryInventoryGrocery Shop
  • 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
  • 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”);
  • 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>
  • 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
  • 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
  • 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
  • Data RaceGET GETGET
  • Lock Non-Existent KeyGET/LOCK GET/LOCKGET/LOCKCacheServiceCachingServiceCacheService
  • Composite RaceCALL WAITWAITCacheServiceCachingServiceCacheService
  • Composite RacePUTUNLOCKGETGETCacheServiceCachingServiceCacheService
  • 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);
  • 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
  • AgendaThe ProblemA Possible SolutionNew PossibilitiesWhat to do next
  • Data CenterPre-FetchHospital
  • Data CenterPre-FetchHospitalRemote ClinicWANSlow!!
  • Data CenterPre-FetchHospitalRemote ClinicCacheServiceWAN
  • AgendaThe ProblemA Possible SolutionNew PossibilitiesWhat to do next
  • Web Platform Installer
  • Select Enterprise
  • Install AppFabric
  • Install AppFabric
  • AppFabric on MSDNhttp://msdn.microsoft.com/AppFabric
  • Thanks to our contributors