Great post, enjoyed your writing style and drawings a ton! One of the bigger things I think Workers have going for it versus others is it’s ability to bind WASM modules. Hyper efficient, basically native running computation at edge is a really cool concept. Especially since you can talk to it with a dead-simple JavaScript API. For example, Cloudflare charges a good amount of money for image resizing using their CDN h…
Vercel Serverless Functions vs. Cloudflare Workers
31–37 of 37 posts
Re: Vercel Serverless Functions vs. Cloudflare Workers
#32Can someone knowledgeable please explain where these workers are useful? Serverless components within an main infa. make sense - it's an easier way to deploy. But these 'edge' functions ... what is the advantage of saving a few ms on a transaction? I understand that we may want standard content pushed out to the edge, but in what situation is it really worth all the added complexity of risk of pushing out functions t…
> in what situation is it really worth all the added complexity of risk of pushing out functions to the edge If you are talking about developer point of view, then there is no additional complexity. All the complexity is covered by the underlying platform > what is the advantage of saving a few ms on a transaction? one example - if a transaction consists of a few separate sequential transactions, then ms add up and m…
This is only the case if you are using HTTP/1.1: https://stackoverflow.com/a/45583977/11383840
Re: Vercel Serverless Functions vs. Cloudflare Workers
#33Earlier quoted context omitted.
It's often not actually more complex, it's simpler. With Cloudflare Workers, for example, you don't think about regions, availability zones, provisioning resources, or cold starts. You just write code, and it can scale from one request per second to thousands without any thought or work on your part, partially because of how its designed and partially because it's scaled across so many locations and machines.
> You just write code Except you need to do it in a totally new paradigm (serverless) where you can't require any `npm` packages and you can't query your database unless it's over the `fetch()` API.
You just have to introduce a build tool like ncc (https://github.com/vercel/ncc) which will bundle your app into a single JS file.
Re: Vercel Serverless Functions vs. Cloudflare Workers
#34Re: Vercel Serverless Functions vs. Cloudflare Workers
#35Earlier quoted context omitted.
Yes I'm sure it's down to the cold start issue of Lambda. Are there any tips on how to keep it warm? I didn't go down the static route as I have tens of thousands of product pages. Will check out the Incremental Static Generation - thanks.
So yeah in that case I would do Incremental Static Regeneration but don’t pass all your product paths at build time. Instead you can use the fallback mechanism to render individual product pages on request, but then serve the result statically thereafter. That way you don’t build tons of pages at build time that people may not view anyway, but the pages that do get views will stay fresh and fast. If you were using yo…
Re: Vercel Serverless Functions vs. Cloudflare Workers
#36Earlier quoted context omitted.
One important piece missing from this article is that on Vercel you do not get global Serverless functions on any plan except the Enterprise plans. By default you can pick one preferred region for your Serverless functions and that's the region that's always used. In practice, assuming you have a somewhat decent caching strategy, this doesn't really matter as far as latency is concerned. Where it could potentially ma…
If you store data in firestore, dynmodb, postgres or similar.. does it really matter if the function is distributed?
With Vercel it doesn't matter even in case there is valid cached data, because Vercel doesn't execute the function in that case.
Cloudflare always executes the Function regardless of the existence of cache and it's Function's responsibility to respond with Cached data. Hence, distributed Cloudflare functions is a necessity.
Re: Vercel Serverless Functions vs. Cloudflare Workers
#37Since if the DB is hosted on AWS or GCP, then there would be latency going to that too.
That's what I'm really curious about.
Vercel being mainly on AWS would make the latency to the DB optimal if it is hosted on AWS in the same region. But what if the DB is on GCP?