← Fri, Sep 18 digest

Saving another 100TB of RAM

read article ↗ hn thread ↗

summary

Cloudflare reduced the memory footprint of its Pingora Backend Router by optimizing the storage and quantity of hashes used in consistent hashing. By replacing inefficient 32-bit indices with packed 16-bit integers and reducing the number of hashes per server based on statistical analysis, they reclaimed over 100TB of RAM globally. This approach demonstrates that small, mathematically-backed adjustments to core algorithms can lead to massive resource savings at extreme scale.

key points

  1. The team replaced a standard Rust struct with a packed byte array to bypass memory alignment rules, reducing the storage size of each hash point from eight bytes to six.
  2. Mathematical analysis revealed that increasing the number of hashes per server yielded diminishing returns in load distribution and increased collision risks, allowing the team to cut the hash count by 90% without sacrificing accuracy.
  3. To prevent a massive surge in origin traffic caused by cache invalidation, the migration was executed using a layered rollout that maintained both old and new hash rings simultaneously.

who should read it

Software engineers and systems architects interested in high-scale infrastructure, memory optimization, and the practical application of consistent hashing.

discussion positive

consensus

Commenters generally appreciate the return to low-level optimization and lean software engineering, contrasting it with a recent era of bloated software caused by abundant resources and a 'ship fast' mentality. While some argue that rapid delivery is essential for business, others maintain that excessive abstraction and reliance on cloud services have led to unnecessary waste. There is a shared sense that while AI can accelerate coding, it cannot replace the deep architectural thinking required for high-performance systems.

top insight

The discussion on RESTful interfaces illustrates how a simple task, like toggling a boolean, now requires a massive stack of networking, authentication, and orchestration layers. This highlights a systemic issue where abstractions are often managed simply because they exist, creating a 'Fortune-50 style hierarchy' of software that obscures the original goal. This perspective shifts the focus from individual code optimization to the systemic bloat of modern architectural patterns.

Generated by an LLM from the article and thread. Check the sources before relying on it.