Elasticache Flashcards
What are some key differences between Reddis and Memcached?
Memcached: Key/Value pairs. Multithreaded. Good for simpler cache use cases.
Reddis: Complex data types and structures. Can be persisted to disk, can sort and rank data.
What are the 2 engines used by elasticache
Reddis and Memcached
Can a write through cache be stale?
No. With a write through cache as data is written to the database, it is also written to the cache - the cache is therefore always current
Is Elasticache multi-AZ for both Reddis and Memcached?
yes to both
I need a multithreaded in memory cache - would I use Memcached or Reddis?
Memcached is multi threaded
Which cacheing engine supports complex datatypes, ket store persistence and read replicas for read intensive applications?
Reddis
Would we expect reads in an application using write through cache to be faster or slower than those for lazy loading?
Faster - as cache is kept up to date
What is a DISADVANTAGE of using lazy loading (aka cache aside/lazy population)
Data can become stale when using a lazy loading strategy. As lazy loading is read based, if it finds a hit in the cache it will use that - however if the underlying data in the database has changed, this data will be out of date.
Also, there is a read penalty that is incurred with lazy loading.
For lazy loading, how many round trips occur and to where when there is a cache miss?
- First round trip is to the cache to return the miss. Second round trip is to the database to select the data. Third round trip is back to the cache to update it.
Describe this code and the caching strategy it reflects:
def get_user(user_id) record=cache.get(user_id) if record is None: record=db.query("select * from users where Id=?", user_id ) cache.set(user_id, record) return record else: return record
user=get_user(12)
This represents a lazy loading cache strategy. Here, we attempt to retrieve the user_id from the cache. If its a miss (record is None) we execute a select against the db and write the result back to the cache and then return it from the function
Does memcached allow for data persistence?
No, it is in memory only. If the node goes down the data is lost
What scaling actions will you need to take if you are seeing a large number of cache evictions due to memory constraints?
Its likely you will need to scale up or scale out.
Who is responsible for a cache invalidation strategy?
As the developer - you are.
When starting a memcached elasticache cluster, will the cache be empty. What about for reddis?
Memcached will always start empty. Reddis can be restored from backup
Which elasticache engine is multi-threaded
Memcached