Elastic Cache
Elastic Cache
What is Cache?
▪ Caching is a technique to store frequently accessed
information in a temporary memory location on a server.
Read-intensive web applications are the best use-case
candidates for a cache service.
▪ There are a number of caching servers used across
applications, the most notable are Memcached, Redis, and
Varnish
2
Caching
There are various ways to implement caching using those technologies.
▪ ElastiCache can be used to significantly improve latency and throughput for many
read-heavy application workloads
4
What is ElastiCache ?
▪ Caching improves application performance by storing critical pieces of data in
memory for low-latency access.
▪ ElastiCache is a good choice if your database is particularly read heavy and not
prone to frequent changing.
5
ElastiCache - DBCache
6
ElastiCache – User Session Store
• User logs into any of the
application.
7
AWS has MemCached and Redis
8
MemCached & Redis
▪ Memcached is an open source, distributed, in-memory key-value store-caching
system for small arbitrary data streams flowing from database calls, API calls, or
page rendering. Memcached has long been the first choice of caching technology
for users and developers around the world.
9
MemCached & Redis
▪ Memcached is a High-performance, distributed memory object caching system,
intended for use in speeding up dynamic web applications.
▪ Redis In-memory data structure store used as database, cache and message broker.
ElastiCache for Redis offers Multi-AZ with Auto-Failover and enhanced robustness.
10
Redis
11
Redis: Shards
▪ A shard (API/CLI: node group) is a collection of one to six Redis
nodes(1 primary + 5 replicas)
▪ A Redis (cluster mode disabled) cluster will never have more than one
shard.
▪ Redis (cluster mode enabled) clusters can have from 1 to 90 shards
▪ You can create a cluster with higher number of shards and lower
number of replicas totaling up to 90 nodes per cluster
▪ The node or shard limit can be increased to a maximum of 250 per
cluster
12
Redis Topology
13
Redis Topology
14
Redis Cluster-mode enabled vs disabled
15
Elasticache Encryption
16
What is ElastiCache ?
▪ The same way RDS is to get managed Relation Databases..
▪ ElastiCache is to get managed Redis or Memcached.
▪ Caches are in-memory databases with really high performance, low latency
▪ Helps reduce load off of databases for read intensive workloads
▪ Write Scaling using Sharding
▪ Read Scaling using read Replicas
▪ Multi AZ with Failover Capability.
▪ AWS takes care of OS maintenance / Patching, optimizations, setup, configurations,
monitoring, failure recovery and backups
17
Redis Overview
▪ Redis is an in-memory key-value store
▪ Super low latency (sub ms).
▪ Cache survive reboots by default (its called persistence)
▪ Great to host
▫ User sessions
▫ LeaderBoard (gaming)
▫ Relieve pressure on DB (such as RDS)
▫ Pub / Sub capability for messaging
▪ Multi AZ with Automatic Failover for DR if you don’t want to lose your cache data
▪ Support for Read Replicas
18
Redis
▪ Redis implements six fine-grained policies for purging old data, while Memcached uses the
LRU (Least Recently Used) algorithm.
▪ Redis supports key names and values up to 512 MB, whereas Memcached supports only 1
MB.
▪ Redis uses a hashmap to store objects whereas Memcached uses serialized strings.
▪ Redis provides a persistence layer and supports complex types like hashes, lists (ordered
collections, meant for queue), sets (unordered collections of non-repeating values), or
sorted sets (ordered/ranked collections of non-repeating values).
▪ Redis is used for built-in pub/sub, transactions (with optimistic locking), and Lua scripting.
▪ Redis 3.0 supports clustering.
19
Elasticache Usage patterns
▪ Session Management
▪ Database Caching
▪ Streaming data analytics
▪ APIs
▪ IOT
▪ Social media
▪ Standalone databases
▪ Publisher / Subscriber
20
Elasticache Redis Usage patterns
21
Memcached Overview
▪ Memcached is an in-memory object store
▪ Cache doesn't survive reboots
Use cases
▫ Quick retrieval of objects from memory
▫ Overall, Redis has largely grown in popularity and has better feature sets than
Memcached.
▪ I would personally only use Redis for caching needs.
▪ AWS exam wouldn’t ask if Redis or Memcached is better. Just ElastiCache in
general.
22
Memcached VS Redis
23
Elasticache Patterns
▪ ElastiCache is helpful for read-heavy application workloads
24
Lazy Loading – Load only When
necessary
25
Write Through- Add or Update when database
is update
26
Exam Tips
▪ Use ElastiCache to increase database and web application performance.
▪ Redis is Multi-AZ
▪ You can do backups and restored of Redis
▪ If you need to scale horizontally use Memcached.
▪ ElastiCache manage applications session state.
▪ Typically you will be given a scenario where a particular database is under lot of stress/load .
You may be asked which service you should use
ElastiCache is a good answer if your database is particularly read heavy and not prone to
frequent changes
27