caching-and-system-tradeoffslisted
Install: claude install-skill rustcircle/c101
# Caching and system trade-offs
Quantitative design: state the workload, compute, then choose. Latency constants and benchmarking
method live in `performance-optimization`; timeouts, retries with jitter, breakers and rate limits in
`resilience-patterns`; replication guarantees in `distributed-consensus-consistency`; database-side
concurrency in `database-transactions-isolation`; ADR format in `docs-and-adr-writing`.
## 1. Frame the trade-off
- Axes: latency (p50 and p99), throughput, consistency (maximum staleness), cost, durability,
availability, operability (failure modes, on-call load).
- Workload: read/write ratio, number of keys N, popularity skew (fit Zipf s from the log-log
rank-frequency slope of an access log), object size distribution, peak QPS, update rate, and the
staleness each endpoint tolerates.
- SLOs the design must meet, per endpoint.
- Write every decision as "accept X to gain Y, measured by Z", and note whether it is reversible and
at what cost.
## 2. Back-of-envelope procedure
| Quantity | Formula | Example |
|---|---|---|
| Bandwidth | QPS x object size | 20k/s x 4 KB = 80 MB/s, about 640 Mbit/s |
| Working set | distinct keys per window x size | 200k x 4 KB = 0.8 GB |
| Concurrency (Little's law) | L = lambda x W | 20k/s x 50 ms = 1,000 requests in flight |
| Queueing (M/M/1) | W = S / (1 - rho), rho = lambda / mu | rho 0.5: 2S; 0.7: 3.3S; 0.8: 5S; 0.9: 10S; 0.95: 20S |
| Fan-out tail | P(some call slow) = 1 - p^n | 100 calls at p99: 1 - 0.