© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in...
Upcoming SlideShare
Loading in …5
×

AWS Webcast - Accelerating Application Performance Using In-Memory Caching in AWS

1,659 views
1,532 views

Published on

This webinar covers both introductory as well as advanced topics related to ElastiCache and is intended for current memcached users as well as those already using ElastiCache. During this session we will go over various scenarios and use-cases that can benefit by enabling caching, discuss the features provided by ElastiCache, and review best-practices, design patterns, and anti-patterns related to ElastiCache. The webinar will also include a demo where we enable ElastiCache for a web application and show the resulting performance improvements.

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,659
On SlideShare
0
From Embeds
0
Number of Embeds
460
Actions
Shares
0
Downloads
71
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

AWS Webcast - Accelerating Application Performance Using In-Memory Caching in AWS

  1. 1. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Accelerating Application PerformanceUsing In-Memory Caching in AWSOmer Zaki (omerz@amazon.com)Shakil Langha (slangha@amazon.com)
  2. 2. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.AgendaCaching OverviewMemcachedAmazon ElastiCacheUse Cases & Design PatternsDemo
  3. 3. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.A Typical Web ApplicationWebServerDBServerUsersWeb ServerDatabase Server
  4. 4. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.A Typical Web ApplicationWebServerDBServerStep 1: Users hit your web app
  5. 5. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.A Typical Web ApplicationWebServerDBServerStep 1: Users hit your web appStep 2: The Web App queries the Database
  6. 6. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.A Typical Web ApplicationWebServerDBServerStep 1: Users hit your web appStep 2: The Web App queries the DatabaseStep 3: The Database returns the Result
  7. 7. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.A Typical Web ApplicationWebServerDBServerStep 1: Users hit your web appStep 2: The Web App queries the DatabaseStep 3: The Database returns the ResultStep 4: The Web App returns the Page
  8. 8. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.A Typical Web ApplicationWebServerDBServerStep 5: You scale Web and Database ServersWebServerDBServerWebServerDBServer
  9. 9. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.A Typical Web ApplicationWebServerDBServerStep 5: You scale Web and Database ServersStep 6: Now What?WebServerDBServerWebServerDBServer
  10. 10. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.A Typical Web ApplicationWebServerDBServerStep 5: You scale Web and Database ServersStep 6: Now What?Step 7: Use a CacheWebServerWebServerDBServerCache
  11. 11. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.What is a Cache?Component that stores frequently accessed data in memoryRequests for data in the cache are returned fasterBenefits:• Faster responses for cached data• Reduces load on your database
  12. 12. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Why Use a Cache?For a majority of web applications, workloads are readheavy• Often as high as 80-90% reads vs. writesMemory is orders of magnitude faster than disk• Latency can be reduced from milliseconds to microseconds
  13. 13. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Caching: An ExampleExample: Get John Smith’s Phone NumberFirst Time:Cache = {}Step 1: Look in the cache. It’s empty; ‘cache miss’Step 2: Get the value from the DB; update the cache
  14. 14. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Caching: An ExampleExample: Get John Smith’s Phone NumberSecond Time:Cache = {‘John Smith’ : ‘206-555-1212’}Step 1: Look in the cache. Return the result; ‘cache hit’Step 2: Until John’s number changes, we don’t hit the DB
  15. 15. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Caching: An ExampleExample: John gets a new phone number – ‘415-555-1212’Cache Invalidation:Cache = {‘John Smith’ : ‘206-555-1212’} (out of date)Step 1: Update Database with John’s new numberStep 2: Update the cache with John’s new numberCache = {‘John Smith’ : ‘415-555-1212’}
  16. 16. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Caching: Pros & ConsPros• Speed up applications, especially if they are read-intensive• Reduce load on your database serversCons• Requires a change in application architecture• Application needs to ensure data in the cache is current
  17. 17. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.AgendaCaching OverviewMemcachedAmazon ElastiCacheUse Cases & Design PatternsDemo
  18. 18. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Memcached: OverviewMemcached (read: mem-cache-dee)Free, open-source, high-performance, in-memory key valuestoreDeveloped for LiveJournal in 2003Used by many of the worlds top websites:• YouTube, Facebook, Twitter, Pinterest, Tumblr, …
  19. 19. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Memcached: ArchitectureServers with key-value associativearraysClient software populates the arrayand queries itClients know about all the serversServers don’t communicate witheach otherLeast Recently UsedNo persistenceSource: http://architects.dzone.com/news/notes-memcached
  20. 20. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Memcached: Storing DataStores arbitrary data• HTML snippets• Database query results• Computed resultsKeys are limited to 250 bytesValues are limited to 1Mb
  21. 21. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.AgendaCaching OverviewMemcachedAmazon ElastiCacheUse Cases & Design PatternsDemo
  22. 22. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Amazon ElastiCacheWeb service that lets you easilycreate and use cache clusters inthe cloud100% Memcached compatibleManaged, scalable, securePay-as-you-go, and flexible, soyou can add capacity when youneed it
  23. 23. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Amazon ElastiCache: BenefitsEasy toDeployDeploy multi-node cacheclusters with afew buttonclicks or APIcallsEasy toMigrate100%MemcachedcompatibleExisting codewill work whenyou updateserver listsEasy toAdministerAutomaticallyreplaces failednodes andpatchessoftwareCloudWatchenables you tomonitor cacheperformancemetricsEasy toScaleAdd or removecache nodeswith a fewbutton clicks,or API callsEasy toSecureWorks wellwith EC2 andDB Securitygroups whichmeans thecache issecure
  24. 24. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.AgendaCaching OverviewMemcachedAmazon ElastiCacheUse Cases & Design PatternsDemo
  25. 25. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Common Use CasesSocial networksGamingMedia and News SitesQ&A PortalsE-CommerceRecommendation EnginesMobile app back-ends
  26. 26. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Sample Deployment: GamingAuto-scaling front endAmazon ElastiCacheAmazon RDSAmazon S3Amazon CloudFront
  27. 27. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Common Design PatternsDatabase offloading• Allows web apps to scale independent of backend data tierSession management for transient data• Increment/decrement high scores for gaming environmentsIn memory storage for difficult / time consuming tasks• Picture ids for all pictures tagged with a particular keyword
  28. 28. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Anti-PatternsBuild application logic assuming cachehit latencyPut objects into cache without Time-To-Live set (TTL)Sequentially sending single operationsto cache (avoiding usage of batchedoperations)Configuring Memcached client to useRedistribute Failure mode forElastiCache cache nodesResolving DNS only once.Failing application request for cachemiss.Using Memcached as a durable store.Not designing application error pathsregarding cache operations• Connection timeouts, operationtimeouts, etc.
  29. 29. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Best PracticesShare Memcached Client objects in applicationUse TTLs (short TTLs)Consider Memory for Connections OverheadUse CloudWatch Alarms / SNS AlertsUse Consistent HashingUse Auto Discovery
  30. 30. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.AgendaCaching OverviewMemcachedAmazon ElastiCacheUse Cases & Design PatternsDemo
  31. 31. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Adding Caching to a Web AppExisting Web App running in EC2• Using RDS MySQL databaseSteps1. Create ElastiCache Cluster with 2 cache nodes2. Modify the Web App to use Caching
  32. 32. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Create Cache Cluster: Cluster Specification
  33. 33. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Create Cache Cluster: Security / Parameters
  34. 34. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Create Cache Cluster: Cluster Created
  35. 35. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Modify Web App to use CachingInitializationimport memcacheCACHE_NODES = [hostname1:port1,hostname2:port2]mc = memcache.Client(CACHE_NODES)Key LookupKEY = "demo.key"KEY_EXPIRY_SECONDS = 60value = mc.get(key)if (not value):value = getDataFromExistingLogic()#retrieve from existing app logic -database, filesystem, other processingmc.set(key, value, time =KEY_EXPIRY_SECONDS)return value
  36. 36. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Web App with Caching
  37. 37. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Performance ImprovementPerformance run using Multi-Mechanize• Runtime: 600 seconds• Time-series interval: 5 seconds• ElastiCache usage configured to start at 200 seconds mark
  38. 38. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Performance Improvement
  39. 39. © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.Questions

×