Elasticache 101

What is elasticache?

Elasticache is a web service that makes it easy to deploy, operate, and scale an in-memory cache in the cloud. It improves the performance of web applications by allowing you to retrieve information from a fast, managed, in-memory caches instead of relying on slower disk-based databases.

Can be used to dignificantly improve latency and throughput for many read-heavy application workloads

  • Social Media
  • Networking
  • Gaming
  • Media Sharing
  • Q&A Portals

Can also be used for compute heavy workloads like a recommendation engine.

  • Caching improves application performance by storing critical pieces of data in memory for low-latency access.
  • Cached information may include the results of I/O intensive database queries or the results of computationally intensive calculations

Types of Elasticache

  • MemcacheD
    • Widely adopted memory object caching system
    • Elasticache is protocol compliant with MemcacheD, so popular tools that you use today with existing Memcached environments will work seamlessly with the service
  • Redis
    • Popular open-sourc ein memory key value store that supports data structures such as sorted sets and lists
    • Elasticache supports master/slave replication and Multi-AZ which can be used to achieve cross AZ redundancy

For Multi AZ access - USE REDIS. If you are not concerned about redundancy - USE MEMCACHED They both appear similar on the surface (both in memory key stores), but they are quite different

Redis

  • Because of the replication and persistence features of Redis, Elasticache manages Redis more as a relational database.
  • Redis Elasticache clusters are managed as stateful entities that include failover, similar to how Amazon RDS manages Database Failover

Redis Use Cases

  • More advanced data types, such as lists, hashes and sets
  • Sorting and ranking datasets in memory, such as with LEADERBOARDS
  • Persistence of your key store is important
  • Run in multiple AWS Availability Zones with failover

Memcached

  • Because it is esigned as a pure caching solution with no persistence, elasticache manages memcached nodes as a pool that can grow and shrink, similar to an EC2 auto scaling group.
  • Individual nodes are expendable, and Elasticache provides additional capabilities such as automatic node replacement and Auto Discovery

MemcacheD Use Cases

  • Object caching your primary goal, for example to offload your database
  • As simple a caching model as possible
  • Are you planning on running large cache nodes, and require multithreaded performance with utilization of multiple cores?
  • Ability to scale your cache horizontally as you grow

ElastiCache Exam Tips

  • Given a scenario where a particular database is under a lot of stress/load, which service should you use to alleviate this?
    • Elasticache is a good choice if your database is particularly read-heavy and not prone to frequent changing
      • Take stress off of DB because it is read heavy
    • RedShift is a good answer if the reason your database is feeling stress is because management keep running OLAP (OnLine Analytics PRocessing) transactrions on it etc
      • Data Warehousing

--

Redis Use Cases

  • More advanced data types, such as lists, hashes and sets
  • Sorting and ranking datasets in memory, such as with LEADERBOARDS
  • Persistence of your key store is important
  • Run in multiple AWS Availability Zones with failover

--

MemcacheD Use cases

  • Object caching your primary goal, for example to offload your database
  • As simple a caching model as possible
  • Are you planning on running large cache nodes, and require multithreaded performance with utilization of multiple cores?
  • Ability to scale your cache horizontally as you grow

Extras

  • If you have a 3 teiered web app with a classic load balancer, an ASG, and an RDS database and users are having to re-authenticate
    • To make app teir stateless and outsource the session information
      • Use Elasticache Clusters
      • In order to provide a shared data storage for sessions that can be accessible from any individual web server, you can abstract the HTTP sessions from the web servers themselves. A common solution to for this is to leverage an ElastiCache service offerings which is an In-Memory Key/Value store such as Redis and Memcached.
      • https://aws.amazon.com/caching/session-management/