Brifing

How Cloudflare Saves Petabytes of Cache Storage

Efficient cache management achieved with Zstandard and Pingora

Cloudflare Blog2 min

1Rising Cache Storage Costs

Sharp increases in RAM and HDD prices over the past year pushed large-scale storage providers like Cloudflare to seek efficiency gains. For distributed systems like CDN services, expanding cache capacity is critical. This need spawned a new solution prototyped through the 1.1.1.1 Intern Program involving engineering interns.

2Implementing Zstandard Compression

Cloudflare engineers developed Cache Transcoding system that compresses eligible assets with Zstandard (zstd) before disk storage. This lossless compression algorithm, open-sourced by Facebook's Yann Collet in 2016, reduces data to 1/3 original size on average. Tests proved it's 42% faster than Brotli and 11.3% more efficient than gzip.

3Balancing CPU and Storage

The system uses zstd level 3 to optimize the compression-to-speed ratio. A minor CPU increase trades for petabytes of effective cache capacity. Compression cost is paid only when assets first enter cache, while storage and bandwidth savings compound with each reuse.

4Selective Data Compression

The prototype targets only compressible text content (HTML, JSON, CSS, JavaScript) which constitutes 67.3% of requests. Already compressed media like images/videos/fonts (63.3% byte ratio) are excluded. The solution achieved 71% success rate for uncompressed text above 4 KiB.

5Efficiency in Tiered Cache

Compressed assets transfer between data centers using less bandwidth. Data remains compressed through cache tiers, only being decoded for end users. This approach improves backbone efficiency while enabling more objects per disk.

6Increased Cache Density

Smaller file sizes allow servers to store more objects, increasing cache density. This reduces likelihood of useful content being evicted due to uncompressed versions occupying unnecessary space. Tests showed significant capacity gains using existing hardware.

7Popular Content Limit Unnecessary

Initially considering compression only for hot content, engineers found this reduced storage savings without proportionally cutting CPU costs. Instead, compressing all eligible text above 4 KiB delivered maximum storage benefits while staying within CPU budget.

8Future Implications

Cloudflare's innovation marks a milestone for resource efficiency in large-scale distributed systems. Smart implementation of modern compression algorithms like zstd maintains service quality despite rising hardware costs. This approach provides valuable insights for other cloud providers facing similar infrastructure challenges.

Original article: Cloudflare Blog — Cloudflare'ın Önbellek Depolamada Petabayt Tasarrufu