4 ms·
> 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
by ctvo 5y ago
> 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.
- pjc50 5y ago> 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.
- afiori 5y agocloudflare and others workers are almost literally fastcgi for javascript. The problem is that node is not a good cgi engine.
- bastawhiz 5y agoCloudflare doesn't use Node for Workers.
- afiori 5y agoexactly, 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.
- divbzero 5y agoWhat 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.
- afiori 5y agoI 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 https://deno.com/deploy
- deleted 5y ago[deleted]
- kentonv 5y agoNode 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/ https://www.infoq.com/presentations/cloudflare-v8/ (I'm the lead engineer for Workers.)
- _whiteCaps_ 5y agoThey 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.
- afiori 5y agoOn cloudflare I am almost sure that Rust is supported with compilation to WebAssembly.
- _whiteCaps_ 5y agoAh 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#compiled-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.
- samhw 5y agoIt is indeed - but why is that relevant, or somehow undesirable?
- afiori 5y agoIt is not undesirable in the least, it was a response to "native" which for rust usually means "compiled to x86/arm/risc-v/etc
- anonGone73 5y agoRust 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.
- throwthere 5y agocloudflare workers run in an environment more like Chrome than node.