Athena outside Cloudflare Workers proof of concept

Running the Athena widget platform on Google Cloud with its production code, while Cloudflare keeps DNS, TLS, edge security and image delivery.

tracevisitor›cloudflare›edge gcp-poc · workerd›origin pages

Summary

Athena renders the widgets of our partner sites (rankings, brand cards, bonuses, call-to-action buttons, match previews) inside Cloudflare Workers, with its data held in Cloudflare Workers KV. A Workers or KV incident therefore removes widgets from every site at once, and there is no fallback today.

This proof of concept runs the unmodified Athena production code on Google Cloud, using workerd, the open-source runtime behind Cloudflare Workers. Cloudflare remains in front for DNS, TLS and edge security, and keeps serving images through Cloudflare Images. Everything related to Workers moves to infrastructure we operate.

  • Athena master, unmodified
  • 117 widgets, 54 types
  • 8 live Umbrella syncs
  • 2 Sanity webhooks
  • 51/51 images via Cloudflare Images
  • 0 production writes

Scope

The POC answers one question: can the Athena Workers run outside Cloudflare, with the same code and the same output, without depending on Cloudflare KV for their data?

  • In scope: the four Athena gateways, the widgets, tracking links and asset Workers, the Umbrella sync Worker (tracking-links-cron), the Sanity sync Worker (external-endpoint), KV-backed data.
  • Out of scope: moving DNS, TLS, WAF or image storage (Cloudflare Images) off Cloudflare, changes to the Athena repository, production traffic.
  • Environment: GCP project nextwork-staging, zone europe-west1-b. One edge VM (e2-standard-2) and one control VM (e2-medium).

Architecture

Two virtual machines. The edge VM serves traffic and renders widgets; the control VM owns the primary copy of the data and keeps it current.

Visitor browser, crawler Cloudflare DNS, proxy, HTTPS WAF, DDoS protection images, no Workers Edge VM · athena-poc-edge-1 public traffic nginx TLS, client IP, load balancing, fallback workerd ×2 Athena production code, unmodified entry geo → cf gateway widgets /go links images KV → Redis adapter (same interface as Workers KV) Redis replica · read Local cache · write Site origin Pages, WordPress, Cloud Run… Umbrella GraphQL synced every 10 to 30 min Control VM · athena-poc-control Redis primary, Umbrella and Sanity sync (production code) Production Cloudflare KV seed copy of 17 Nov: sports odds Sanity signed webhooks, live ↩ finished page to visitor raw page on cache miss continuous replication
The blue path is the only part of a request that executes Athena code. The finished page returns the same way: edge, then Cloudflare, then the visitor. Data flows from Umbrella into the Redis primary on the control VM and replicates to the edge. Sanity notifies the control VM through signed webhooks. The dashed element is the initial KV seed copy, now used only for sports odds.
ComponentHostRole
nginxedge VMOrigin TLS endpoint behind the Cloudflare proxy; restores the client IP from Cloudflare ranges. Balances the two workerd processes, caps concurrent renders at 30 and serves the origin page without widgets when overloaded.
workerdedge VMRuns the Athena production bundles, one process per vCPU. Bindings are generated from the production wrangler.toml.
Entry Workeredge VMRebuilds request.cf (country, region, city, timezone) from Cloudflare headers so Athena sees the same request object as in production.
Egress guardboth VMsworkerd globalOutbound Worker. Maps site domains to their origins and rejects any write towards production systems.
KV adapterboth VMsSame interface as Workers KV (get, list, put, delete, bulk get), backed by Redis. Compiled Go binary on the edge.
Redisboth VMsPrimary on the control VM; read-only replica plus a local writable cache on the edge.
Umbrella synccontrol VMProduction tracking-links-cron in workerd, triggered by 8 systemd timers at the production intervals.
Sanity synccontrol VMProduction external-endpoint in workerd, fed by two Sanity webhooks that mirror the production ones. Uses a read-only (Viewer) Sanity token.
Webhook receivercontrol VMnginx and an entry Worker that verify Sanity's HMAC signature before any delivery reaches external-endpoint. Only the two webhook routes are exposed.
D1 stand-incontrol VMRead-only copy of the 27-row sanityConfig table (Sanity type to KV namespace, key and GROQ query), exported once from production.
Widget cache purgeedge VMEmpties the POC widget cache within seconds of each Sanity delivery, signalled from the control VM through Redis replication. POC-only rule.

