1 / 12

Windows Server AppFabric Cache

Windows Server AppFabric Cache. HA, locking, and callbacks. Outline. High-availability Pessimistic concurrency Cache callbacks. High availability. Generally used with Activity data

Download Presentation

Windows Server AppFabric Cache

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Server AppFabric Cache HA, locking, and callbacks

  2. Outline • High-availability • Pessimistic concurrency • Cache callbacks

  3. High availability • Generally used with Activity data • Performance overhead generally not worth it for resource or reference data (remember – cache-aside pattern is the typical use case for cached data). • Secondaries parameter to New-Cache • Only valid option in V1 is “1” • Cluster will have two hosts hold copy of data • One is primary – one is secondary • If primary host dies, secondary is promoted, new secondary is chosen • If secondary dies, new secondary is chosen • Happens automatically

  4. High Availability Application Application Get(K2) AppFabric Caching Client AppFabric Caching Client Routing Table Routing Table Cache1 Cache2 Cache3 Primary for Primary for Primary for Replication Agent K3, V3 K1, V1 K2, V2 K2, V2 PUT(K2, V2) Secondary for Secondary for Secondary for K2, V2 K3, V3 K1, V1

  5. Pessimistic Concurrency • DataCache API supports locking across nodes • Expensive • Generally only used for resource data

  6. Pessimistic Locking • GetAndLock works on non-existent keys • Allows you to co-ordinate creating new object amongst multiple clients Client1: GetAndLock ("k1") Client3: Get ("k1") Client2: GetAndLock ("k1") GetAndLock gets lock handle Regular Get succeeds Other GetAndLock on same item fails K1

  7. Callbacks • Client can register for notification of cache events • Different levels • Item • Cache • Region • Bulk API available as well • Callback functionality has to be enabled on the cache • –Notifications true on New-Cache or Set-CacheConfig • Not synchronous • No guarantees on time of delivery

  8. DataCachecallback API publicvirtualDataCacheNotificationDescriptorAddCacheLevelBulkCallback(DataCacheBulkNotificationCallbackclientCallback); publicvirtualDataCacheNotificationDescriptorAddCacheLevelCallback(DataCacheOperation filter, DataCacheNotificationCallbackclientCallback); publicvirtualDataCacheNotificationDescriptorAddFailureNotificationCallback(DataCacheFailureNotificationCallbackfailureCallback); publicvirtualDataCacheNotificationDescriptorAddItemLevelCallback(string key, DataCacheOperation filter, DataCacheNotificationCallbackclientCallback); publicvirtualDataCacheNotificationDescriptorAddItemLevelCallback(string key, DataCacheOperation filter, DataCacheNotificationCallbackclientCallback, stringregionName); publicvirtualDataCacheNotificationDescriptorAddRegionLevelCallback(stringregionName, DataCacheOperation filter, DataCacheNotificationCallbackclientCallback);

  9. DataCacheOperation filter • Enables restricting or expanding callback functionality • Use binary OR to combine namespaceMicrosoft.ApplicationServer.Caching { [Flags] publicenumDataCacheOperations { AddItem = 1, ReplaceItem = 2, RemoveItem = 4, CreateRegion = 8, RemoveRegion = 16, ClearRegion = 32, } }

  10. Using callbacks New-CacheCallBackCache-NotificationsEnabledtrue varcfg = newDataCacheFactoryConfiguration(); cfg.Servers = newList<DataCacheServerEndpoint> { newDataCacheServerEndpoint("demo2010a", 22233) }; vardcf = newDataCacheFactory(cfg); var cache1 = dcf.GetCache("CallBackCache"); var d = cache1.AddCacheLevelCallback(DataCacheOperations.AddItem, ( cacheName, regionName, key, version, cacheOperation, nd) => { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("New item added to cache {0}", key); Console.ResetColor(); });

  11. Summary • High availability is an expensive (performance) but useful feature for guaranteeing availability of activity data • Pessimistic locking API exists for particular scenarios, generally around resource data • Callbacks can be useful for administrative and/or monitoring applications

  12. Questions?

More Related