Elasticache Flashcards
What is Elasticache?
Web service that acts as an in memory cache in the cloud. Improves performance of web apps and latency and throughput for ready heavy apps.
What are the 2 open source in memory caching engines used by Elasticache?
Memcached
Redis
Describe Memcached
ElasticCache Widely adopted
Not persistent (pool can grow or shrink)
Multi-threaded
No Multi-AZ
What is a use case of memcached?
Object caching
Want a simple caching model
Need multi-threaded performance (large cache loads)
Scale Horizontally
Describe Redis
ElasticCache
Popular open source key value store
Multi-AZ supported
Managed like Relational Databases
What are use cases for Redis?
Need to cach advanced data types (lists, hashes, sets)
Sorting and ranking datasets in memory (leadership)
Need persistence of key store
Need to run in Multi-AZ zones
Management keeps running OLAP transactions data warehousing
What are the two caching strategies of Elasticache?
Lazy Loading
WriteThrough
Describe Lazy Loading
Caches only when necessary. If the item is not in the cache and return null goes and gets the item from the DB.
Advantages and Disadvantages of Lazy Loading
Advantages
- Only requested data is cached
- Node failure is not a problem
Disadvantage
- Cache miss penalty
- Initial request -> query to database -> write to cache
- Data can become stale (only update on cache miss)
Describe WriteThrough caching
Add or update data in a cache when anything is written to the database
Advantages and Disadvantages of WriteThrough caching
Advantages
- data is never stale
- more tolerant of additional latency
Disadvantage
- Write penalty (every write involves wrtie to db)
- If node fails. Have to midigate by implementing lazy loading in conjunction with writeThrough.
- Wasted resources if mos of data is never read
When to use elasticache for Dynamo
If need lazy loading
When a data set is under a lot of stress what can you use to elevate some of the stress?
Elasticache