Cloudflare has a lot more to offer than merely DDoS protection and CDN services. On this episode, Jon Kuperman joins Amal & Jerod to talk through many of their cool new things like Workers, KV, Durable Objects, and R2 Storage. Thanks to listener Matt Mannucci for requesting this episode!
Jon Kuperman: Yeah, Iād say thereās the big things, like to check out ā if you start a new Pages app, or if you move your site onto Cloudflare, just playing around in the dashboard, which weāve been working on design tweaks to, but⦠We basically have a lot of cool stuff about automatic image optimization, making your images smaller, or reading the device size and serving images⦠So thatās like Polish and Mirage.
[43:59] Then we have the Rocket Loader, which will turn off unnecessary [unintelligible 00:44:02.07] So weāve got a lot of these options, and these are all one-click options for the most part. So if you start a new Cloudflare Pages app, or if you move your website over⦠Sort of looking at these things - automatic imagery sizing, automatic compression of JavaScript and CSS and HTML, serving images by the device width⦠Or with the automatic resizing, every time we have to do a resize, we save it, too. Thatās like a paid service. And so then you just upload one image, and then as devices come in, we start resizing it based on their width, and then we save all those cached in the edge⦠So you end up with 10 or 20 copies of your image. Rocket Loader for speeding up JavaScript-heavy sitesā¦
And then the other one that I wanted to talk about which I think is really cool is we have this tiered caching initiative which is now available in the dashboard⦠So the idea being letās say you have 200 data centers, and you use our CDN. Or we have 200 data centers, you use our CDN. So your stuff gets cached in all 200 data centers, but then every time you do a cache purge, or a user requests something where thereās a miss, it has to always go back to your application.
So a hypothetical, I guess, would be like you have an app, you go buy a DigitalOcean VPS, you put it in your New York City, and you put your app on there⦠And it gets overwhelmed, so then you sign up for Cloudflare CDN, and poof - all of a sudden thereās all this caching stuff. But you can still have this problem where if somebodyās hammering on an end point, or just users are trying to request an end point and itās a miss for the cache - all the caches will start going back to your one DigitalOcean VPS that you bought. Itās almost like a mini-DDOS, an innocent/accidental oneā¦
But you see this ā like, Facebook went down the other day⦠So all of these big sites, like Facebook, Twitter, Google - they take in more traffic than they could possibly serve cold; like, if all the computers went off and all went back on again - theyād just get hammered. So they rely on these caching mechanisms. So one of the problems for these companies when they have an outage and things go actually down - youāll see this all the time, where they keep trying to go back up, and itās like up and then down again. And then itās like, they go up and they go down. So they have to come up with these clever ways of like āOkay, weāll go up, but weāll block any users whose names donāt start with Aā, or theyāll come up with these ways of doing these slowly booting back on, so they donāt get just decimated again.
So the same thing can happen with just anybodyās application, where you have like this one VPS that can handle (whatever) 100 or 1,000 hits a second, and then something gets purged from the cache and all of your users are trying to hit it - boom, it takes it down again.
So we came up with the idea of tiered cache, where we take those 200 and we mark, letās say, 25 of them as top-level cache CDNs. Like, cut top-level endpoints. So what happens is now the other 175 are no longer allowed to hit origin when they have a cache miss. What they have to do is they have to find their closest top-level cache system and ask it for the file.
So itās like, āI need a JPEG, and I hit this one ā Iām in Florida, so I hit the Miami one. Miami doesnāt have it. Miami is no longer allowed to just hit New York.ā [unintelligible 00:47:10.19] it canāt do that anymore. It has to find its closest one, letās say like in South Carolina, and be like āDo you have the JPEG?ā And only if that doesnāt have the JPEG, South Carolina has permission to hit New York now.