SE Radio 667: Ashley Peacock on Cloudflare
Ashley Peacock, the author of Serverless Apps on Cloudflare, speaks with host Jeremy Jung about content delivery networks (CDNs). Along the way, they examine dependency injection with bindings, local development, serverless, cold starts, the V8 runtime, AWS Lambda vs Cloudflare workers, WebAssembly limitations, and core services such as R2, D1, KV, and Pages. Ashley suggests why most users use an external database and discusses eventually consistent data stores, S3-to-R2 migration strategies, queues and workflows, inter-service communication, durable objects, and describes some example projects.
Brought to you by IEEE Computer Society and IEEE Software magazine.
Ashley Peacock, the author of Serverless Apps on Cloudflare, speaks with host Jeremy Jung about content delivery networks (CDNs). Along the way, they examine dependency injection with bindings, local development, serverless, cold starts, the V8 runtime, AWS Lambda vs Cloudflare workers, WebAssembly limitations, and core services such as R2, D1, KV, and Pages. Ashley suggests why most users use an external database and discusses eventually consistent data stores, S3-to-R2 migration strategies, queues and workflows, inter-service communication, durable objects, and example projects.
Brought to you by IEEE Computer Society and IEEE Software magazine.
Show Notes
- Twitter: @_ashleypeacock
Related Episodes
Transcript
Transcript brought to you by IEEE Software magazine.
This transcript was automatically generated. To suggest improvements in the text, please contact [email protected] and include the episode number and URL.
Jeremy Jung 00:00:18 Today I am talking to Ashley Peacock. He’s the author of Serverless Apps on Cloudflare and he was a previous guest talking about diagramming and software engineering. Ashley, welcome back to Software Engineering Radio.
Ashley Peacock 00:00:31 Hey, glad you’re back and looking forward to talking about Cloudflare today.
Jeremy Jung 00:00:34 For anybody in our audience who hasn’t heard of Cloudflare, what is it?
Ashley Peacock 00:00:39 So I guess Cloudflare’s been around for quite a while. It started out as a kind of cloud security company and then over the years they’ve had different phases where they gradually grow from doing security related to websites. So bot protection, content delivery network, things like that. And they’ve slowly migrated to also introduce a developer platform that’s not unlike AWS. So you can go on, you can deploy your apps they’ve got everything you need. And those are the kind of two main pillars I would say of what Cloudflare offers.
Jeremy Jung 00:01:10 And I think maybe a lot of people’s first exposure to Cloudflare is as a CDN. So maybe you could explain it at a high level what a CDN is.
Ashley Peacock 00:01:19 Yeah, so let’s say you have a WordPress blog and you host it on a virtual machine or some shared hosting you’re effectively hosting it on a single server. And let’s say you’re really lucky, you write a really positive blog post, it goes viral gets retweeted everywhere. Your little VM or your shared hosting might not survive the rush of traffic. And what a CDN can do is it distributes your content from your blog. So the images, the JavaScript CSS and the content itself globally around the world. And then what happens is whenever a request comes in, the CDM will check and see if it has content in its cache. If it does, it’ll return it without ever hitting your VM. So that gives you decreased LA latency, so fast responses for end users and it also puts a lot less pressure on your VM. And then with Cloudflare that’ll also give you some security protection to protect you from attacks and bot protection and things like that. So it, it’s effectively like a proxy sitting kind of like in front of your website as a bit of a shield and just gives you those benefits that I outlined.
Jeremy Jung 00:02:26 And you mentioned it’s starting to become more of a developer platform. What do you mean specifically by that?
Ashley Peacock 00:02:35 So if you go back to the origins of Cloudflare, it was a security company the CDM we talked about. That’s how it largely started and the very kind of beginnings of its developer platform. Weíre allowing people who use the proxy to do things like modify the request headers before the content is sent back. So you could add a HTP header for example or modify the response. And that was the very kind of beginning of what’s called a Cloudflare Worker, which is like a serverless function. You can write some code, be executed when a request comes in. And then over the years they’ve taken what was something very simple to just modify the headers and you can now deploy fully fledged applications to Cloudflare develop platform. So Workers give you compute very similar to a DS Lambda in some ways, but also very different.
Ashley Peacock 00:03:26 And they have the other kind of core building blocks that you would expect to build applications. So databases, caches, queues, all those sorts of things that you use from AWS like R2 and Aurora and all those things. But it’s a lot more focused than AWS. So AWS these days has, I don’t know how many services it has, but it’s in the hundreds, right? And Cloudflare focused on the kind of core building blocks for your website I would say. And particularly in the last few years, they’ve really kind of pushed that developed platform and added what I would say are the kind of missing pieces. Like they didn’t have a database, they didn’t have object storage, but it’s really come on leaps and bounds in recent years. And I think it’s at the point where it’s starting, you can start to see the momentum and people start to pick it up and realize actually it’s a kind of complete platform for building apps these days.
Jeremy Jung 00:04:13 And you mentioned Workers as an example, it sounds like that’s very similar to AWS’s Lambda. Why would someone who for example, is already on AWS look at something like Workers?
Ashley Peacock 00:04:25 I think one of the huge selling points for Cloudflare in my opinion is with Lambda for example, let’s just take Lambda because it’s probably the biggest one that everyone knows it’s been added to AWS but they also have hundreds of other services. They’ve kind of bolted on serverless and Lambda onto their offering. And it works, very nicely. It’s not a bad product by any means, but with Cloudflare’s offering, they always envisioned their entire platform being serverless. So it’s designed from the ground up to be serverless. Not only that but they focused on things that are important to me and you with developer experience and how easy and enjoyable it is to build on the platform. Like if you’ve ever built anything on a US lately, you probably spend half an hour trying to get your IAM Policy just right because it keeps on not quite working. You tweak it, you tweak it, tweak it, eventually you get there or you need it and then you need a VPC or you need an IP address or something. With CloudFare there’s no such roadblocks. It’s more like the platform is kind of working with you and they’ve really designed it for engineers versus AWS to a point has to kind of build and market to the CTOs and people that are not building those products. Whereas Cloudflare, I think it’s taken a slightly different approach.
Jeremy Jung 00:05:35 What it sounds like is maybe the developer experience or the ease of use is more optimized on Cloudflare than it would be for someone getting started with AWS?
[...]