Why Cloudflare Replaced Nginx with Pingora: Inside the New High‑Performance Proxy

Cloudflare abandoned Nginx for its home‑grown Rust‑based proxy Pingora, detailing the architectural limits of Nginx, the design choices behind Pingora, and the measurable performance, efficiency, and safety gains achieved in production across billions of requests.

Top Architect
Top Architect
Top Architect
Why Cloudflare Replaced Nginx with Pingora: Inside the New High‑Performance Proxy

Background

Cloudflare processes more than a trillion client requests per day. The existing Nginx‑based edge proxy exhibited several architectural limits that prevented further scaling and feature development.

Limitations of the Nginx Worker Model

Each request is bound to a single worker process, causing load imbalance across CPU cores.

Connection pools are per‑worker, so increasing the number of workers reduces connection‑reuse efficiency.

Adding advanced per‑request logic (e.g., custom header manipulation, retry policies) required invasive changes to Nginx’s C code.

Nginx’s C implementation lacks memory‑safety guarantees, increasing the risk of crashes and security bugs.

Evaluation of Alternatives

Continue investing in Nginx and pay for customizations.

Migrate to a third‑party proxy such as Envoy.

Build an internal platform from scratch.

After multiple years of assessment, the team concluded that a custom solution offered the best long‑term return on investment.

Pingora Project

Design Decisions

Language: Implemented in Rust to achieve C‑level performance while providing memory‑safety.

HTTP Stack: A bespoke HTTP library was created instead of using existing crates (e.g., hyper) to handle the wide range of non‑RFC‑compliant traffic seen on the Internet.

Concurrency Model: Multithreaded execution on the Tokio async runtime with work‑stealing. This enables shared resources such as connection pools across threads, eliminating the per‑worker isolation of Nginx.

Programmable Request Lifecycle: An API modeled after Nginx/OpenResty allows developers to insert custom logic (request filters, header modifications, retry handling) without touching core proxy code.

Pingora architecture diagram
Pingora architecture diagram

Production Performance

Median time‑to‑first‑byte (TTFB) reduced by 5 ms; 95th‑percentile TTFB reduced by 80 ms.

Connection‑reuse rate increased from 87.1 % to 99.92 % for a major client, cutting new connections by a factor of 160 and saving an estimated 434 years of TLS handshake time per day.

CPU usage dropped ~70 % and memory usage ~67 % under comparable load, thanks to shared connection pools and more efficient Rust code compared with Lua on Nginx.

Performance chart
Performance chart

Additional Capabilities

HTTP/2 upstream support was added quickly, paving the way for gRPC services.

Cache Reserve feature uses Cloudflare R2 storage as an external caching layer.

Safety and Reliability

Rust’s memory‑safety guarantees eliminate many classes of crashes and security vulnerabilities common in C‑based code. Since its launch, Pingora has processed trillions of requests without a service‑code‑induced crash. The multithreaded model also reduces synchronization overhead compared with Nginx’s shared‑memory locks.

Conclusion

Pingora is now the primary internal HTTP proxy at Cloudflare, delivering lower latency, higher connection‑reuse, and substantially reduced CPU and memory consumption. The project is planned to be open‑sourced after further maturation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ProxyRustHTTPCloudflare
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.