Disk is fast, memory is slow. Forget all you think you know
summary
Goal is to aggregate Prometheus counters across multiple Ruby processes while keeping increments extremely cheap, with a target of 1 microsecond per increment. Experiments: PStore (serialize whole hash — unusably slow), Redis (localhost roundtrip ~60μs), mmap via a C gem (about 6 microseconds but unstable, causing mmap segfaults), and simple file writes (seek + write 8 bytes ≈ 9 microseconds). Chosen solution: plain file-backed bytes—slower than mmap but robust, C-free, JRuby-compatible, and fast enough for the use case.
AI-written summary · about
chapters (6)
- 0:00Introduction and context
- 3:27Prometheus metrics in Ruby
- 10:25Fast and slow are relative
- 18:08Experiments with memory maps
- 22:01Disk is fast in this context
- 24:28Question assumptions and measure
related talks
39mDisk is fast, memory is slow. Forget all you think you know
43mReal World Ruby Performance at Scale
37mCache is King: Get the Most Bang for Your Buck From Ruby
33mI Made a Slow Thing Fast
41mRuby for Distributed Storage System
33mCache is King: Get the Most Bang for Your Buck From Ruby
39m"300x faster ruby"
31mProcessing data: Ruby or SQL?