Request path

  1. dns
    ResolutionCloudflare DNS, unchanged. The hostname is proxied.
  2. cloudflare
    Edge securityTLS termination, WAF and DDoS protection, CF-IPCountry header. No Worker route is attached to the hostname.
  3. nginx
    Edge VMAccepts public traffic from Cloudflare IP ranges only and forwards it to workerd.
  4. entry
    Request contextThe entry Worker attaches the cf object, then hands the request to the Athena gateway through a service binding.
  5. gateway
    Athena gatewayFetches the raw page from the site origin and streams it through HTMLRewriter, replacing each <bw-widget> tag with server-rendered markup.
  6. data
    Data accessKV reads resolve to the Redis replica on the same VM; writes go to the local cache. Images are served by Cloudflare Images, as in production.
  7. response
    DeliveryThe completed page returns to the visitor through Cloudflare.

The trace line under each page title shows which of these hops served the page, read from its response headers.

Data sources

Cloudflare KV is an intermediate store. Every dataset has an upstream source outside Cloudflare, which the POC reads directly where possible.

DatasetSystem of recordPOC status
Rankings, brands, bonuses, tracking links, payment methods, game providers, website configurationsUmbrella GraphQL API (GCP)Live, every 10 to 30 min
Site configuration, translations, compliance, matches, bannersSanityLive via webhooks, confirmed 19 Nov
Images and logosCloudflare Images (uploaded from Sanity by production)Unchanged, served by Cloudflare Images
Sports oddsOdds providersSeed copy of 17 Nov
Tracking links missing from KV (/go)Vulcan tracking-links API (Cloud Run, GCP)Looked up on demand, as in production
Widget and page cachesComputed by AthenaRebuilt locally

Sanity content follows the production mechanism. Each published change triggers one of two webhooks, filtered exactly like the production ones. The receiving code re-reads the changed document with its production GROQ query and rebuilds the documents that reference it. There is no polling: Sanity API usage is proportional to edits, and zero when nothing changes.

Athena caches each rendered widget, for 30 minutes in most cases. The cache does not record which documents a widget was built from, so production cannot invalidate it selectively: a Sanity edit takes up to 30 minutes to reach the sites. The POC empties its whole widget cache within seconds of each delivery, which is practical at POC scale (about 100 widgets) but not in production.

Rationale

  • Resilience. Removes the single point of failure on Cloudflare Workers and KV, and provides a failover target per domain.
  • No rewrite. The same bundles run in both environments, so rendered output and business rules stay identical and there is a single codebase to maintain.
  • Cost control. Workers and KV are billed per request, at roughly 1.7 billion requests per month. VMs are a fixed cost. A full cost model is part of the next phase. Images stay on Cloudflare Images.
  • Incremental adoption. Cloudflare keeps DNS, TLS and security. Only widget rendering moves, domain by domain, with immediate rollback by restoring the Worker route.

Cloudflare services

ServiceCurrent useIn the POC
WorkersWidget rendering, click redirectsReplaced by workerd on GCE
Workers KVWidget dataReplaced by Redis, behind an adapter with the same interface as Workers KV
Cloudflare ImagesLogo storage and resizingRetained
D1Sanity-to-KV mapping (sanityConfig)Replaced by a read-only copy
Queues, Durable Objects, Analytics EngineLogging, counters, background jobsSunk locally; GCP equivalents to define
DNSName resolutionRetained
Proxy and TLSEdge terminationRetained
WAF and DDoS protectionEdge securityRetained
Static asset cachePerformanceRetained

Image delivery: Sanity CDN evaluated, not adopted

Images stay on Cloudflare Images. The Sanity CDN was evaluated as an alternative; the measured comparison is kept for reference.

OptionBilling modelMeasured volume (30 days)Estimate
Cloudflare Images$1 per 100,000 images delivered, plus $5 per 100,000 images stored55.6M deliveriesup to $556 / month + storage
Sanity CDN100 GB included (Growth plan), then $0.30 per GB≈ 210 GB at 3.8 KB average≈ $33 / month

List prices from the Cloudflare and Sanity documentation (19 Nov 2026). The Sanity estimate assumes every request reaches Sanity; the Cloudflare cache in front of the site domains serves repeat requests. Break-even, calculated from the two list prices: Sanity costs more only above an average of about 33 KB per image, or 35 KB counting the 100 GB included.

A further option is to reduce Cloudflare to DNS only, with TLS and edge security provided on Google Cloud. It is a separate decision, covered in the report.

Production safety

