Kill Redis
Kill Redis
Redis answers almost every read of this application, and the database was sized for the few that remain. You choose how the application behaves when Redis cannot be reached. Then you kill Redis and watch where the work goes. Finally you decide what to change, and run the same failure again to compare.
The failure lab needs JavaScript. The healthy system is shown below.
1. Choose how the application reacts
2. Kill Redis
The healthy system runs for a moment, then Redis dies. The run measures the 30 seconds that follow.
- Cache hit
- Cache miss, goes on to the database
- Waits for another request’s read
- Request fails
Each dot stands for many requests. The numbers show the real rate.
Hit ratio 96%: 7.9% of requests reach the database (31.8 reads/s, capacity 200/s).
Sources
Illustrative values, not benchmarks of any real product.
Model notes
Assumptions
- Each request asks for a key drawn independently from a fixed popularity distribution. Real traffic has bursts and trends that this does not capture.
- Every operation on a cache shard (lookups, stores, deletions) joins one queue served by a few slots, so a busy shard slows everything on it.
- The cache restarts empty: everything it held is lost.
Simplifications
- A request waits for the full connect timeout each time the cache is unreachable. Real clients may stop trying for a while after repeated failures, which is what a circuit breaker does.
- An entry’s lifetime starts when it is stored. Reading it does not extend it.
- Only a version number is tracked for each key, not the data. A cached copy is stale when its version is behind the database’s.
- The cache never runs out of memory, so no entry is evicted early. Real caches evict the least recently used entries when they are full.
- A write updates the database and then deletes the cached copy (cache-aside). Write-through and write-behind are compared in the trade-off explorer, not simulated here.
- Refresh before expiry reloads an entry in the background when a request reads it in the last part of its life. Production systems often use a probabilistic variant.
- A cache that goes down loses everything it held and comes back empty. A cache with persistence would not.
- The application learns that the cache is down at once, on the request that fails. Health checks and circuit breakers are not modelled.
- When a caller times out and gives up, the callee still finishes the work, so abandoned requests keep consuming capacity.
Parameter values are illustrative. They are not benchmarks of any real product.
Built by GhaziAlibi.
© ShardCraft. All rights reserved.