Sunday, July 17, 2022

Cloudflare Workers + WebAssembly + R2 storage

Episode #142: Cloudflare Workers with Michael Hart - Serverless Chats Podcast

Michael Hart is currently a Principal Engineer for Cloudflare Workers at Cloudflare
...what's new with Cloudflare Workers, how to add state with K/V, Durable Objects, R2, and more, how and why WinterCG is defining a new set of Web API standards, maintaining open source

Twitter: @hichaelmart

"Under the hood, the Workers runtime uses the V8 engineOpen external link — the same engine used by Chromium and Node.js. The Workers runtime also implements many of the standard APIs available in most modern browsers.

The differences between JavaScript written for the browser or Node.js happen at runtime. Rather than running on an individual’s machine (for example, a browser application or on a centralized serverOpen external link), Workers functions run on Cloudflare’s Edge NetworkOpen external link - a growing global network of thousands of machines distributed across hundreds of locations."

V8 orchestrates isolates: lightweight contexts that provide your code with variables it can access and a safe environment to be executed within. You could even consider an isolate a sandbox for your function to run in.

A single runtime can run hundreds or thousands of isolates, seamlessly switching between them. Each isolate’s memory is completely isolated, so each piece of code is protected from other untrusted or user-written code on the runtime. Isolates are also designed to start very quickly. Instead of creating a virtual machine for each function, an isolate is created within an existing environment. This model eliminates the cold starts of the virtual machine model.

Announcing support for WASI on Cloudflare Workers

In 2017 Cloudflare launched Cloudflare Workers, a serverless computing platform for creating new applications, augmenting existing ones, without configuring or maintaining infrastructure. It has expanded to include Workers KV, a low-latency key-value data store; Cron Triggers, for scheduling Cron jobs; 

Cloudflare R2 Storage includes full S3 API compatibility

Traditional object storage charges developers for three things: bandwidth, storage size and storage operations.

R2 builds on Cloudflare’s commitment to the Bandwidth Alliance, providing zero-cost egress for stored objects — no matter your request rate. Egress bandwidth is often the largest charge for developers utilizing object storage and is also the hardest charge to predict. Eliminating it is a huge win for open-access to data stored in the cloud.

That doesn’t mean we are shifting bandwidth costs elsewhere. Cloudflare R2 will be priced at $0.015 per GB of data stored per month — significantly cheaper than major incumbent providers.

No comments: