Cloud & infrastructure

Cloudflare cuts data pipeline traffic by deferring replication and aggregating early

Cloudflare reduced wide-area network traffic by shifting sampling, replication, and aggregation earlier in its data pipeline, deferring years of hardware expansion.

Illustration of a data pipeline reducing volume through filtering and compression
Illustration generated for this article

Cloudflare’s Data team has implemented a series of architectural changes to manage exponential traffic growth without proportional increases in hardware. Between 2022 and late 2026, the company reduced compressed data throughput significantly by restructuring schemas, changing compression algorithms, and moving processing steps closer to the source. These optimizations have allowed the network to handle roughly two billion events per second while deferring an estimated two and a half years of hardware expansion.

What happened

The Cloudflare network supports more than 20% of the web, generating massive volumes of data for logs, observability, and internal analytics. In May 2026, the system processed approximately two billion events per second. The core challenge has been balancing this exponential traffic growth against linear hardware allocation. To keep resource costs under control, the Data team executed five major initiatives over five years: breaking up a monolithic schema, adjusting compression, rearchitecting pipeline replication, decentralizing sampling, and introducing early aggregations.

In 2022, the team dismantled a single, monolithic data schema that forced all consumers to ingest every field from every product. By replacing this firehose with product-specific schemas, they reduced backbone bandwidth usage by 35-40%. In 2024, they switched compression algorithms from LZ4 to zstd. After careful testing to ensure CPU usage remained stable, this change yielded a nearly 40% reduction in compressed traffic throughput, effectively supporting 1.5 times more traffic on the same infrastructure.

The most recent changes occurred in 2026. In spring, the team rearchitected how data is replicated across regions for disaster resilience. In summer, they moved sampling logic earlier in the pipeline. By fall, they introduced decentralized aggregation. Together, these moves drastically cut the volume of data traversing wide-area networks and reduced the load on centralized data centers.

How it works

The pipeline begins with Logfwdr, a service that collects data from distributed sources like Workers. Historically, to ensure disaster resilience, Logfwdr sent two full copies of every event to two different centralized regions. This double-writing doubled wide-area transit traffic. The new architecture decouples pipeline transit from database redundancy. Logfwdr now sends each event exactly once to a shared pool of receivers. Replication happens later, downstream of sampling and buffering. Remote inserters stream cross-data-center copies only after the data has been sampled and buffered in Buftee. Because replication occurs after sampling, the second copy is much smaller than the original raw event. Additionally, data is aggregated into uniform batches at the central level, allowing compression algorithms to achieve higher ratios.

Sampling was also pushed upstream. Previously, sampling occurred only at centralized receivers. The team added sampling to Logfwdr itself, using a square-root method to select representative records for each key. This ensures that high-volume keys are sampled more aggressively while rare events are preserved. The result is a representative dataset with far fewer rows. For example, 11.6 million events can be represented by just 18,000 rows instead of 79,000, without compromising estimate accuracy.

Aggregation was similarly decentralized. Instead of waiting until the end of the pipeline to compute rollups, the system now aggregates data at every stage: at Logfwdr, at centralized receivers, and in the buffering layer. This repeated combination of matching partial aggregates reduces the data volume before it reaches the final database. For the HTTP dataset, this approach reduced compressed traffic from over 9 GB/s to less than 2 GB/s.

Key details

  • Schema breakup (2022): Moving from a monolithic schema to product-specific schemas reduced backbone bandwidth by 35-40%.
  • Compression switch (2024): Changing from LZ4 to zstd compression reduced compressed traffic throughput by nearly 40% with negligible CPU impact.
  • Replication shift (Spring 2026): Sending events once instead of twice, and replicating after sampling, reduced wide-area transit by 36 GB/s net.
  • Early sampling (Summer 2026): Adding sampling at the source (Logfwdr) halved compressed data for top datasets, saving over 2PB/day.
  • Decentralized aggregation (Fall 2026): Aggregating at multiple pipeline stages reduced HTTP dataset traffic by approximately 80%.
  • Overall impact: These combined efforts have deferred an estimated two and a half years of hardware expansion.

Why it matters

For engineering leaders managing large-scale data platforms, this case study highlights the importance of questioning default architectural patterns. Double-writing for redundancy is a common simplicity tax that becomes unsustainable at scale. By decoupling transit from storage redundancy, Cloudflare demonstrated that you can maintain resilience while drastically cutting bandwidth costs. The key insight is that replication should happen as late as possible, ideally after data has been compressed, sampled, or aggregated.

Furthermore, moving compute closer to the edge or source can yield disproportionate savings. By performing sampling and aggregation at Logfwdr and intermediate stages, the team reduced the load on expensive centralized resources like ClickHouse clusters. This not only saves on network transit but also reduces CPU and memory usage in central data centers. For teams building observability or analytics tools, evaluating where in the pipeline data reduction occurs can unlock significant efficiency gains without sacrificing data quality.

What you can do

  • Audit your data schemas: Identify if you are transmitting unused fields to all consumers and consider splitting monolithic schemas into domain-specific streams.
  • Evaluate compression algorithms: Test modern algorithms like zstd against your current setup, monitoring CPU trade-offs carefully before full rollout.
  • Delay replication: If you duplicate data for resilience, check if you can replicate after sampling or compression rather than sending raw duplicates across wide-area networks.
  • Sample early: Implement sampling at the ingestion point for high-volume, non-critical data to reduce downstream storage and processing costs.
  • Aggregate incrementally: For metrics and rollups, perform partial aggregations at each stage of your pipeline rather than waiting for the final database insert.
  • Monitor growth vs. capacity: Track your traffic growth rate against hardware allocation to identify when architectural refactoring is needed to defer capital expenditure.
  • #data engineering
  • #cloud infrastructure
  • #optimization
  • #scalability
  • #cloudflare

Tools from the Bytechap store

Keep reading

All stories