Building a Highly Concurrent Cache in Go: A Hitchhiker's Guide
summary
Builds a Redis-fronting in-memory cache that replays 30‑minute production access logs (benchmarks pinned to 5,000 events per run) to compare eviction strategies; finds LRU faster for throughput but a Decaying LFU variant (DFU decaying LFU) improves hit rate. Uses go parallel benchmarks, benchstat and pprof (block and CPU) to find lock contention, then moves eviction to a background goroutine and swaps to xsync.Map + atomics, yielding ~100× faster reads/writes but ~2,000× slower eviction; rolls out with 1–10% sampling and per-lookup context timeouts.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 1:37Dont Panic
- 7:28Cash Replacement Policies
- 11:19Benchmarks
- 20:11DLFU
- 26:01Incremental Progress
- 27:03Context Timeouts
- 28:42SyncMap
- 35:45Benchmark
related talks
37mHow I made a powerful cache system using Go
25mBuild and Test Caching in Go
36mGolang's Realtime GC in Theory and Practice
01h 27mFlash Talks
35mGo and Redis. More than a love story.
37mHow I made a powerful cache system using Go
43mWhere Is My Cache? Architectural Patterns for Caching ...
50mLet's talk about the cache!
