Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Cloudflare 9 min read Announcement mediumAdept

Introducing Spend Management: Spending limits and alerts for Cloudflare

Cloudflare Spend Management, now in beta for pay-as-you-go customers, lets users set spending limits and alert thresholds on Workers and Durable Objects, automatically pausing billable invocations when a cap is hit. Static assets keep serving. Limits can be configured via dashboard, cf CLI or REST API. Under the hood, a two-stage metering pipeline aggregates usage into one-minute and then five-minute windows, and an account-partitioned Usage Engine with local state and a WAL feeds a Rating Engine. The Rating Engine applies allowances and pricing, tolerating out-of-order subscription data by holding usage as pending. Caps propagate asynchronously through Quicksilver so enforcement uses local state off the request path, with roughly 10-minute lag today and a goal of under a minute.

Assumes: stream aggregation basicsdistributed key-value replication

Related posts

  • Controlling costs when building with AI

    incident.io mediumAdept

    After hitting OpenAI billing limits broke its early AI features, incident.io built per-prompt cost attribution into its Go LLM abstraction, using reflection to capture each prompt's type name alongside token usage and emitting it to Grafana metrics and Postgres records for BI. Separate OpenAI projects per feature, mapped from source file patterns and provisioned with Terraform, give each surface its own billing limit to contain runaway spend. Daily Slack spend reports, per-message cost and latency in dev, backfill cost predictions from historical runs, and eval suites that report their cost keep spend visible to developers and let teams model feature costs before launch.

  • Observability At Scale — Every Byte Counts

    Wise Engineering mediumAdept

    Five observability changes at Wise cut monthly spend by 40%. Switching Loki chunk compression from Snappy to lz4 cut S3 storage and cross-AZ traffic by roughly 50% with negligible CPU impact. Moving the OpenTelemetry Collector to Tempo path from gzip to zstd reduced Tempo ingest by about 40%, and upgrading Prometheus to Remote Write v2 dropped daily traffic to Mimir from ~16TB to ~5.5TB. Aligning Loki's split_queries_by_interval with the ~1-hour p90 chunk span eliminated redundant chunk reads, and an AI-assisted investigation tracked down a Fluent Bit connection limit, with the overall lesson being to challenge defaults on high-volume data paths and validate against measured cost.

  • Worker Backpressure (Part 1)

    Canva Engineering mediumAdept

    Canva added Worker Backpressure to its shared queue library: each worker records success/failure outcomes, a pluggable controller maintains a backoff factor (0.0 to 1.0) against a failure-rate set point, and the factor scales down how many messages the worker may poll and process concurrently. Everything runs locally with no coordinator, at a cost of two arithmetic operations per cycle. In a 4-hour multi-spike cloud outage the DLQ grew by one message. In a 32.5-hour quota overload, 1.8M failed attempts produced only 22 DLQ messages, against an estimated 16,000+ without backpressure. The tradeoffs are reduced throughput for saturated workers and reliance on a single success/failure signal, with latency and in-flight signals planned as future additions.

  • Three Mighty Alerts Supporting Hugging Face’s Production Infrastructure

    Hugging Face mediumAdept

    Hugging Face's infrastructure team relies on three alerts to catch problems early. A static-threshold alert on NAT gateway throughput flags cost-relevant egress changes, such as misrouted traffic that skips cheap private paths to object storage; the fix uses Route53 Resolver DNS overrides managed with CDKTF. An end-to-end alert compares ALB request counts with logs archived through a Filebeat → Logstash → Elasticsearch → Parquet/S3 → Glue/Athena pipeline, catching log loss caused by backpressure, schema-detection failures, OOMs and failed archive jobs. The third alert tracks Kubernetes API error rates and rate limiting, which matter because kube-rs controllers manage certificates, node draining and billing.

  • The foundations of Canva’s continuous data platform with Snowpipe Streaming

    Canva Engineering mediumAdept

    Canva replaced AWS Data Firehose, which accounted for nearly half its product analytics platform cost because of 5 KB minimum record billing, with Snowpipe Streaming fed directly from Kinesis Data Streams via the Kinesis Client Library. One Snowpipe channel maps to each Kinesis shard. KCL shard stealing invalidates every channel on a shared client, so Canva runs one Snowflake client per shard, trading compression and per-client cost for reliability, and uses a LeaseCoordinator workaround to drop unhealthy leases. After six months and 20 PiB processed, cloud spend fell 45% and time-to-query dropped to about 10 minutes, with a 5-minute MAX_CLIENT_LAG and larger buffers recommended for lower costs.

The quest for software engineering knowledge.

Look:
Layout: