Podcast
Questions and Answers
Which cache eviction strategy removes items that are used least often?
Which cache eviction strategy removes items that are used least often?
- Least Frequently Used (LFU) (correct)
- Least Recently Used (LRU)
- Most Recently Used (MRU)
- Random Replacement (RR)
Most Recently Used (MRU) eviction strategy keeps the most recently accessed items in cache.
Most Recently Used (MRU) eviction strategy keeps the most recently accessed items in cache.
False (B)
What is the main characteristic of the Last In First Out (LIFO) caching method?
What is the main characteristic of the Last In First Out (LIFO) caching method?
It evicts the block accessed most recently first.
The _____ Replacement (RR) strategy discards a randomly selected candidate item to make space.
The _____ Replacement (RR) strategy discards a randomly selected candidate item to make space.
Stale-while-revalidate is a method where outdated content is immediately served to the user while a background update occurs.
Stale-while-revalidate is a method where outdated content is immediately served to the user while a background update occurs.
Match the following caching strategies with their descriptions:
Match the following caching strategies with their descriptions:
In a read-through cache, the cache is responsible for retrieving data from the ______ when a cache miss occurs.
In a read-through cache, the cache is responsible for retrieving data from the ______ when a cache miss occurs.
Which of the following is NOT a benefit of using stale-while-revalidate?
Which of the following is NOT a benefit of using stale-while-revalidate?
What happens when a request is made for content using the stale-while-revalidate technique?
What happens when a request is made for content using the stale-while-revalidate technique?
Match the caching strategy to its description:
Match the caching strategy to its description:
What happens when the latest version of content becomes available in the stale-while-revalidate method?
What happens when the latest version of content becomes available in the stale-while-revalidate method?
Read-through caching is a method primarily used in web browsers.
Read-through caching is a method primarily used in web browsers.
Describe the primary aim of using stale-while-revalidate.
Describe the primary aim of using stale-while-revalidate.
What is the primary purpose of a Content Delivery Network (CDN)?
What is the primary purpose of a Content Delivery Network (CDN)?
A CDN serves content directly from the back-end servers at all times.
A CDN serves content directly from the back-end servers at all times.
What is one way to prepare for a future transition to a CDN?
What is one way to prepare for a future transition to a CDN?
If a CDN doesn't have the requested file locally, it will query the _____ servers.
If a CDN doesn't have the requested file locally, it will query the _____ servers.
What lightweight HTTP server is suggested for serving static media?
What lightweight HTTP server is suggested for serving static media?
CDNs can help reduce the load on back-end servers.
CDNs can help reduce the load on back-end servers.
What action does a CDN take when it has a piece of content available?
What action does a CDN take when it has a piece of content available?
Match the following actions in a CDN setup with their descriptions:
Match the following actions in a CDN setup with their descriptions:
What must happen to cache data when the database is modified?
What must happen to cache data when the database is modified?
Cache invalidation is not necessary if the database is updated frequently.
Cache invalidation is not necessary if the database is updated frequently.
What is the primary benefit of using a write-through cache?
What is the primary benefit of using a write-through cache?
The main purpose of cache invalidation is to maintain _____ between the cache and the database.
The main purpose of cache invalidation is to maintain _____ between the cache and the database.
Match the following cache invalidation schemes with their descriptions:
Match the following cache invalidation schemes with their descriptions:
Which scenario describes a potential problem without cache invalidation?
Which scenario describes a potential problem without cache invalidation?
Data stored in the cache is generally more reliable than data stored in the database.
Data stored in the cache is generally more reliable than data stored in the database.
What is a possible consequence of a crash or power failure when using a write-through cache?
What is a possible consequence of a crash or power failure when using a write-through cache?
What happens during a cache miss?
What happens during a cache miss?
The read-aside cache strategy simplifies application code because it automatically updates the cache.
The read-aside cache strategy simplifies application code because it automatically updates the cache.
What is the primary benefit of writing to permanent storage after specified intervals?
What is the primary benefit of writing to permanent storage after specified intervals?
Why might an application choose to implement a read-aside cache strategy?
Why might an application choose to implement a read-aside cache strategy?
In the FIFO cache eviction policy, the cache evicts the first block __________.
In the FIFO cache eviction policy, the cache evicts the first block __________.
Writing data directly to permanent storage eliminates the risk of data loss in the case of a crash.
Writing data directly to permanent storage eliminates the risk of data loss in the case of a crash.
What characteristic does a read-aside cache provide to an application?
What characteristic does a read-aside cache provide to an application?
What happens when a purge request is received?
What happens when a purge request is received?
The two common cache invalidation methods are ___ and ___.
The two common cache invalidation methods are ___ and ___.
Cache eviction policies have no impact on application performance.
Cache eviction policies have no impact on application performance.
What must an application do when a cache miss occurs?
What must an application do when a cache miss occurs?
What does the refresh method do in cache invalidation?
What does the refresh method do in cache invalidation?
Match the cache eviction policies with their definitions:
Match the cache eviction policies with their definitions:
The refresh method will use the existing cached content instead of going back to the origin server.
The refresh method will use the existing cached content instead of going back to the origin server.
Match the following cache invalidation methods with their descriptions:
Match the following cache invalidation methods with their descriptions:
What risk is associated with using cache for write-intensive applications?
What risk is associated with using cache for write-intensive applications?
Flashcards
Permanent storage write
Permanent storage write
Writing to permanent storage happens at intervals or under specific conditions.
Low-latency
Low-latency
Achieving quick access to data, ideal for write-intensive applications.
High-throughput
High-throughput
Ability to process a large amount of data quickly.
Data loss risk
Data loss risk
Signup and view all the flashcards
Purge method
Purge method
Signup and view all the flashcards
Refresh method
Refresh method
Signup and view all the flashcards
Cache invalidation
Cache invalidation
Signup and view all the flashcards
Origin server
Origin server
Signup and view all the flashcards
Expired Cache
Expired Cache
Signup and view all the flashcards
Content Fetching
Content Fetching
Signup and view all the flashcards
Stale-while-revalidate
Stale-while-revalidate
Signup and view all the flashcards
Asynchronous Request
Asynchronous Request
Signup and view all the flashcards
Cache Read Strategies
Cache Read Strategies
Signup and view all the flashcards
Read-Through Cache
Read-Through Cache
Signup and view all the flashcards
User Experience
User Experience
Signup and view all the flashcards
Cached Version Update
Cached Version Update
Signup and view all the flashcards
Content Delivery Network (CDN)
Content Delivery Network (CDN)
Signup and view all the flashcards
Static Media
Static Media
Signup and view all the flashcards
Cache
Cache
Signup and view all the flashcards
Local Availability
Local Availability
Signup and view all the flashcards
Back-end Servers
Back-end Servers
Signup and view all the flashcards
Query
Query
Signup and view all the flashcards
Cache Locally
Cache Locally
Signup and view all the flashcards
Subdomain
Subdomain
Signup and view all the flashcards
Last In First Out (LIFO)
Last In First Out (LIFO)
Signup and view all the flashcards
Least Recently Used (LRU)
Least Recently Used (LRU)
Signup and view all the flashcards
Most Recently Used (MRU)
Most Recently Used (MRU)
Signup and view all the flashcards
Least Frequently Used (LFU)
Least Frequently Used (LFU)
Signup and view all the flashcards
Random Replacement (RR)
Random Replacement (RR)
Signup and view all the flashcards
Cache Miss
Cache Miss
Signup and view all the flashcards
Data Retrieval
Data Retrieval
Signup and view all the flashcards
Read-Aside Cache Strategy
Read-Aside Cache Strategy
Signup and view all the flashcards
Complexity in Cache Handling
Complexity in Cache Handling
Signup and view all the flashcards
Cache Usage Optimization
Cache Usage Optimization
Signup and view all the flashcards
Cache Eviction Policies
Cache Eviction Policies
Signup and view all the flashcards
FIFO (First In First Out)
FIFO (First In First Out)
Signup and view all the flashcards
Cache Lifetime
Cache Lifetime
Signup and view all the flashcards
Source of Truth
Source of Truth
Signup and view all the flashcards
Consistent Application Behavior
Consistent Application Behavior
Signup and view all the flashcards
Write-through Cache
Write-through Cache
Signup and view all the flashcards
Data Consistency
Data Consistency
Signup and view all the flashcards
Data Loss Prevention
Data Loss Prevention
Signup and view all the flashcards
Application Behavior Issues
Application Behavior Issues
Signup and view all the flashcards
Cache Maintenance
Cache Maintenance
Signup and view all the flashcards
Study Notes
Caching
- Load balancing scales servers horizontally, but caching optimizes existing resources and makes demanding product requirements feasible.
- Caching leverages the principle of locality of reference—recently requested data is likely to be requested again.
- Caches are integrated into various computing components: hardware, OS, web browsers, web apps, etc.
- Caches function like short-term memory: they have limited space, are often faster than the original source, and store recently accessed data.
- Caches exist at different architectural levels, typically near the front end to quickly return data without affecting downstream processes.
Application Server Cache
- Placing a cache on the request layer node allows local storage of response data.
- Upon request, the node returns locally cached data, if available, otherwise fetches it from the disk.
- Caches can reside both in memory (fast) and on the node's local disk (faster than network storage).
- Scaling to multiple nodes allows each node to have its own cache, but a load balancer distributing requests across different nodes increases cache misses.
Content Delivery Network (CDN)
- CDNs are caches designed for static media-heavy websites.
- A CDN request initially seeks the requested content locally.
- If the content isn't available locally, the CDN queries backend servers, caches the content locally, and serves the content to the user.
- CDNs can be a separate subdomain (e.g., static.yourservice.com) integrated using a lightweight server like Nginx, and DNS can be switched later.
Cache Invalidation
- Maintaining cache coherence with the source of truth (e.g., database) requires cache invalidation.
- If data in the database changes, the cached data should be invalidated to prevent inconsistencies.
Three Main Invalidation Schemes
- Write-through: Simultaneously writes data to the cache and the database; ensures data consistency but has higher latency due to double writes.
- Write-around: Directly writes data to the database, bypassing the cache, reducing latency, but read requests for recently written data will create a cache miss, resulting in slower response.
- Write-back (write-behind): Writes data only to the cache; immediately confirms to the client; writes to the database occurs periodically or under specific conditions. This potentially loses data during failures and has lower latency.
Cache Invalidation Methods
- Purge: Removes cached content for specific objects, URLs, or sets of URLs, typically used when content is updated or changed. A purge request immediately removes the content from the cache, and serves subsequent requests from the origin server.
- Refresh: Updates the cache with the latest version of the data even if cached content is available.
- Ban: Invalidates cached content based on criteria like URL or headers, immediately removing matching data from the cache. Subsequent requests are served from the origin server.
- Time-to-live (TTL): Content in the cache expires after a specified time; the cache checks expiry and re-fetches data if it is expired.
- Stale-while-revalidate (SWI): Serves stale cached content while asynchronously fetching updated data from the origin server; the update results in an updated cache.
Cache Read Strategies
- Read-through: The cache is responsible for retrieving data from the data store on a cache miss. The application requests data from the cache first; on a cache miss, the cache retrieves the data, updates the cache, and returns the data to the application. Simplifies application logic and ensures data consistency.
- Read-aside: The application is responsible for retrieving data from the underlying data store on cache misses. The application first checks the cache: if found, uses cached data; otherwise, retrieves the data, updates the cache, and uses that data. Provides more control over caching but adds complexity to the application code.
Cache Eviction Policies
- First-In, First-Out (FIFO): Evicts the oldest entry in the cache.
- Last-In, First-Out (LIFO): Evicts the most recently added entry.
- Least Recently Used (LRU): Evicts the least recently used entry.
- Most Recently Used (MRU): Evicts the most recently used entry.
- Least Frequently Used (LFU): Evicts the least frequently used entry.
- Random Replacement (RR): Randomly selects an entry to evict.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.