News for hackers. Stuff that matters.
Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by ctvo on Friday February 11, 2022 @09:41AM (#30301997)
> Long story short, it turns out that Workers KV also works for storing static sites generated by Hugo, Gatsby, and other SSGs. This makes complete sense if you think about it. When you access a static site, you point your browser to a unique URL, and the server returns a pre-generated static HTML file. In this model, the URL is the “key” and the contents of the HTML file is the “value”. Thus, a static site can be stored in a key-value data store like Workers KV.

Why not just use Cloudflare's standard CDN? It makes no sense. By this logic, a file system is a perfect key value store, because ya know, the key is the full path and the file is the value.

Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by pjc50 on Friday February 11, 2022 @10:23AM (#30302451)
> By this logic, a file system is a perfect key value store, because ya know, the key is the full path and the file is the value.

They're not wrong.

I'm still waiting for people to rediscover (fast)cgi as the "worker" interface.

Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by afiori on Friday February 11, 2022 @10:30AM (#30302541)
cloudflare and others workers are almost literally fastcgi for javascript.

The problem is that node is not a good cgi engine.

Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by _whiteCaps_ on Friday February 11, 2022 @11:37AM (#30303465)
They also have native Rust libraries - I just made a worker that's an SMS gateway for Canadian tide data, it was a really fun project.
Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by afiori on Friday February 11, 2022 @11:51AM (#30303641)
On cloudflare I am almost sure that Rust is supported with compilation to WebAssembly.
Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by _whiteCaps_ on Monday February 14, 2022 @08:37PM (#30341432)
Ah yes, thanks for pointing out that it's compiled to WASM... I meant in comparison to other languages like Python were it's compiled (transpiled?) to Javascript: https://developers.cloudflare.com/workers/platform/languages...

Using Python for Workers was weird, and it felt like you needed to be both a Python and JS expert to make it work.

Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by samhw on Friday February 11, 2022 @12:40PM (#30304383)
It is indeed - but why is that relevant, or somehow undesirable?
Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by afiori on Friday February 11, 2022 @03:54PM (#30306866)
It is not undesirable in the least, it was a response to "native" which for rust usually means "compiled to x86/arm/risc-v/etc
Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by anonGone73 on Friday February 11, 2022 @06:27PM (#30308258)
Rust and WASM with some combination of Container Orchestration through block-chained nodes which only come online when you are not using your phone and willing to power the transactions.

Cloudflare Workers and KV @ the Edge can do a lot to manage the control plane.

Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by throwthere on Friday February 11, 2022 @12:01PM (#30303767)
cloudflare workers run in an environment more like Chrome than node.
Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by bastawhiz on Friday February 11, 2022 @11:04AM (#30302993)
Cloudflare doesn't use Node for Workers.
Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by afiori on Friday February 11, 2022 @11:21AM (#30303226)
exactly, I think that no "workers" platform uses node as it is not feasible to use node for fastcgi, so javascript fastcgi need to use alternative runtimes.

Since node is so dominant for serverside js, fastcgi with javascript is very uncommon.

PS: I do not know whether deno is better for fastcgi, but it is unlikely that it would be good enough.

Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by divbzero on Friday February 11, 2022 @11:25AM (#30303304)
What about Node makes it unsuitable for FastCGI? I always found it curious that Cloudflare Workers does not use Node, makes sense that there could be an underlying reason.
Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by kentonv on Friday February 11, 2022 @02:47PM (#30306161)
Node is not designed to be multi-tenant. That is, it is expected that a single Node.js process runs a single Node application. Additionally, Node does not attempt to provide any isolation of that application -- it is assumed that the application code is fully trusted.

So, in order to host Node apps on behalf of multiple customers, you must run multiple copies of Node.js as separate processes, and you must use some sort of secure containerization or VMs to isolate them from each other and from the system.

That in turn means there's a lot of overhead involved in running each application instance. To amortize that overhead, it's necessary for each instance to handle a large number of events, so that the per-event overhead is reasonable. So, you need to concentrate your traffic stream onto a small number of instances.

Workers, however, had the design goal that every application would run at every one of Cloudflare's hundreds of locations, in order to run as close to the end user as possible. That implies that there may be hundreds of instances of an app around the world, while each instance only handles traffic from a particular locality, which may be small. This means the setup overhead per instance had to be much less, and it had to be possible to run tens of thousands of live instances per machine, with the ability to quickly load from a library of millions on disk on-demand.

That's just not possible with containers, or even processes. But it is possible if you run lightweight V8 JavaScript instances -- called "isolates" -- all inside a single process.

This talk of mine goes into a lot more detail: https://www.infoq.com/presentations/cloudflare-v8/

(I'm the lead engineer for Workers.)

Re:Migrating from Netlify to Cloudflare Workers Sites for 2x... by afiori on Friday February 11, 2022 @11:42AM (#30303532)
I believe I made a mistake, my previous comments are about CGI not FastCGI.

Also I am not an expert so I will not be able to prove anything, but I can try my best to express my opinions.

I do not think that node has any problems with FastCGI

So basically Node's start latency are too slow for CGI and FastCGI is bad for a worker platforms (or for any multitenant offering).

The reason is that cloudflare doesn't want to keep track which workers are for which customers and want to offer a clean slate environment for each request.

This either means spinning up new processes or using some other in-process isolation techniques. All javascript workers platforms I know use V8 isolates, which (I believe) node does not offer.

PS: I made also another mistake, it looks like deno offers a worker platform on V8 isolates. https://deno.com/deploy