TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9


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

No notes for slide
  • MSCUIBusiness Application Template
  • MSCUIBusiness Application Template
  • MSCUIBusiness Application Template
  • TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9

    1. 1. Como garantir a escalabilidade da sua camada de dados com o Windows Server AppFabric<br />WIN304<br />NunoGodinho<br />Partner & CTO @ ITech4All<br /><br />@NunoGodinho<br />
    2. 2. Session abstract<br />Session title<br />
    3. 3. Speaker Bio and Photo<br />Speaker Name<br />
    4. 4. Nuno Filipe Godinho<br />Partner & CTO @ ITech4all<br />Mail:<br /><br />Blogs:<br /><br /><br /><br />Twitter: @NunoGodinho<br />About Me<br />
    5. 5. The Problem!<br />Caching with the Windows Server AppFabric<br />Overview and Programming Model<br />Caching Futures<br />Summary<br />Q&A<br />Agenda<br />
    6. 6. The Problem<br />
    7. 7. Online Pharmacy<br />
    8. 8. Typical Web Architecture<br />
    9. 9. Typical Architecture<br />Users<br />Load Balancer<br />Sticky Routing<br />Application<br />/ Web Tier<br /> Application<br /> Application<br /> Application<br />ASP.Net App <br />Session Cart Hosted in memory<br />Catalog sits in Database<br />Data Tier<br />Database<br />
    10. 10. And then… <br />Flu Hits!<br />
    11. 11. You become a popular Pharmacy!<br />Web Site’s too slow!!<br />Users<br />Where did my shopping cart go?<br />Web Tier<br />(ASP.Net)<br />…<br /> Application<br /> Application<br /> Application<br />Servers are crashing<br />Database is hot!!<br />Data Tier<br />Database<br />
    12. 12. Possible Solution<br />
    13. 13. Data Near Processing<br />Cache<br />Cache<br />Browser<br />Smart Client<br />Cache<br />Web Service<br />ASP.NET<br />Cache<br />Cache<br />Database<br />
    14. 14. Cache is scoped to machine / process<br />Machines die<br />Processes recycle<br />Cache memory is limited<br />Good but…<br />
    15. 15. You could have as much cache as you wanted?<br />You could share a giant cache across servers, services and even clients?<br />What if this was something you could simply add to the platform for 1free?<br />1Some features may require certain editions of Windows Server <br />What if?<br />
    16. 16. Caching with the Windows Server AppFabric<br />
    17. 17. What Is It?<br />
    18. 18. An explicit, distributed, in-memory application cache for all kinds of data <br />(CLR objects, rows, XML, Binary data etc.)<br />Fuse "memory" across machines into a unified cache<br />What is AppFabric Caching?<br />Caching clients can be across machines or processes<br />Clients Access the Cache as if it was a large single cache<br />Unified Cache View<br />Cache Layer distributes data across the various cache nodes<br />
    19. 19. Where does it fit?<br />Users<br />Caching Access Layer<br />Caching Access Layer<br />Caching Access Layer<br />…<br />Web Tier<br />(ASP.Net)<br /> Application<br /> Application<br /> Application<br />Caching Service<br />Caching Service<br />Caching Service<br />Cache Tier<br />Data Tier<br />Database<br />Cloud<br />
    20. 20. AppFabric Cache<br />
    21. 21. Why AppFabric Caching<br />
    22. 22. 1. Share Data Across Applications<br />No more sticky routing<br />2. Performance<br />3. Scale out by adding more boxes<br />4. High Availability Protect from Web & Cache Server Failure<br />Why use AppFabric Caching? <br />
    23. 23. 5. Proven Technology - Associated Press Custom News live on CTP3<br />Why use AppFabric Caching?<br /><ul><li>AppFabric caching capabilities caches metadata and news for widgets
    24. 24. Serves 16 million hits per day
    25. 25. Increased the amount of cached data 6 times.</li></li></ul><li>5. Proven Technology Contd..<br /> uses AppFabric caching!<br />Channel Partner Portal uses AppFabric caching<br />Provides targeted content and search results <br />Tracks customer browse history and downloads.<br />Next Generation Sales Platform Solutions to use AppFabric caching (currently under construction)<br />Just two of the many TAP customers in line for production<br />Why AppFabric Caching?<br />
    26. 26. 6. Do all this at low cost!<br />Why AppFabric Caching? – Best yet<br /><ul><li>Use inexpensive commodity hardware
    27. 27. Ships as part of Windows Server AppFabric 2010 Wave 1 </li></ul>* Different Features of the cache might require higher level SKUs of Windows Server.<br />AppFabric<br />MONITORING<br />WORKFLOW HOSTING<br />CACHING<br />ACCESS CONTROL<br />SERVICE HOSTING<br />SERVICE BUS<br />MANAGEMENT<br />MULTI-TENANT <br />SCALE OUT<br />HIGH AVAILABILITY <br />
    28. 28. What Stage Is It In?<br />
    29. 29. When Can I Get Windows Server AppFabric ?<br />Azure CTP<br />Post RTM<br />RTM<br />2010 Wave 1<br />* CY10<br />CTP2<br />PDC ‘08<br />CTP1<br />June ‘08<br />CTP3<br />Mar ‘09<br />Beta<br /><ul><li>PDC
    30. 30. Nov ‘09</li></ul>(Formerly Called “Velocity”)<br />
    31. 31. Installation<br />
    32. 32. Overview and Programming AppFabric Caching<br />
    33. 33. Deployment and Access API<br />
    34. 34. Deployment<br />Users<br />Update Web.config<br />Copy Client DLLs<br /> Application<br /> Application<br /> Application<br />…<br />Caching Access Layer<br />Caching Access Layer<br />Caching Access Layer<br /><hosts><br /> <host name="BL1CDB8083714“<br />cachePort="22233" <br />cacheHostName="DistributedCacheService"/><br /> …..<br /> </hosts><br /> <localCacheisEnabled=“true" ../><br /><security … /><br />.NET 3.5 SP1 OR .NET 4<br />Caching Service<br />Caching Service<br />Caching Service<br />.NET 4<br />Configure AppFabric<br />Install AppFabric<br />Configuration Store <br />
    35. 35. AppFabric Caching CodePlex Tool<br /><br />
    36. 36. Domain Based Security Option<br />Domain Account / Local Account based Authentication<br />Only authorized servers can join the cluster<br />Only authorized clients can connect to the cluster<br />Transport Level Security<br />Turn on/off Signing or Encryption<br />Can turn off Cache Security<br />Use Firewalls, IPSec, VLANs to protect cache<br />Security (new since Beta) <br />grant-cacheallowedclientaccount  RedDomainMachine1$<br /> grant-cacheallowedclientaccount  RedDomainJohn<br />
    37. 37. Centralized administration through powershell<br />Perfmon to monitor the cache (new in Beta)<br />Logging <br />Default ETW, support for file logs <br />Administration & Monitoring<br />
    38. 38. // Create instance of cachefactory (reads appconfig)<br />DataCacheFactoryfac = new DataCacheFactory();<br />// Get a named cache from the factory<br />DataCache catalog = fac.GetCache("catalogcache");<br />AppFabric Caching API<br />// Simple Get/Put<br />catalog.Put("toy-101", new Toy("Puzzle", .,.));<br />// From the same or a different client<br />Toy toyObj = (Toy)catalog.Get("toy-101");<br />// Region based Get/Put<br />catalog.CreateRegion("toyRegion");<br />// Both toy and toyparts are put in the same region <br />catalog.Put("toy-101", new Toy( .,.), “toyRegion”);<br />Catalog.Put("toypart-100", new ToyParts(…), “toyRegion”);<br />Toy toyObj = (Toy)catalog.Get("toy-101“,"toyRegion");<br />
    39. 39. AppFabric Caching Logical Hierarchy<br />AppFabric Caching Service<br />AppFabric Caching Service<br />AppFabric Caching Service<br />AppFabric Caching Service<br />Named Cache : Product Catalog<br />Named Cache : Electronics Inventory<br />Regions <br />Key Payload Tags <br />Region A<br />121 xxxx “Toy” “Child”<br />123 yyyy “Toy” “Chair”.. <br />Machine -> Cache Host -> Named Caches -> Regions -> Cache Items -> Objects<br />Host<br />Physical processes hosting AppFabric Caching instance.<br />Named Caches<br />Can span across machines<br />Defined in the configuration file<br />Cache Item<br />Key, Payload (Object ), Tags, TTL, Timestamps, Version<br />Regions<br />Physically co-located Container of Cache Items<br />May be implicit or explicitly created<br />
    40. 40. Add Tags to Items<br />Tag Search on Default Regions (New in Beta)<br />Access APIs – Tagging Items<br />Tag hotItem = new Tag("hotItem");<br />catalog.Put("toy-101", new Toy("Puzzle"),<br /> new Tag[]{hotItem}, “toyRegion”);<br />catalog.Put("toy-102", new Toy("Bridge"), “toyRegion”);<br />// From the same or a different client<br />List<KeyValuePair<string, object>> toys = <br />catalog.GetAnyMatchingTag("toyRegion", hotItem);<br />
    41. 41. Usage Pattern – Cache Aside (Explicit Caching)<br />// Read from Cache<br />Toy toyObj = (Toy)<br />catalog.Get("toy-101");<br /> Application<br />Caching Access Layer<br />// If Not present in the cache<br />if (toyObj == null)<br />{<br /> // Read from backend..<br /> toyObj = ReadFromDatabase();<br /> // Populate Cache<br />catalog.Put("toy-101", toyObj);<br /> return toyObj;<br />}<br />Caching Service<br />Database<br />
    42. 42. How does it Scale?<br />
    43. 43. Data Distribution - Partitioned Cache<br />Users<br />…<br />G<br />H<br />I<br />D<br />E<br />F<br />A<br />B<br />C<br />Web Tier<br />ASP.Net App<br />ASP.Net App<br />ASP.Net App<br />Caching Client<br />Caching Client<br />Caching Client<br />E<br />G<br />B<br />D<br />H<br />A<br />I<br />C<br />F<br />Cache Service<br />Cache Service<br />Cache Tier<br />Cache Service<br />Scale on Data Size -More machines => More memory to cache<br />Scale on Cache Throughput -More machines => keys distributed across more machines => better throughput<br />
    44. 44. Scale Test Output<br />Load<br />1 Cache Server<br />As load increases, <br />throughput fails <br />to scale <br />latency increases<br />Caching Tier<br />Throughput<br />Latency<br />
    45. 45. Add Second Cache Server<br />Load<br />Load Max<br />Throughput increases<br />Latency decreases<br />Caching Tier<br />Throughput<br />Latency<br />
    46. 46. Add Third Cache Server<br />Load<br />Caching Tier<br />Throughput<br />Latency<br />
    47. 47. GridDynamics Blog Engine Tests<br />More info at or<br /><br />
    48. 48. Features<br />
    49. 49. Classify your data <br />Reference or Activity or Resource Data<br />Examine Requirements<br />Performance - Throughput & Latency <br />Consistency – Tolerable staleness<br />Eviction - Is the data evictable?<br />Security - Is there any secure data?<br />Availability – Survive node or cluster failures?<br />Use the right features!<br />
    50. 50. Types of Data<br />Grocery Shop<br /> Web Tier<br /> Shopping Cart<br />Pharmacy Inventory<br />Distributed Cache<br />Pharmacy Catalog<br />
    51. 51. Catalog data doesn’t change often<br />Unnecessary network cost to access from different machines<br />Solution – Local Cache<br />Application<br />Application<br />Reference Data – Performance<br />Get(K2)<br />Get(K2)<br />Put(K2, v3)<br />AppFabric Caching Client<br />AppFabric Caching Client<br />Local Cache<br />Routing Table<br />Routing Table<br />K2, V2<br />K2, V2<br />Cache2<br />Cache3<br />Cache1<br />Primary for K1,V1<br />Primary for K3,V3<br />Primary for K2,V2<br />K1, V1<br />K2, V3<br />K3, V3<br />
    52. 52. Enumerate all items in Region<br />Bulk Fetch from region (New in Beta)<br />200-300k ops per second<br />Reference Data – Bulk Get<br />Catalog.BulkGet( <br /> new List<string>(){“toy-101”, “toy-102”} ,<br /> “toyRegion”);<br />
    53. 53. Application<br />PUT<br />Application<br />Get(K2)<br />AppFabric Caching Client<br />AppFabric Caching Client<br />Routing Table<br />Routing Table<br />Cache1<br />Cache2<br />Cache3<br />Activity Data - Availability<br />Primary for<br />Primary for<br />Primary for <br />Replication Agent<br />(K2, V2)<br />K3, V3<br />K2, V2<br />K1, V1<br />K2, V2<br />K2, V2<br />Secondary for<br />Secondary for <br />Secondary for<br />K3, V3<br />K1, V1<br />
    54. 54. GetCacheItem returns a version object<br />Every update to an object internally increments it's version<br />Supply the version obtained along with the Put/Remove<br />Put/Remove will succeed only if the passed in version matches the version in the cache <br />Resource Data - Optimistic Locking<br />Two clients access the same item <br />Both update the item<br />Second Client gets in first; put succeeds because item version matches; atomically increments the version<br />First client tries put;<br />Fails because the versions don’t match<br />
    55. 55. Resource Data - Pessimistic Locking<br />Client1: <br />GetAndLock ("k1")<br />Client3:<br /> Get ("k1")<br />Client2:<br /> GetAndLock ("k1")<br />GetAndLock gets lock handle<br />Regular Get succeeds<br /> Other GetAndLock on same item fails<br />New in Beta – Take locks on non-existent keys<br />Allows you to co-ordinate creating new object amongst multiple clients<br />K1<br />
    56. 56. Cache Event notifications<br />Register on any client to notify changes<br />Batched Notifications – (New in Beta)<br />Resource/Activity Data – Tracking Changes<br />DataCache.RegisterCacheLevelCallback(<br />int filter, DataCacheChangeCallback delegate); <br />DataCache.RegisterRegionLevelCallback(<br /> String region, int filter, DataCacheChangeCallback delegate); <br />DataCache.RegisterKeyLevelCallback(<br /> String region, String key, int filter, DataCacheChangeCallback delegate); <br />
    57. 57. Register Notification for Key “K3"<br />Call Delegate<br />Store Last LSN <br />Map Keys to Partition (say P2)<br />Application<br />AppFabric Caching Client<br />Partition: P2<br />Last LSN: 19<br />Routing Table<br />Poll Required Nodes<br />Nodes Return List of Changes<br />LSN Order<br />Cache2<br />Cache3<br />Cache1<br />K2, V2<br />Primary for<br />Primary for<br />Primary for<br />Change Log (Partition P2)<br />Del K32<br />Del K43<br />Change Log<br />Partition P1<br />Add K2<br />Del K32<br />Change Log<br />33 Add K1<br />34 Del K22<br />K1, V1<br />K3, V3<br />Scalable Notifications<br />
    58. 58. Programming Model<br />
    59. 59. AppFabric Caching Futures<br />
    60. 60. AppFabric Caching and Azure Platform<br />
    61. 61. You are a popular Online Pharmacy!!<br />Lots of Users!<br />Irregular & Elastic Demands<br />Solution - Move to the Services World!<br />Application on-premise with data on SQL Azure<br />Application on Windows Azure with data on SQL Azure<br />Application on Windows Azure with on-premise database connected by AppFabric Service Bus<br />Application Growth<br />
    62. 62. App on-premise; Data on SQLAzure<br />…<br />ASP.Net Web Tier<br /> Application<br /> Application<br /> Application<br />AppFabric Caching Access Layer<br />AppFabric Caching Access Layer<br />AppFabric Caching Access Layer<br />Application & AppFabric Caching deployed On-premise<br />Caching Service<br />Caching Service<br />Caching Service<br />Caching Worker Role<br />Data on SQL Azure<br />
    63. 63. App on Windows Azure; Data on SQL Azure<br />Web Role<br />…<br /> Application<br /> Application<br /> Application<br />AppFabric Caching Access Layer<br />AppFabric Caching Access Layer<br />AppFabric Caching Access Layer<br />Application & AppFabric Caching on Windows Azure<br />Caching Service<br />Caching Service<br />Caching Service<br />Caching Worker Role<br />AppFabric Caching Worker Role<br />Data on SQL Azure<br />
    64. 64. App on Windows Azure; Data on-premise<br />Web Role<br />…<br /> Application<br /> Application<br /> Application<br />AppFabric Caching Access Layer<br />AppFabric Caching Access Layer<br />AppFabric Caching Access Layer<br />AppFabric Service Bus<br />Application & AppFabric Caching on Windows Azure<br />Caching Service<br />Caching Service<br />Caching Service<br />Caching Worker Role<br />AppFabric Caching Worker Role<br />Data on-premises<br />
    65. 65. ASP.NET and Persistence<br />
    66. 66. ASP.Net extends cache surface .Net 4.0<br />Integrate with the Application Cache<br />System.Runtime.Caching namespace<br />AppFabric Caching will be a provider for this namespace<br />Granular Session Updates<br />IPartialSessionState lists keys changed<br />Extensible Output Cache Provider<br />Output Caching not limited to single node<br />Integration with ASP.Net<br />
    67. 67. Callback for read-through, write-behind <br />Specified at Named Cache Level<br />Read-Through<br />Called when item not present in cache<br />Callback returns the object/serialized bytes<br />Write-Behind<br />Writes to cache are queued <br />Callback called asynchronously in batches<br />Re-tries upon failure<br />Bulk Access APIs<br />Future – Cache Through<br />
    68. 68. HPC Integration<br />Final Results Store<br />AppFabric Caching<br />Market Data<br />Central Market Data Store<br />(~1 TB Tick Data)<br />Final<br />Results<br />AppFabric Caching<br />Intermediate<br />Store<br />Market Data<br />Scratch<br />Job<br /> Input<br />Rollup<br />Operation<br />Split<br />Method<br />Scratch<br />Keys<br />Calculation<br />Operation<br />GridDynamics testing<br /> on CTP1<br /> 50 times improvement<br /> in some cases<br />
    69. 69. Summary<br />
    70. 70. AppFabric Caching Vision – Cache for all your data<br />
    71. 71.<br />AppFabric on MSDN<br />