Skip to content

Shard your locks: benchmarking 6 Go cache designs

7.8 relevance
Score Breakdown
technical depth
9
novelty
7
actionability
8
community
7
strategic
5
personal
9

Scored daily by a customisable AI persona to surface the most relevant engineering leadership news.

Go cache design benchmarks with lock sharding, directly applicable to platform engineering and system design

General strebkov.dev
Summary

Benchmarked across 1-8 cores with 1M keys on a pinned i7-14700K, a 256-shard striped map (sharded) achieves 6.9x scaling with per-shard mutexes in about 15 lines of code, outperforming a single sync.Mutex by up to 8x. sync.RWMutex plateaus at 2x scaling and is slower for writes, while sync.Map shows great slope but poor absolute throughput. Copy-on-write delivers 87 Mops/s lock-free reads but zero writes due to copying the entire map per set—value size is irrelevant because Go strings are immutable.

Author

Misha Strebkov