返回资讯中心
外部精选
软件工程
#开发者实时流

Double Buffering with Cloudflare Queues

I use a double-buffered queue pipeline to collect and segment telemetry events into groups bound by UTC hour. This pattern naturally batches data, produces predictable event flow, and minimizes cost.

Hacker News 最新b_llc2026/10/28 · 2 天前2 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

I use a double-buffered queue pipeline to collect and segment telemetry events into groups bound by UTC hour. This pattern naturally batches data, produces predictable event flow, and minimizes cost.

Modulo math is used to route the payload to the active queue and again to drain the inactive queue. UTC is used to avoid DST handling.

This pipeline leverages Cloudflare Workers, Queues, Workflows, and R2 to capture, batch, process, and store telemetry events while maximizing the benefits of Cloudflare's pricing.

The producer evaluates the current UTC hour and directs the payload to the active queue:

The consumer task triggers every hour on the half-hour to drain the inactive queue:

The consumer task looks back one hour to determine which queue is currently inactive and safe to consume:

Finally, the batch is compressed and written to R2 using a simple partitioning strategy:

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →