Caching Flashcards

1
Q

Why is caching important?

A

it helps make better use of the resources you have, and makes calls faster

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Locality of Reference Principle

A

recently requested data is likely to be requested again

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Where is a cache usually found?

A

closest to the front end to return data quickly without using downstream resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an application server cache?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the benefits of using an application server cache?

A

caches can be in memory, which is super fast, or on a node’s local disk, which is faster than network storage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some tradeoffs of using an application server cache?

A

it performs worse the more the load balancer distributes the load (ie as there are more nodes, it gets worse)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a distributed cache?

A

each node owns part of the cached data, which is divided up using a hashing function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the benefits of using a distributed cache?

A

you can easily increase cache space by adding nodes to the pool

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are some tradeoffs of using a distributed cache?

A

if a node is missing, there is an automatic cache miss

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How could you resolve an issue with a missing node in a distributed cache?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a global cache?

A

all nodes use a single cache space, treats cache like a local one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does a global cache require?

A

a server or file store that is faster than the original store and accessible by all request layer nodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are some benefits of using a global cache?

A

it’s very effective in some architectures, like ones with specialized hardware or a fixed dataset that needs to be cached

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are some tradeoffs of using a global cache?

A

it can get complicated as the number of clients and requests increase

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the two forms of a global cache?

A
  1. 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)
  2. 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a CDN?

A

content distribution network, used for serving large amounts of static media

17
Q

What is cache invalidation?

A

when data is modified in the database, it needs to be marked as invalid in the cache

18
Q

What is a write-through cache?

A

data is written into the cache and the database at the same time

19
Q

What are some benefits of a write-through cache?

A

allows for fast retrieval and loses nothing if the system is disrupted

20
Q

What are some tradeoffs of a write-through cache?

A

there is higher latency for write operations

21
Q

What is a write-around cache?

A

data is written directly to permanent storage, bypassing the cache

22
Q

What are some tradeoffs of a write-around cache?

A

a read request for recently written data will result in a cache miss

23
Q

What is a write-back cache?

A

data is only written to the cache, and completion is confirmed immediately to the client. write to permanent storage is done in batches

24
Q

What are some benefits to a write-back cache?

A

low latency and high throughput

25
Q

What are some tradeoffs of a write-back cache?

A

risk of data loss if the system is disrupted

26
Q

What is FIFO?

A

First In, First Out, evicts first block accessed

27
Q

What is LIFO?

A

Last in, First out, evicts the block accessed most recently

28
Q

What is LRU?

A

Least Recently Used, discards least recently used items first

29
Q

What is MRU?

A

Most Recently Used, discards most recently used items first

30
Q

What is LFU?

A

Least Frequently Used, counts how often an item is needed and discards least used first

31
Q

What is RR?

A

Random Replacement, randomly select an item to discard when space is needed