Live data from Hacker News

Cloudflare Workers: Run JavaScript Service Workers at the Edge

blog.cloudflare.com

31–40 of 134 posts

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

#31
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…

We haven't nailed down pricing yet One of the things I like about AWS is the price doesn't jump from $0/year directly to $240/year the way cloudflare does.

On the other hand, there's no surprise uncapped charges when something unexpected happens.

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

#32
post #2

Hey all! This is my project at Cloudflare. (You may remember me as the tech lead of Sandstorm.io and Cap'n Proto.) Happy to answer questions!

Congratulations on the announce - it seems like a game changer of a feature, and one I look forward to testing.

Will Cloudflare be curating a list of useful worker scripts? I imagine there will be certain usecases that get a lot of attention (e.g. ESI)

Do requests made from the API go through Cloudflare's usual pipeline, or do they go straight to the backend? In short, will we need to manage the cache ourselves?

And finally, does this change Cloudflare's role as a "dumb" intermediary?

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

#33
Kudos for re-using an existing API when one was already available in the same language for a very similar usecase.

Any time you commit to someone else's API -- whether it's an actual industry standard, or simply some de facto widely used paradigm -- you incur risks; conversely, now that you're a vested participant, consider being involved in the future of the spec so it can evolve where it needs to meeting emerging needs around its new uses.

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

#34

This is really cool...but why ?

I thought of a few use cases...

A more granular way to block requests than what cloudflare provides (IP, BGP AS, country)

Tokenizing credit cards at the edge if you have a payment provider that supports that, and are using CF's PCI compliant environment.

Injecting a unique ID into requests for log correlation. You get collisions if you do this via browser javascript for various reasons. I'm assuming v8 has a better Math.random(), or that you would at least be able to find a workaround since it's in one stack.

I'm sure there's more.

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

#35
post #2

Hey all! This is my project at Cloudflare. (You may remember me as the tech lead of Sandstorm.io and Cap'n Proto.) Happy to answer questions!

Congratulations on the announce - it seems like a game changer of a feature, and one I look forward to testing. Will Cloudflare be curating a list of useful worker scripts? I imagine there will be certain usecases that get a lot of attention (e.g. ESI) Do requests made from the API go through Cloudflare's usual pipeline, or do they go straight to the backend? In short, will we need to manage the cache ourselves? And…

> Will Cloudflare be curating a list of useful worker scripts?

Better than that, we plan to unify this with Cloudflare Apps, so people can publish a reusable script as an app, and other people can then "install" that app onto their site with a click.

> Do requests made from the API go through Cloudflare's usual pipeline, or do they go straight to the backend? In short, will we need to manage the cache ourselves?

The worker sits in front of the cache, so subrequests made by calling fetch() will go through the usual caching logic.

Eventually we also plan to expose the "Cache" API from standard Service Workers to allow you to manipulate the cache directly for advanced use cases, but this shouldn't be necessary for most people.

> And finally, does this change Cloudflare's role as a "dumb" intermediary?

That sounds like a policy question, which isn't my department. ;)

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

#36
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…

Can I use this together with CloudFlare streaming to open up stream ingestion based on some HMAC signed parameters?

To give regular end-user the rights to e.g. 'record one video of up to X seconds and Y mbps under ID "some-uuid"'

I've been waiting for a proper Content Ingestion Network for ages by now... if the CloudFlare video team ever wants to talk to someone who hand-rolled their own single-node version of this I'd be more than willing to share my experiences.

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

#37

This is really cool...but why ?

I worked for an analytics company at one point and we generated impression IDs server side (you'd be surprised how broken client-side JS randomness can be) and included them in our loader. If we had been using CloudFlare I would have put our loader directly into this service worker so that we could shave a few more milliseconds off our intial response time, so that we could get to our cached JS faster.

So yeah, if you care about milliseconds :)

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

#38
post #33

Kudos for re-using an existing API when one was already available in the same language for a very similar usecase. Any time you commit to someone else's API -- whether it's an actual industry standard, or simply some de facto widely used paradigm -- you incur risks; conversely, now that you're a vested participant, consider being involved in the future of the spec so it can evolve where it needs to meeting emerging n…

Absolutely! One reason we wanted to get this out in public before it's ready is so we can properly engage with the spec writers (and the V8 team).

That said, I am amazed by how well the spec fits as-is. I don't usually like other people's API designs but in this case I think they did a really good job, and I've been pleased not to have to think about API design myself.

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

#39
post #36
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…

Can I use this together with CloudFlare streaming to open up stream ingestion based on some HMAC signed parameters? To give regular end-user the rights to e.g. 'record one video of up to X seconds and Y mbps under ID "some-uuid"' I've been waiting for a proper Content Ingestion Network for ages by now... if the CloudFlare video team ever wants to talk to someone who hand-rolled their own single-node version of this I…

That's a really interesting idea!

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

#40
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…

We haven't nailed down pricing yet One of the things I like about AWS is the price doesn't jump from $0/year directly to $240/year the way cloudflare does.

Indeed, this would be the second product announcement from Cloudflare in 3 days that didn't have any pricing available.
Post reply on HN