1 / 30

Verteiltes Caching mit Windows Server AppFabric

Verteiltes Caching mit Windows Server AppFabric. Ingo Rammer thinktecture ingo.rammer@thinktecture.com. Unterstützung und Consulting von Software- Entwicklern und – Architekten im Windows- und .NET- Umfeld Entwickler -Coaching und –Mentoring Architektur -Consulting und –Prototyping

december
Download Presentation

Verteiltes Caching mit Windows Server AppFabric

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. Verteiltes Caching mit Windows Server AppFabric Ingo Rammer thinktecture ingo.rammer@thinktecture.com

  2. Unterstützung und Consulting von Software-Entwicklernund –Architektenim Windows- und .NET-Umfeld Entwickler-Coaching und –Mentoring Architektur-Consulting und –Prototyping Architektur- und Code-Reviews Anwendungsoptimierung, Troubleshooting, Debugging http://www.thinktecture.com ingo.rammer@thinktecture.com Ingo Rammer und thinktecture

  3. AppFabric Caching (Velocity) is a Windows Service forhighlyscalabledistributedcaching Multiple physicalnodesarecombined to form onebigvirtualcache Caching in 30 Seconds

  4. So first … let‘sstartthevirtualmachines …

  5. User Load Balancer WebServer #1 WebServer #2 WebServer #3 WebServer #n Data

  6. Web Server Application Local Caching Session State Data

  7. Session state InProc, Session server, database? Availability, Single-Point-Of-Failure, Performance Caching Cache consistencywhenusing multiple servers Today‘sIssues

  8. Load Balancer CacheServer #1 WebServer #1 WebServer #2 WebServer #3 WebServer #n AppFabric Caching CacheServer #2

  9. Load Balancer WebServer #1 WebServer #2 WebServer #3 WebServer #n CacheServer #1 CacheServer #2

  10. Administration Powershell Cluster configcentrally in XML fileor in SQL Server ConfiguringAppFabric

  11. Notebook directly: Windows 7 with IIS and Visual Studio Fourvirtualmachines: VCacheDC Domain Controller SQL Server VCache01 AppFabric VCache02 VCache03 AppFabric AppFabric

  12. Named Caches VCache01 VCache02 VCache03 Cache: default Cache: sessiondata Additional caches … with different configuration

  13. Administration via Powershell Loadingthemodule Import-Module DistributedCacheAdministration Get-CacheHelp Creating a newcache: New-Cache democache Startingthe Cluster: Start-CacheCluster Status: Get-CacheHost Cache Administration

  14. Export-CacheClusterConfig c:\test.xml Add advancedProperties Import-CacheClusterConfigc:\test.xml AppFabric Caching w/o Security <dataCache> <advancedProperties> <securityProperties mode="None" protectionLevel="None" /> </advancedProperties> <caches>…</caches> <hosts>…</hosts> </dataCache>

  15. Configuringtheclient AppFabric Caching „Hello World“ <configuration> <configSections> <section name="dataCacheClient" type="Microsoft.ApplicationServer.Caching.DataCacheClientSection, Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </configSections> <dataCacheClient> <hosts> <host name="VCache01" cachePort="22233“ /> </hosts> <securityProperties mode="None" protectionLevel="None"/> </dataCacheClient>

  16. Adding References fromC:\Windows\System32\AppFabric Microsoft.ApplicationServer.Caching.ClientandMicrosoft.ApplicationServer.Caching.Core Have to becopiedfirst AppFabric Caching „Hello World“ DataCacheFactory fact = new DataCacheFactory(); DataCachemyCache = fact.GetCache("democache2"); string someKey = "myKey"; string someValue = "testing"; // anything [Serializable] myCache.Put(someKey, someValue); string result = (string) myCache[someKey];

  17. Storingand Distribution DataCache defaultcache = GetCache("default"); Product prod = GetProduct(...); defaultcache.Put("Prod-1",prod); .NET Client defaultcache.Put("Prod-2",prod2); defaultcache.Put("Prod-3",prod3); defaultcache.Put("Prod-4",prod4); VCache01 VCache02 VCache03 Cache: default Prod-1 Prod-2 Prod-3 Prod-4 Other namedcaches …

  18. Scalingsize More machines == morememory Scalingthroughput More machines == higherthroughput „LocalCache“ Directlyatclient == massivelylowerlatency Higher throughputwhenreading But also: itemsareolder, cangetstale Scalingthe Cache

  19. Item Routing .NET Client defaultcache.Put("Prod-1",prod); Dynamic Routing Table Prod-1 Velocity #1 Velocity #2 Velocity #3 Prod-2 Prod-3 Prod-4

  20. NodeFailure .NET Client object p1 = defaultcache["Prod-1"]; object p1 = defaultcache["Prod-1"]; if (p1==null) { p1 = GetProductFromDatabase(...) defaultcache.Put("Prod-1", p1); } Dynamic Routing Table Prod-1 Velocity #1 Velocity #2 Velocity #3 Prod-2 Prod-1 Prod-3 Prod-4

  21. Optional All elements in a region live on the same node Can betagged AllowBulkGetandbulkdelete Regionsand Tags

  22. Reference Data: "never" changes (catalogdata, pricelists, …) Activitydata: non-concurrentchanges (sessiondata, shoppingcart, …) Resourcedata: highconcurrencydata, constantlychanging (inventorylevel, …) Kinds of Data

  23. Analysing Data • Performance – Throughputandlatency • Consistency – Guaranteedor eventual • Recoverability – Can thedataberestoredfrom DB (cacheeviction?) • Availability – Whathappensatnodefailure

  24. Chosen in configorcode In practice: oftencode, becauseonlyspecificpartsshouldbecachedlocally (DataCacheFactory) Goodforreferencedata Synchronization Age ofitems Notification Local Cache

  25. Pub/sub on cache item changes Callbacksforcompletecache, for a regionorfor a single item Are currently (beta 2) queuedatserversideandregularilypolledbytheclient Cache has to beconfiguredfornotifications New-Cache <name> -NotificationsEnabledtrue Notifications

  26. Optimisticandpessimisticlocking Concurrency DataCacheItemVersion ver = default(DataCacheItemVersion); object itm = defaultCache.Get("region", "key", ref ver); // after change (throws an exception if modified in meantime) defaultCache.Put("region","key", itm, ver); DataCacheLockHandle lockHandle; object itm = defaultCache.GetAndLock("region", "key", TimeSpan.FromSeconds(30), out lockHandle); // after change: defaultCache.PutAndUnlock("region", "key", itm, lockHandle, null);

  27. Session State <sessionStatemode="Custom" customProvider="Velocity"> <providers> <addname="Velocity" type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider, Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" cacheName="sessiondata" retryCount="5"/> </providers> </sessionState>

  28. High Availability sessionCache.put("Sess-1", se1); sessionCache.put("Sess-1", se1); sessionCache.put("Sess-2", se2); Sess-1 (Primary) Sess-2 (Primary) Sess-1 (Secondary) Sess-2 (Secondary) Velocity #1 Velocity #2 Velocity #3

  29. Failover with High Availability sessionCache.put("Sess-1", se1); sessionCache.put("Sess-2", se2); sessionCache.put("Sess-1", se1); Velocity #1 Velocity #2 Velocity #3 Sess-1 (Secondary) Sess-1 (Primary) Sess-1 (Secondary) Sess-2 (Secondary) Sess-2 (Primary) Sess-2 (Primary) Sess-2 (Secondary)

  30. Powershell New-Cache <name> -Secondaries 1 Maybe also: –Eviction None –NotExpirabletrue Startingwith Beta2: Onlysupported on Enterprise (and Data Center) operatingsystemeditions Configuring High Availability

More Related