news.volyx.in

A good day to trie-hard: saving compute 1% at a time (blog.cloudflare.com)

614 points by eaufavor · 697 days ago · 173 comments on HN

Article summary

Cloudflare's global network handles over 60 million HTTP requests per second, and a significant portion of CPU time is spent on removing internal headers from requests. The company has been working on optimizing this process, starting with a function called clear_internal_headers, which consumes over 1.7% of the total CPU time. By inverting the lookup direction and using a different data structure, the function's runtime was improved from 3.65µs to 1.53µs. This optimization is part of a larger effort to reduce CPU utilization and improve the performance of Cloudflare's services.

Main themes

  • Optimization
  • HTTP Request Processing
  • Cloudflare Infrastructure
  • Performance Improvement
  • Header Management

What commenters say

  • The use of HTTP headers for internal metadata is a fragile and error-prone approach that can lead to security vulnerabilities and name collisions.
  • Optimizing code as you go, rather than waiting for a major overhaul, can lead to significant performance improvements and make it easier to maintain a clean codebase.
  • Using a prefix for internal headers, such as X-CF-, can help avoid conflicts with external headers, but may not be a foolproof solution.
  • Alternative approaches, such as using a separate data structure or protocol, like Protobufs, could provide a more robust and efficient solution for handling internal metadata.
  • The optimization efforts are a temporary solution, and a more fundamental change to the system architecture is needed to fully address the issue.
  • The use of headers for internal metadata is a common practice in the industry, and Cloudflare's approach is not unique or particularly problematic.