The POC reads production data and never writes to production. This is enforced at the network layer, not by convention.

  • All outbound traffic from workerd goes through the egress guard. On the control VM, only Umbrella GraphQL queries are allowed. On the edge VM, the Cloudflare API, Sanity mutations, GraphQL mutations and outbound e-mail are rejected.
  • Validated against 10 test cases, write attempts included: 10 passed.
  • In operation, no request has been blocked: the Athena code does not attempt production writes. The counter is published on the dashboard.
  • Sanity is accessed with a Viewer (read-only) token. Webhook deliveries without a valid signature are rejected. The production monthly cleanup jobs, which delete Sanity documents, are never scheduled by the POC.
  • Logs, click counters and analytics events stay on the VMs. /go clicks are not reported to production; only links missing from KV are looked up from the Vulcan tracking-links API, a read.

Resources created outside the staging project, for testing only: the Cloudflare Pages project athena-poc-test, the DNS records poc-athena.umbrella-showcase.com and poc-sanity-hook.umbrella-showcase.com, and two Sanity webhooks.

Results

ObjectiveStatus
Athena production bundles run on workerd without code changesValidated
Widgets rendered end to end through Cloudflare and the edge VM117 widgets, 54 types
Umbrella data refreshed without Cloudflare KV8 syncs at production intervals
Images served through the POC path51 of 51, from Cloudflare Images
No writes to production systems0 blocked, 10 of 10 guard tests
Sanity-to-KV mapping served without Cloudflare D1Validated, 27 types
Sanity content refreshed without Cloudflare KVConfirmed on 19 Nov, both webhooks

A standalone demo website shows the result as a visitor sees it: an ordinary site, hosted on its own Cloudflare Pages project, whose widgets are all rendered by the POC.

See the widget catalogue for every rendered widget, and the dashboard for live health and data freshness.

Load test

One edge VM with 2 vCPUs serves 12 pages per second carrying 50 widgets each. When overloaded, it serves the site's own page without widgets instead of making visitors wait.

Method: test pages with 30 and 50 real widgets (a 50-widget page is about 800 KB of HTML), loaded from the control VM over HTTPS on the internal network, 30 seconds per scenario, widget cache warm. Rendering calls neither Umbrella nor Cloudflare Images, so production was not loaded.

ScenarioBefore optimisationAfter optimisation
30 widgets, 10 connections13.0 pages/s, median 0.73 s19.0 pages/s, median 0.51 s
50 widgets, 10 connections8.4 pages/s, median 1.16 s12.0 pages/s, median 0.80 s
50 widgets, 25 connections8.0 pages/s, median 2.77 s12.0 pages/s, median 1.89 s
50 widgets, 80 connections (overload)about 6 s per page216 responses/s, median 0.27 s, 0 errors
/go click links, 10 connectionsnot measured251 redirects/s, median 39 ms

The optimisations: a compiled KV adapter (its share of CPU fell from 31% to 13.5%), one workerd process per vCPU, and an nginx cap of 30 concurrent renders with a fallback to the origin page. In the overload run, 184 pages were fully rendered and 6,293 were served without widgets. The /go test rotated through 31 real links taken from the widgets: 30 of them resolved from KV; calls to the production Vulcan API were blocked for the duration of the test so that it was not loaded.

Production traffic and sizing

Gateway traffic, last 7 daysRequests per second
Median hour348
95% of hours578
Normal peak615
Burst, 12 Nov 11:00 to 13:00 UTCup to 12,329

At about 600 pages per second, a fleet of roughly 50 such VMs would be needed if every page carried 50 widgets (75 before the optimisations). Real pages carry fewer widgets on average, and a short cache of finished pages would cut the need further; both remain to be measured. A burst like 12 November is absorbed by degrading and by Cloudflare rate limiting, not by standing capacity. Source: Cloudflare Workers analytics.

Limitations and next steps

Not yet demonstrated

  • Output parity with production on high-traffic sites, page by page.
  • Capacity at production scale: one edge VM serves 12 pages/s with 50 widgets, so the normal peak needs a fleet with autoscaling.
  • Selective widget-cache invalidation usable in production: requires a change in the Athena code.
  • Automatic refresh of sports odds.
  • Images still depend on Cloudflare Images. During a Workers outage, production stops copying new Sanity images to Cloudflare Images; they appear once production recovers.
  • Umbrella load: the POC polls Umbrella in parallel with production, at the same intervals, which doubles the sync load during the POC.
  • Running cost compared with the current Cloudflare invoice.

Next steps

  1. Connect sports odds.
  2. Propose selective widget-cache invalidation on Sanity updates to the Athena team.
  3. Compare POC and production output on a sample of real sites.
  4. Measure the average number of widgets per page on real sites, add a short finished-page cache, then produce a cost model with autoscaling.
  5. Decide on the target: standby failover, or progressive migration by domain.

Internal page, not indexed. Updated 19 November 2026.