1 / 28

Performance Distributed Caching: Introduction to Velocity

Performance Distributed Caching: Introduction to Velocity. Ingo Rammer ingo.rammer@thinktecture.com thinktecture. Ingo Rammer and thinktecture . Support and consulting for software architects and developers Application Optimization, Troubleshooting, Debugging

nona
Download Presentation

Performance Distributed Caching: Introduction to Velocity

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. Performance Distributed Caching: Introduction to Velocity Ingo Rammer ingo.rammer@thinktecture.com thinktecture

  2. Ingo Rammer and thinktecture • Support and consulting for software architects and developers • Application Optimization, Troubleshooting, Debugging • Architectural Consulting and Prototyping • Developer-Coaching and -Mentoring • Architecture and Code Reviews • http://www.thinktecture.com • ingo.rammer@thinktecture.com

  3. 30 Second Elevator Pitch • Project Velocity is a Windows Service which provides highly scalable, distributed, cache-aside caching infrastructure spanning multiple physical nodes • ... and it will quite likely be free and released mid 2009

  4. Typical Web Application Users Load Balancer WebServer #1 WebServer #2 WebServer #3 WebServer #n DataStore

  5. Web Server in Detail Web Server Application Memory Local Caching Session State DataStore

  6. Typical Web Application Load Balancer WebServer #1 WebServer #2 WebServer #3 WebServer #n CacheServer #1 Velocity Caching CacheServer #2

  7. Velocity Services Load Balancer WebServer #1 WebServer #2 WebServer #3 WebServer #n CacheServer #1 V V V V V CacheServer #2 V

  8. Installing Velocity • Today CTP2/CTP3 • Configuration • Server: Cluster XML or SQL Server • Client: App.Config or code • Administration • Powershell - can be used from any node in the cluster

  9. Velocity Hello World • In Powershell admin • New-Cache -cachename democache • Store/Retrieve items DataCacheFactory fact = new DataCacheFactory(); DataCachemyCache = fact.GetCache("democache2"); string someValue = "testing"; // anything [Serializable] string someKey = "myKey"; myCache.Put(someKey, someValue); string result = (string) myCache[someKey];

  10. Velocity Item Storage DataCache defaultcache = GetCache(...); 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); Velocity #1 Velocity #2 Velocity #3 Prod-1 Prod-2 Prod-3 Prod-4

  11. Scaling Velocity • Scale on size • More machines == more memory • Scale on throughput • More machines == higher throughput • Local Cache • Closer to the client == lower latency, higher throughput, higher staleness

  12. Local Cache • Can be enabled in config or code • Great for reference data which can tolarate staleness • Synchronization • CTP2: Expiration • CTP3: notifications from central caches

  13. Velocity 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

  14. Cache Failure .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

  15. Kinds of Data • Reference Data • Example: product catalog • Does not change dynamically, can be cached locally • Can be reloaded from database • Activity Data • Example: Session, shopping cart • Frequent changes, highly partitionable • Needs high availability • Resource Data • Example: product inventory level • Changes often, needs staleness decision • Maybe "exceed first, apologize later", maybe centralized checks on update on partitioned DB

  16. Concurrency • Optimistic (default) and pessimistic locking 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);

  17. Data Requirements • Decide which properties you need • Performance - Throughput and Latency • Consistency - Staleness • Eviction - Can the data be recreated? • Security - Who can read/write • Availability - Survive node failure • Different set of requirements for each kind of data • Configuration options in Velocity for these requirements

  18. 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

  19. High Availability Failover sessionCache.put("Sess-1", se1); sessionCache.put("Sess-1", se1); sessionCache.put("Sess-2", se2); 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)

  20. Session State // ... here comes the code ... <sessionState mode="Custom" customProvider="SessionStoreProvider"> <providers> <add name="SessionStoreProvider" type="System.Data.Caching.SessionStoreProvider, ClientLibrary" cacheName="CacheName"/> </providers> </sessionState>

  21. Regions • Optional • Support tagging, enumeration and bulk gets (CTP3) • Every item in a region lives on the same node! • Example use case • Session state in which every property can be stored individually within one region • Can be used as unit for deletion

  22. Future • CTP3: • Notifications, callback for cache item changed • Version 2: • Core features • Queryable caches with LINQ • Cache-Through instead of cache-aside • ASP.NET 4.0 • Velocity as System.Caching provider • Granular session updates (IPartialSessionState) • Velocity as Output caching provider • Higher compatibility with Azure and HPC

  23. Your MSDN resourcescheck out these websites, blogs & more! PresentationsTechDays: www.techdays.chMSDN Events: http://www.microsoft.com/switzerland/msdn/de/presentationfinder.mspxMSDN Webcasts: http://www.microsoft.com/switzerland/msdn/de/finder/default.mspx MSDN EventsMSDN Events: http://www.microsoft.com/switzerland/msdn/de/events/default.mspxSave the date: Tech•Ed 2009 Europe, 9-13 November 2009, Berlin MSDN Flash (our by weekly newsletter)Subscribe: http://www.microsoft.com/switzerland/msdn/de/flash.mspx MSDN Team BlogRSS: http://blogs.msdn.com/swiss_dpe_team/Default.aspx Developer User Groups & CommunitiesMobile Devices: http://www.pocketpc.ch/Microsoft Solutions User Group Switzerland: www.msugs.ch.NET Managed User Group of Switzerland: www.dotmugs.chFoxPro User Group Switzerland: www.fugs.ch

  24. Your TechNet resourcescheck out these websites, blogs & more! PresentationsTechDays: www.techdays.ch TechNet EventsTechNet Events: http://technet.microsoft.com/de-ch/bb291010.aspx Save the date: Tech•Ed 2009 Europe, 9-13 November 2009, Berlin TechNet Flash (our by weekly newsletter)Subscribe: http://technet.microsoft.com/de-ch/bb898852.aspx Schweizer IT Professional und TechNet BlogRSS: http://blogs.technet.com/chitpro-de/ IT Professional User Groups & CommunitiesSwissITPro User Group: www.swissitpro.chNT Anwendergruppe Schweiz: www.nt-ag.chPASS (Professional Association for SQL Server): www.sqlpass.ch

  25. Save the date for tech·days nextyear! 7. – 8. April 2010Congress Center Basel

  26. Premium Sponsoring Partners Classic Sponsoring Partners Media Partner

  27. Code Template // ... here comes the code ...

More Related