Caching Flashcards
Why is caching important?
it helps make better use of the resources you have, and makes calls faster
Locality of Reference Principle
recently requested data is likely to be requested again
Where is a cache usually found?
closest to the front end to return data quickly without using downstream resources
What is an application server cache?
when the cache is placed on the request layer node itself, the node quickly returns local cached data if it exists, otherwise it queries from disk
What are the benefits of using an application server cache?
caches can be in memory, which is super fast, or on a node’s local disk, which is faster than network storage
What are some tradeoffs of using an application server cache?
it performs worse the more the load balancer distributes the load (ie as there are more nodes, it gets worse)
What is a distributed cache?
each node owns part of the cached data, which is divided up using a hashing function
What are the benefits of using a distributed cache?
you can easily increase cache space by adding nodes to the pool
What are some tradeoffs of using a distributed cache?
if a node is missing, there is an automatic cache miss
How could you resolve an issue with a missing node in a distributed cache?
technically you can replicate the information, but that becomes complicated quickly, when really the outcome is that the request just has to pull from the origin
What is a global cache?
all nodes use a single cache space, treats cache like a local one
What does a global cache require?
a server or file store that is faster than the original store and accessible by all request layer nodes
What are some benefits of using a global cache?
it’s very effective in some architectures, like ones with specialized hardware or a fixed dataset that needs to be cached
What are some tradeoffs of using a global cache?
it can get complicated as the number of clients and requests increase
What are the two forms of a global cache?
- when there is a cache miss, the cache is responsible for retrieving the missing piece of data from the store (used the majority of the time)
- when there is a cache miss, the request node is responsible for retrieving the missing data (used in special cases, like when the files are large)