Caching in Windows Azure

  • 3,240 views
Uploaded on

Examining caching solutions that you can use in Windows Azure, such as the Windows Azure Cache service, In-role cache, Memcached, Redis, and Couchbase. …

Examining caching solutions that you can use in Windows Azure, such as the Windows Azure Cache service, In-role cache, Memcached, Redis, and Couchbase.
The presentation shows the different features of each caching solution, pros and cons, deployment strategies, and deployment steps.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,240
On Slideshare
0
From Embeds
0
Number of Embeds
18

Actions

Shares
Downloads
47
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • Availability – not supported in South Central US

Transcript

  • 1. Ido Flatow Senior Architect Microsoft MVP SELA Group Caching in Azure More than Just Azure Caching @idoFLATOW http://bit.ly/flatow-blog This presentation: http://sdrv.ms/17s8osK
  • 2. www.devconnections.com CACHING IN WINDOWS AZURE 2 THE WORLD BEFORE DISTRIBUTED CACHE
  • 3. www.devconnections.com CACHING IN WINDOWS AZURE
  • 4. Ido Flatow Senior Architect Microsoft MVP SELA Group Caching in Azure More than just Azure Caching @idoFLATOW http://bit.ly/flatow-blog This presentation: http://sdrv.ms/15QPjke
  • 5. www.devconnections.com CACHING IN WINDOWS AZURE WHAT WE ARE GOING TO SEE  Different caching solutions  Different deployment strategies  For each solution  General features, pros/cons  Windows Azure deployment steps  C# API and benchmarks 5
  • 6. www.devconnections.com CACHING IN WINDOWS AZURE CACHING 101  Why do we cache?  Scale-out our applications  Decrease load on database  Store data close to the application  Speed up data access 6
  • 7. www.devconnections.com CACHING IN WINDOWS AZURE CACHING 101  What is expected of a cache?  Key/value CRUD  Store any entity type (no special attributes)  LRU / absolute / sliding evictions  Concurrent access  Cache per application (multitenant)  Secured transport 8
  • 8. www.devconnections.com CACHING IN WINDOWS AZURE CACHING 101  What would also be great?  Bulk operations  Enumeration and queries  Clustering and replication for high-availability  Change notifications  Transactions  Data persistence  Management API 9
  • 9. www.devconnections.com CACHING IN WINDOWS AZURE CACHING SOLUTIONS 10 Memcached Coherence Couchbase Redis SharedCache AppFabric NCache StateServer In-memory key-value store for on-premises and Windows Azure In-memory key-value store Key-value store, Data structure server NoSQL document database
  • 10. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE COMPONENTS  Windows Azure PaaS components  Storage, database, caching  Cloud Services  Web role, worker role  Virtual Machines  OS images, virtual hard disks  Virtual Networks  Subnets, VPN 11
  • 11. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE CACHE SERVICE Cache-as-a-Service 12
  • 12. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE CACHE SERVICE  Store any Data-Contract serializable objects  Item eviction (LRU, absolute, and sliding)  Item locking  Local cache for re-fetching  Group items to regions  Bulk get/delete  Simple tag-based queries  Offering-dependent features:  Standard - Separate cache per application  Premium - Notifications for region and item changes  Includes providers for ASP.NET session state and output cache 13 FeaturesPros/ConsTopologySteps
  • 13. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE CACHE SERVICE  Pros  Cache-as-a-Service, no installation required  Available from everywhere  Supports high-availability (premium offering)  Secured (transport + authentication)  Cons  Billed by cache size  Not available in all US data centers  Still in preview (for now) 14 FeaturesPros/ConsTopologySteps
  • 14. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE CACHE SERVICE 15 Cache Service Virtual Machine Web Site Cloud Service On-premises FeaturesPros/ConsTopologySteps
  • 15. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE CACHE SERVICE  Create the cache service in the portal  Cache size  Region  Add the Windows Azure Caching NuGet package to your application  Configure host name and security key 16 FeaturesPros/ConsTopologySteps
  • 16. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE CACHE SERVICE Benchmark 17
  • 17. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE IN-ROLE CACHE Distributed cache agent for cloud services 18
  • 18. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE IN-ROLE CACHE  Same features as cache service  Separate caches per-application  Expiration and eviction  Local cache  Notifications  Regions and tagging  Cache provider for ASP.NET 19 FeaturesPros/ConsTopologySteps
  • 19. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE IN-ROLE CACHE  Pros  Runs on dedicated roles or existing roles (co-located)  Deployment is very straightforward  Same API as the on-premises AppFabric caching  Supports replication for high-availability  Provides diagnostics information  Cons  No security measurements (necessary?)  Accessible only within the cloud service  No management tools 20 FeaturesPros/ConsTopologySteps
  • 20. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE IN-ROLE CACHE 21 Other Roles Co-located Roles Dedicated Worker Role Cloud Service Clustering&Replication FeaturesPros/ConsTopologySteps
  • 21. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE IN-ROLE CACHE  Dedicated cache role  Add a Cache Worker Role project to the cloud project  Configure number of instances and size  Co-located cache  Open the Caching tab in the role’s properties, and select the Enable Caching option  Specify cache size (percentage of memory)  In the application  Add the Windows Azure Caching NuGet package  Configure the role name running the cache 22 FeaturesPros/ConsTopologySteps
  • 22. www.devconnections.com CACHING IN WINDOWS AZURE WINDOWS AZURE IN-ROLE CACHE Benchmark 23
  • 23. www.devconnections.com CACHING IN WINDOWS AZURE MEMCACHED Open source, in-memory key-value cache 24
  • 24. www.devconnections.com CACHING IN WINDOWS AZURE MEMCACHED  Simple CRUD API  Data is stored in binary form  Item eviction (LRU and absolute)  Features extended by client libraries  Clustering  Sliding eviction  Replaceable serializers  Data compression 25 FeaturesPros/ConsTopologySteps
  • 25. www.devconnections.com CACHING IN WINDOWS AZURE MEMCACHED  Pros  Well-known solution, used by many sites  Has many client libraries (C++, Java, PHP, .NET, Ruby …)  Supports clustering (managed by the client library)  Cons  Item size limited to 1 MB  Retrieve only by ID, no query support  Windows port a bit old (1.4.4 from 2009)  Replication not supported in most client libraries  No security – public endpoints are problematic (Security supported with SASL on Linux VMs) 26 FeaturesPros/ConsTopologySteps
  • 26. www.devconnections.com CACHING IN WINDOWS AZURE MEMCACHED 27 Other Roles Memcached Worker Roles Cloud Service FeaturesPros/ConsTopologySteps
  • 27. www.devconnections.com CACHING IN WINDOWS AZURE MEMCACHED  Cache service  Create a new worker role  Add an internal endpoint in the role’s properties for port 11211  Configure number of instances and size  Worker role  Add the WazMemcachedServer NuGet package  Add a bit of code (2 lines) to run the cache service  In the application  Add the EnyimMemcached NuGet package  Add some code to create the client configuration 28 FeaturesPros/ConsTopologySteps
  • 28. www.devconnections.com CACHING IN WINDOWS AZURE MEMCACHED var configuration = new MemcachedClientConfiguration(); foreach (var instance in RoleEnvironment.Roles["MemcachedServer"].Instances) { IPEndPoint endpoint = instance.InstanceEndpoints["MemcachedEP"].IPEndpoint; configuration.Servers.Add(endpoint); } var client = new MemcachedClient(configuration); 29 FeaturesPros/ConsTopologySteps
  • 29. www.devconnections.com CACHING IN WINDOWS AZURE MEMCACHED Benchmark 30
  • 30. www.devconnections.com CACHING IN WINDOWS AZURE REDIS Open source, advanced key-value store 31
  • 31. www.devconnections.com CACHING IN WINDOWS AZURE REDIS  Stores entities, lists, and sets  Item eviction (LRU, absolute, and sliding)  Item locking  Atomic transactions for groups of commands  Built-in Pub/Sub messaging  Cache can be persisted periodically or consistently 32 FeaturesPros/ConsTopologySteps
  • 32. www.devconnections.com CACHING IN WINDOWS AZURE REDIS  Pros  Supports various data types  Windows version is up-to-date  Data is replicated to slave servers for high- availability  Secured with authentication  Cons  Single threaded, requests are served sequentially  Transport is not encrypted  Does not support clustering 33 FeaturesPros/ConsTopologySteps
  • 33. www.devconnections.com CACHING IN WINDOWS AZURE Cloud Service REDIS 34 Redis Slave Replication Redis Master Virtual Machine Cloud Service VirtualNetwork Other Roles FeaturesPros/ConsTopologySteps
  • 34. www.devconnections.com CACHING IN WINDOWS AZURE REDIS  Run the deployment tool from ossonazure.interoperabilitybridge.com  Wait 20 minutes while it executes  Give up and press Ctrl+C  Open Visual Studio and do it manually 35 FeaturesPros/ConsTopologySteps
  • 35. www.devconnections.com CACHING IN WINDOWS AZURE REDIS  Create a cloud project with two worker roles: RedisMaster and RedisSlave  Configure roles  Add an internal endpoint for port 6379  Set instance sizes  Set number of slave instances  In both worker roles  Add the redis-server.exe and redis.conf files  Add code to run the redis-server.exe using Process.Start() 36 FeaturesPros/ConsTopologySteps
  • 36. www.devconnections.com CACHING IN WINDOWS AZURE REDIS  In the slave worker role  Write code to edit the redis.config and set the master’s IP address  In the application  Add the ServiceStack.Redis NuGet package  Use either the RoleEnvironment or a static IP address to configure the master’s address 37 FeaturesPros/ConsTopologySteps
  • 37. www.devconnections.com CACHING IN WINDOWS AZURE REDIS Benchmark 38
  • 38. www.devconnections.com CACHING IN WINDOWS AZURE COUCHBASE Open source document database 39
  • 39. www.devconnections.com CACHING IN WINDOWS AZURE COUCHBASE  Entities stored as either binary or JSON  Item eviction (absolute and sliding)  No LRU, it’s a database  Bulk get  Cache (bucket) per application  Indexing and querying with views  Views can use reduce functions 40 FeaturesPros/ConsTopologySteps
  • 40. www.devconnections.com CACHING IN WINDOWS AZURE COUCHBASE  Pros  Replication and clustering  Buckets can be Couchbase or Memcached based  Couchbase buckets are persisted (enables warmup)  Secured (transport + authentication)  Web administration  Provides usage statistics  Cons  Requires a virtual machine and a virtual network  Query requires serializing content to JSON  Not totally free 41 FeaturesPros/ConsTopologySteps
  • 41. www.devconnections.com CACHING IN WINDOWS AZURE COUCHBASE 42 Replication & Clustering Virtual Machine Cloud Service VirtualNetwork Couchbase VMs On-premises VPN FeaturesPros/ConsTopologySteps
  • 42. www.devconnections.com CACHING IN WINDOWS AZURE COUCHBASE  Create a virtual network  Create VMs in the virtual network  In each VM  Install Couchase  Configure incoming firewall rules (11211, 11210, 4369, 8091, 21100-21199)  Configure Couchbase cluster 43 FeaturesPros/ConsTopologySteps
  • 43. www.devconnections.com CACHING IN WINDOWS AZURE COUCHBASE  In the application  Add the CouchbaseNetClient NuGet package  Configure the VMs addresses and port  If application is running in a cloud service  Add a <NetworkConfiguration> element in the ServiceConfiguration.Cloud.cscfg  Configure the role to use the same virtual network as the Couchbase VMs 44 FeaturesPros/ConsTopologySteps
  • 44. www.devconnections.com CACHING IN WINDOWS AZURE COUCHBASE <NetworkConfiguration> <VirtualNetworkSite name="CachingNetwork" /> <AddressAssignments> <InstanceAddress roleName="AzureCacheClientDemo"> <Subnets> <Subnet name="Compute" /> </Subnets> </InstanceAddress> </NetworkConfiguration> 45 FeaturesPros/ConsTopologySteps
  • 45. www.devconnections.com CACHING IN WINDOWS AZURE COUCHBASE Benchmark 46
  • 46. www.devconnections.com CACHING IN WINDOWS AZURE BENCHMARK COMPARISON 47
  • 47. www.devconnections.com CACHING IN WINDOWS AZURE OTHER CACHING OPTIONS  Install on-premises caching solutions on Virtual Machines  Use either Windows or Linux VMs  Easily accessible by clients running in the same virtual network  External access may require additional configuration  Use other cache-as-a-service solutions  Prefer services that use Windows Azure – better throughput  Redis and Memcached are currently available as a service in Windows Azure (http://garantiadata.com) 48
  • 48. www.devconnections.com CACHING IN WINDOWS AZURE THE GOTCHAS  Security  Private vs. Public vs. Virtual network  Clustering  Public endpoint load balancing  Debugging  Deployed cache vs. Windows Azure Emulator  VM restarts  Cache resets due to guest/host upgrades  Price  Choose the proper instance size 49
  • 49. www.devconnections.com CACHING IN WINDOWS AZURE RESOURCES 50 Windows Azure Cache bit.ly/appfabric-on-azure bit.ly/azure-caching-memcached Memcached memcached.org bit.ly/memcached-on-azure Redis redis.io bit.ly/redis-on-azure bit.ly/redis-on-azure-linux Couchbase www.couchbase.com bit.ly/couchbase-on-azure idof@sela.co.il @idoflatow http://bit.ly/flatow-blog This presentation: sdrv.ms/17s8osK