Optimizing cloud economics with linear elastic caching
Linear elastic caching treats cache memory as a cost that grows linearly with data size and time held, and frames each page's retention as a ski rental problem: keep paying for RAM or evict and risk a miss penalty. The key theoretical result is that per-page rental duration (a TTL) and capacity-bound eviction (e.g. LRU) can be optimized separately. In Spanner, a shallow decision-tree model predicts a TTL per page from data size, miss cost and operation type. It cut memory by 15.5% and TCO by about 5%, with 5.5% more misses but only a 0.5% rise in I/O cost. On public traces, learned and breakeven/randomized TTL variants beat a fixed-size GDSF baseline on total cost and miss rate, with larger gains as memory gets more expensive relative to misses.
Related posts
- Kangaroo: A new flash cache optimized for tiny objects
Meta Engineering hardMasterKangaroo is a flash cache for tiny objects (~100 bytes) that pairs a small log-structured cache (KLog, ~5% of flash) with a large set-associative cache (KSet). This avoids both the per-object DRAM index cost of log-structured caches and the ~40x write amplification of set-associative ones. When objects leave KLog, Kangaroo batches all objects that map to the same KSet set, amortizing each 4 KB page write across several objects. A threshold admission policy drops objects when too few would be written together. Built into CacheLib and evaluated on Facebook and Twitter social-graph traces, it cuts misses by 29% versus set-associative and 56% versus log-structured caches under realistic DRAM and write-rate limits.
- Transparent memory offloading: more memory at a fraction of the cost and power
Meta Engineering hardMasterTMO offloads cold memory to compressed RAM (zswap) or NVMe SSD swap. It uses the kernel's Pressure Stall Information (PSI), which measures time lost to CPU, memory and I/O shortage, and a userspace agent, Senpai, that applies mild proactive reclaim through a new stateless cgroup2 memory.reclaim knob. A reworked Linux swap algorithm engages swap in proportion to file-cache refaults, so cold anonymous pages get evicted at low pressure instead of only near OOM. In production across millions of servers, TMO saves 20–32% of memory per server, and SSD backends suit poorly compressible data like quantized ads models.
- Introducing Web Cache API support on Deno Deploy
Deno mediumAdeptDeno Deploy now offers beta support for the web-standard Cache API, giving serverless code semi-persistent storage for Request/Response pairs via caches.open(), cache.match() and cache.put(). Entries persist indefinitely (usually at least 30 days) unless expiry is set with standard Expires or Cache-Control headers. The backend is a multi-tier LSM storage engine that moves 512KB pages between RAM, local NVMe SSD and object storage, using io_uring to reach 2.4Gbps and sub-millisecond random I/O. It is free during the beta, and measured costs run about 10x lower than Deno KV.
- Session revocations at scale
Canva Engineering mediumAdeptCanva moved its gateway session-revocation cache from per-pod MySQL loads to sorted binary chunks in S3, eliminating the database stampede when hundreds of gateway pods started during deploys. Revocations are packed into 16-byte records in sorted flat arrays split into 30-minute S3 objects. Gateways binary-search the downloaded bytes directly and refresh recent chunks with conditional GETs. A ZooKeeper-elected worker appends new revocations, using conditional PUTs for optimistic concurrency so that racing writers never lose updates. The theoretically O(N^2) rebuild still exceeds 2000 revocations/sec, memory use dropped 87.5%, and read replicas were cut to two.
- Astra Dynamic Chunks: How We Saved by Redesigning a Key Part of Astra
Slack Engineering mediumAdeptSlack's Astra log search engine replaced fixed-size chunk slots on cache nodes with dynamically sized chunks, because undersized chunks wasted allocated disk space and oversized chunks from recovery tasks could overflow their slots. Cache nodes now advertise disk capacity, and the manager persists chunk-to-node assignments and node metadata in ZooKeeper, using first-fit bin packing to place chunks onto as few nodes as possible. The rollout ran behind a feature flag on one of two data replicas, moving from small clusters to large ones. It cut cache nodes by up to 50% on clusters with many undersized chunks and reduced overall cache node cost by 20%.