System Design · Module 07
Caching and CDNs
- Lessons
- 12
- Free
- 1
- Reading
- ~4 h
Your progress
0 / 12 lessons done
Sign in to trackLessons
- Cache placement: from browser to databaseFreeA cache can remove a database query without removing the slow network trip. Placement determines whose waiting time improves, which systems receive less traffic, and who might see a cached response.
- Caching patterns: cache-aside, write-through and write-backAdding a cache changes more than read speed. You must decide who keeps it current and whether acknowledged changes survive losing it.
- Eviction policies: LRU, LFU and moreA full cache must discard something. The policy determines whether that space serves returning customers or fills with data nobody reads again.
- TTLs: expiring cached dataExpiration settings affect what customers see and how much work reaches your database. You need to understand both before changing a TTL in production.
- Cache invalidation: keeping cached data correctA successful database update can leave customers reading old data. You need to decide which copies become invalid, how to remove them, and what happens when that removal fails.
- Distributed caching: sharing a cache across serversAdding application servers can duplicate cached data and database work. A shared cache changes that behavior, but introduces network calls, routing decisions and a shared failure dependency.
- Cache stampede: many requests hitting the database at onceA cache can remove most database reads and still expose the database to a sudden burst when an entry disappears. You need to control who rebuilds the entry, not only how long it stays cached.
- Hot keys: handling one extremely popular itemA cache can have spare memory and a high hit rate yet still delay requests. One popular item can overload its owner while other cache nodes sit mostly idle.
- Cache race conditions: concurrent reads and writesA successful cache deletion does not stop an older request from putting stale data back. You meet this problem whenever several application instances read and update the same cached records.
- Cache failures and database fallbackA cache outage can overload a healthy database. You need a fallback policy that preserves useful service without sending every failed cache read downstream.
- CDNs: caching content close to usersProduct images and application files often travel farther than the database queries behind a page. A CDN shortens that journey, but its shared copies introduce correctness, security and deployment decisions.
- Design: a fast product catalog pageA popular product page must stay useful during traffic spikes without exposing another customer’s data or treating cached stock as a purchase guarantee. This design connects cache performance to those correctness boundaries.
Practise with
Terms this module teaches 34
Open glossaryAdmission control
Deciding whether work may start before it consumes a limited resource.
Cache admission
The decision to accept an incoming entry into a cache rather than only deciding which resident to remove.
Cache eviction
Removing a resident cache entry to make room within a capacity budget.
Cache generation token
An identifier captured before fetching data and checked atomically before publication, allowing invalidation to revoke earlier fills.
Cache hit
A lookup that finds a stored copy the cache can use for the current request.
Cache hit rate
The fraction of lookups arriving at a cache that it answers using usable stored copies.
Cache invalidation
Declaring that a cached result must no longer answer reads because its source or dependencies changed.
Cache key
The identifier used to find a cached result, including inputs needed to distinguish different results.
Cache miss
A lookup that cannot supply a usable stored copy and requires another source.
Cache race condition
A correctness problem caused by the ordering of overlapping cache reads, fills, invalidations or updates.
Cache replica
A node holding a copy of a cache partition, commonly used to support recovery after its primary fails.
Cache shard
A partition of a cache that owns a subset of its keys.
Cache stampede
A burst of overlapping attempts to rebuild missing or expired cached data.
Cache-aside
A caching pattern where the application checks the cache, reads missing data from the backing store, and fills the cache.
CDN (content delivery network)
A network of servers in many locations that caches content and serves it close to users, so requests travel a shorter distance.
CDN edge
A CDN server or delivery location that handles user requests and can serve reusable cached responses.
Circuit breaker
A mechanism that temporarily stops ordinary calls to a failing dependency and uses limited probes to check recovery.
Database fallback
Reading the authoritative database when a cache cannot supply a usable answer.
Fixed expiration
An expiration policy whose deadline does not move when an entry is read.
Hot key
A key whose traffic places unusually high demand on the resource serving it.
Least frequently used
An eviction policy that prefers removing entries with lower recorded or estimated access frequency.
Least recently used
An eviction policy that removes the resident entry whose most recent access is oldest.
Local cache
A cache held inside an application process or on its machine, rather than in a shared remote service.
Origin
The upstream system that supplies original content when a delivery cache needs to fetch or validate it.
Refill lease
Expiring ownership used to coordinate rebuilding one cache entry across application instances.
Sliding expiration
An expiration policy that extends an entry’s deadline when it is accessed.
Stale fill
An outdated result being stored in a cache, often after an overlapping update invalidated the previous copy.
Stale-while-revalidate
Serving an older cached answer within an allowed stale period while refreshing it in the background.
TTL (time to live)
How long a cached item, DNS record or message stays valid before it expires and has to be fetched again or dropped.
TTL jitter
A deliberate variation in cache lifetimes that spreads expiration deadlines across time.
Write coalescing
Combining pending replacements for the same key so that only the latest required value is persisted.
Write-back
A write policy that accepts a change in a caching layer and persists it to a backing store later.
Write-through
A write policy that waits for the backing-store write and updates the cached representation during the write operation.