Live data from Hacker News

Cloudflare Workers: Run JavaScript Service Workers at the Edge

blog.cloudflare.com

41–50 of 134 posts

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#42
post #30

Earlier quoted context omitted.

Point of curiosity: why did you go with C++ instead of Rust?

V8's API is C++. While bindings exist in other languages, they don't always expose everything and don't always keep up with V8's frequent API changes. I felt it was essential that we bind closely to V8, being able to use all of its features, and that we be able to track closely to the latest stable release. Also, I personally have decades of experience in C++ and wasn't sure this should be the project where I work on…

That’s about what I expected; thanks.

Just for reference for people reading this: rust-bindgen can produce bindings to C++ code these days, though that gets you an unsafe library; you’d want to build another thin layer on top of it to nail down the ownership semantics so that you can provide a safe interface.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#43

Could this be used for HTTP Push across domains? I would love an easy way to take advantage of HTTP Push for assets hosted on S3 without routing requests to my origin server.

Yes, your worker can make subrequests to other domains, and serving some assets out of S3 is a use case we specifically want to enable.

I haven't looked into how specifically to expose HTTP Push in the API but that certainly seems like something we should support.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#45
post #10
post #7

So in a way this is similar to for example AWS Lambda ? It can process incoming http requests in many ways ? Fascinating idea. Is there any indication on price level ? And what about runtime duration ?

It's actually somewhat different. AWS Lambda is intended to act as your origin server. Generally your Lambda functions run in a small number of locations, not necessarily close to users. Cloudflare Workers will run in all of Cloudflare's 117 (and growing) locations. The idea is that you'd put code in a worker if you need the code to run close to the user . You might want that to improve page load speed, or to reduce…

How do you store scripts in each edge ? Since in 1 of 117 datacenters, you'll need all scripts from all customers ready to go/execute.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#46
This is probably the best annoucement of a new feature I have ever read. It makes an analogy to an existing technology. It provides a clear description of the new feature. It provides clear examples of how to use the new feature with a link to a sandbox so you can run and modify the examples. And it explains the thought process behind the implementation. In additon, I didn't notice a single typo, spelling or grammar error.

Also, this feature is pretty cool!

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#47
post #43

Could this be used for HTTP Push across domains? I would love an easy way to take advantage of HTTP Push for assets hosted on S3 without routing requests to my origin server.

Yes, your worker can make subrequests to other domains, and serving some assets out of S3 is a use case we specifically want to enable. I haven't looked into how specifically to expose HTTP Push in the API but that certainly seems like something we should support.

Please, add support HTTP/2 push!

This is very, very awesome work. My team has been working on enabling the PRPL pattern[1] and differential serving on a few platforms, and edge caching has been a problem. We've tried to use Vary: User-Agent, but that leads to low cache hits. This API would let us to much smarter UA sniffing at the edge.

From there we just need to parse some responses like JS and HTML, to be able to push their sub-resources, for an instant speedup and great caching for fine-grained deployments.

[1]: https://developers.google.com/web/fundamentals/performance/p...

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#48
post #28

Have you guys considered side channels? Seems like whenever there's co-execution (VMs, JavaScript, etc) there seem to be side channel leakages.

We're certainly aware of them, but haven't spent a lot of time focused on this issue yet. Of course, the issue exists on all forms of shared compute. So if you're going to do crypto, you'd better make it constant-time. Which is... not easy in Javascript. (But we will provide the WebCrypto API, which might help.) There is a theoretical solution that we might be able to explore at some point: If compute is deterministi…

> There is a theoretical solution that we might be able to explore at some point: If compute is deterministic -- that is, always guaranteed to produce the same result given the same input -- then it can't possibly pick up side channels.

Doesn't this require the timing and interleaving with other processes also be deterministic? ...which seems hard to guarantee with modern CPUs, async IO, and shared execution.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#49
post #28

Earlier quoted context omitted.

We're certainly aware of them, but haven't spent a lot of time focused on this issue yet. Of course, the issue exists on all forms of shared compute. So if you're going to do crypto, you'd better make it constant-time. Which is... not easy in Javascript. (But we will provide the WebCrypto API, which might help.) There is a theoretical solution that we might be able to explore at some point: If compute is deterministi…

> There is a theoretical solution that we might be able to explore at some point: If compute is deterministic -- that is, always guaranteed to produce the same result given the same input -- then it can't possibly pick up side channels. Doesn't this require the timing and interleaving with other processes also be deterministic? ...which seems hard to guarantee with modern CPUs, async IO, and shared execution.

If you don't provide (real) time as an input to the program, then non-determinism of time does not affect determinism of the program. At least, in theory. It's definitely a long way from there to practice.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#50
post #10

Earlier quoted context omitted.

It's actually somewhat different. AWS Lambda is intended to act as your origin server. Generally your Lambda functions run in a small number of locations, not necessarily close to users. Cloudflare Workers will run in all of Cloudflare's 117 (and growing) locations. The idea is that you'd put code in a worker if you need the code to run close to the user . You might want that to improve page load speed, or to reduce…

How do you store scripts in each edge ? Since in 1 of 117 datacenters, you'll need all scripts from all customers ready to go/execute.

Same as any other site setting, all of which need to be pushed to every location. We have existing infrastructure for this that propagates changes everywhere within a couple seconds.
Post reply on HN