Unbound reaches general availability

Workers Unbound, previously in beta, is now generally available on the Workers Paid plan. The extended CPU limit of up to 30 seconds applies to HTTP requests, while Bundled Workers remain capped at 50 milliseconds and can be selected per script.

Introducing Workers Unbound Embedded Image - CaA6BH

Cron Triggers running up to 15 minutes are available through a separate private beta. HTTP Workers are invoked by requests as part of the Fetch API; Cron Workers are scheduled jobs triggered by Cron Triggers. The goal is to let customers move intensive workloads onto Workers and the edge network without hitting computation limits.

Pricing and egress changes

Unbound's pricing model charges for duration, egress and requests, with no extra charges of the kind other providers add, such as API Gateway or CloudFront.

BLOG-460 Embedded Image - x19dIQ

Egress has been cut from $0.09 per GB to $0.045 per GB, and the usage included in the $5 per month plan has increased, so the same rate now buys more. Limits are documented in the Workers limits docs.

From short scripts to long-running workloads

When Workers launched in 2017, the platform targeted lower-latency use cases, chiefly customers modifying Cloudflare products such as WAF who needed little execution time. Cloudflare retained the ability to raise CPU limits in special cases, often for its own teams building on Workers. As those requests grew more frequent, the case for offering higher compute limits to the wider market became apparent, and the beta program validated it.

BLOG-460 Embedded Image - XhUxwV

Early testers have run more complex compute, including genomic analysis. Dr. Robert Aboukhalil built an API that simulates DNA sequencing data, requesting subsets of a reference genome and streaming them back to the user. He compiled wgsim, an open source tool for simulating sequence reads, from C to WebAssembly with biowasm, then started from the human genome hosted in the public repo of the 1,000 Genomes Project and applied random modifications to simulate experimental errors.

BLOG-460 Embedded Image - k2kzLe
"Cloudflare Workers Unbound and KV are well-suited for complex workloads such as powering genomics analysis. For example, I was able to build an API that simulates DNA sequencing data. Workers was well suited as it features 0 ms initialization time (i.e. no “cold starts”), runs at the edge (i.e. in a data center close to your users), and has a pricing model that doesn’t require a degree in quantum physics to understand."

At larger organizations, Thomson Reuters used Unbound to build EverCache, a cache implementation meant to improve efficiency and load times across thousands of partner websites.

"We use Cloudflare Workers Unbound and Workers KV to reduce the burden on our origin servers and pre-populate our cache. We are early users of Unbound's long running Workers, and the simple integration with Workers KV has made it easy to use, with consistent performance and reliability."

Testers also report Unbound as an environment for sandboxing and experimentation, with customers who started on simpler use cases expanding into prototyping and optimization work.

"Workers has been our go-to tool for scaling and tuning ni.com. We first started using Workers for redirects, and then began using Workers Unbound once we realized it could be a powerful tool for other features such as detecting the location of users and adjusting the experience accordingly. We started experimenting with using includes for deploying common header and footer HTML across the site, and currently we are improving routing, image optimization, and page caching. Our development team loves having the ability to experiment with building new features on top of Workers."

Enabling Unbound

Unbound is available to anyone with a Workers Paid subscription. In the Workers dashboard, click "Change" under the Default Usage Model section and follow the prompts; the Usage Model can also be changed per Worker under its Settings tab.

  1. Update wrangler to release 1.15.1 or later.
  2. Set the usage_model field in wrangler.toml to "bundled" or "unbound".

"bundled" gives the original Workers model with up to 50ms of compute time; "unbound" opts into the higher execution limits under the pricing above. New Workers scripts without a specified usage model use the dashboard default. An MIT-licensed template is available for trying Unbound.

// Try running this script first with Usage Model: Bundled
// see how far it can count.
//
// Then update the script's Usage Model to Unbound to see
// how much further it can go!
//
// note: 1st requests on a connection in Bundled mode
// might get higher cpu allocation than average requests.
 
addEventListener('fetch', event => {
 event.respondWith(handleEvent(event))
})
 
async function handleEvent(event) {
 let { readable, writable } = new TransformStream()
 let countingIsDone = countToOneTrillion(writable)
 event.waitUntil(countingIsDone)
 
 // start streaming response while still counting
 return new Response(readable, {
   status: 200,
   headers: {
     'Content-Type': 'text/plain; charset=utf8',
     'X-Content-Type-Options': 'nosniff',
   },
 })
}
 
async function countToOneTrillion(writableStream) {
 // This is an example of a cpu-heavy long running task.
 //
 // Try your own example here instead!
 // Fractal Generator? ML model training?
 
 const million = 1000000
 const intro = `Hello World!
Let's count to one trillion:
(we'll stop when cpu limits are exceeded)
 
`
 const writer = writableStream.getWriter()
 const encoder = new TextEncoder()
 await writer.write(encoder.encode(intro))
 
 for (let i = 1; i <= million * million; i++) {
   if (i % (2 * million) == 0) {
     // send an update to client every 2M cycles
     const count = i / million
     const line = `${count} million\n`
     await writer.write(encoder.encode(line))
   }
 }
 await writer.close()
 return
}