top | item 29947320

Set up a practically free CDN

399 points| frogger8 | 4 years ago |gist.github.com | reply

149 comments

order
[+] onphonenow|4 years ago|reply
Some caution with cloudflare:

Because they give a lot away and post blog posts attacking AWS folks think they are cheap. But a lot of their free stuff may be in the marketing budget. The issue here is:

1) Their paid offerings for their core product, CDN, does not have a public pricing guide. That's a BAD sign if they claim to be competing on price. So we can pretty safely assume their paid service bandwidth charges are NOT the 80X cheaper than amazon despite their claims here.

2) They hype their bandwidth alliance. I tried following this up on Azure, it's basically all call a sales person / maybe you'll get a deal type stuff. Smoke and mirrors again.

3) If you actually try to use their CDN to serve something high bandwidth (games / software updates / video streaming) that is going to violate some type of clause which says that the free CDN is not REALLY unlimited.

4) Financially they spend a mind boggling amount on sales costs. Between sales costs and cost of sales I think they are negative relative to revenue.

BTW - If you try any of the other "free" and "unlimited" providers (for $5/month etc) you will also find out once you try to move some real data volumes (video etc) - it's all a lie over and over.

Same things with geo issues. Cloudflare claims to have "one" price globally. These are almost alwyas false claims. It's easy to test - setup a stream into a high cost area, stream a bunch of video there - you'll usually get a call over some tricky TOS issue they pull out.

In short, if you want pay and forget, there is a reason the big cloud players have a business still.

[+] WM9t27Ta|4 years ago|reply
Enterprise customer here. throw away account, since not sure how much I should be able to divulge...

1: we are paying (ballpark) 5-10k for our account. We have 5-10 domains on the enterprise plan, and we have roughly 100m requests per month plus about 70TB bandwidth, IIRC... Mind you, we have other sites that are on Pro ($20) or business ($200) plans and they are coming in at around a million requests a day (only about 2-3Gb a day) and no one complains.. could be the 5-10k we spend a month with them makes them think twice... Most of our cost is for the 24/7 tech support, regular meetings, etc. extra domains are a somewhat fixed cost (little over double a business plan domain) and that gives us extra features.

2: for Azure and BW Alliance, we were told you need to use a storage account and use "Internet Routing" not "Azure Routing" for the account. Azure routing is, IIRC, 12c per Gig. Internet routing is closer to 8c... Cant see an option for Servers, but I think Internet Routing might work for them too...

3: Any proof of this? I do know there is a limit of 256Mbyte for free account files, but not sure about what the limits on Pro or Business accounts...

4: https://cloudflare.net/news/news-details/2021/Cloudflare-Ann... Seems they spend nearly double on Sales and Marketing than they do on R&D... and they seem to be currently loosing money, but what startup doesn't lose money for the first few years?

[Edit: formatting]

[+] mathattack|4 years ago|reply
They don’t list because they are still in the “what the market will bear” model of pricing.

My experience was their sales team talked a good game up until the time to bid, and then Akamai closed enough of the pricing gap to not make it worth switching. Cloudflare seemed like great technology but their pricing suggested they had already won the business. I can only imagine how they treat existing customers once there are switching costs.

[+] judge2020|4 years ago|reply
To summarize your point, yes, Cloudflare is not entirely free for all. Cloudflare specifically states why they have this sort of model, from their S-1 [0]:

> Our free customers create scale, serve as efficient brand marketing, and help us attract developers, customers, and potential employees. These free customers expose us to diverse traffic, threats, and problems, often allowing us to see potential security, performance, and reliability issues at the earliest stage. This knowledge allows us to improve our products and deliver more effective solutions to our paid customers. In addition, the added scale and diversity of this traffic makes us valuable to a diverse set of global ISPs, improving the breadth and economic terms of our interconnections, bandwidth costs, and co-location expenses. Finally, the enthusiastic engagement of our free customer base represents a “virtual quality assurance” function that allows us to maintain a high rate of product innovation, while ensuring products are extensively tested in real world environments before they are deployed to enterprise customers.

That's the value they get for providing the service for 'free' for quite a lot of websites that aren't moving real data volumes. For millions of websites, this is a sweet deal for them since it still saves them hundreds of dollars in bandwidth a month while they provide enough value to CF indirectly to not be considered a loss-leading customer (in which the customer would get "the call" saying they need to start directly paying for their usage of CF).

So is it an opaque, customer-hostile pricing strategy? Sure, but even image boards doing petabytes a month serving images are within the realm of never needing to pay for their direct usage of the service since CF still sees that as a worthwhile marketing and intelligence source. It's only when you actively cause them to lose money (such as streaming video in eg. the Oceania region) or start proxying raw binaries on a domain that proxies nothing else [1] that CF doesn't see a reason to keep your domain around as a charity case.

0: https://www.sec.gov/Archives/edgar/data/1477333/000119312519...

1: https://community.cloudflare.com/t/the-way-you-handle-bandwi...

[+] rileymat2|4 years ago|reply
Point 3 is very true, however as far as competing on price, CloudFlare was a fraction of the cost of cloudfront when we had priced it out, despite the nontransparent pricing.
[+] manigandham|4 years ago|reply
> "does not have a public pricing guide"

Most of their pricing is public: https://www.cloudflare.com/plans/

This includes the CDN product, workers, security services like Access and Teams. Only the Enterprise plan and other products require negotiation, but the majority of customers are easily covered by the standard options.

> "high bandwidth (games / software updates / video streaming) that is going to violate some type of clause"

The clauses are publicly stated in their terms. The CDN is for typical website assets and not large files, but many sites are running TBs of bandwidth for free or with the regulars plans though. Large file delivery requires different technical setup from small/dynamic requests, and there are CDNs specialized for that. You can also rent unmetered servers or interconnects yourself and get much better rates instead of using a CDN.

[+] frogger8|4 years ago|reply
Looking at your comment history, you mention AWS often. Do you work there?
[+] nerdbaggy|4 years ago|reply
The amount of sales calls and PowerPoints are crazy with CloudFlare. AWS makes it soooooo much easier to spend money and their sales are so less naggy.
[+] kondbg|4 years ago|reply
Using Cloudflare to proxy B2 content seems like it directly violates Cloudflare's ToS.

https://www.cloudflare.com/terms/

> 2.8 Limitation on Serving Non-HTML Content

> The Services are offered primarily as a platform to cache and serve web pages and websites. Unless explicitly included as part of a Paid Service purchased by you, you agree to use the Services solely for the purpose of (i) serving web pages as viewed through a web browser or other functionally equivalent applications, including rendering Hypertext Markup Language (HTML) or other functional equivalents, and (ii) serving web APIs subject to the restrictions set forth in this Section 2.8. Use of the Services for serving video or a disproportionate percentage of pictures, audio files, or other non-HTML content is prohibited, unless purchased separately as part of a Paid Service or expressly allowed under our Supplemental Terms for a specific Service. If we determine you have breached this Section 2.8, we may immediately suspend or restrict your use of the Services, or limit End User access to certain of your resources through the Services.

If this was truly acceptable and not in some grey area, why doesn't Backblaze simply route all downloads through Cloudflare by default, rather than having each individual customer go through the hassle of setting this up?

[+] cmeacham98|4 years ago|reply
If you only use this for "standard" CDN assets (like pictures that are part of your website styling rather than as an image host) and you also host your website on Cloudflare, I think it should be ok.
[+] nacs|4 years ago|reply
> If this was truly acceptable and not in some grey area, why doesn't Backblaze simply route all downloads through Cloudflare by default, rather than having each individual customer go through the hassle of setting this up?

Because Backblaze makes more money charging you for repeated downloads?

[+] samwillis|4 years ago|reply
This B2/CloudFlare combination is a good one.

CloudFlare are about to launch their own object/file store with native CDN called R2. They have even come up with a wonderful trick for migrating to it from S3 and it’s looks like it’s going to have an incredible generous level of free egress. I suspect that it will beat out the B2/CloudFlare combination once it launches.

https://blog.cloudflare.com/introducing-r2-object-storage/

Edit: Typo

[+] boffinism|4 years ago|reply
> 440% cheaper than S3 per GB.

However the author thinks percentages work.... They are not right.

[+] d1sxeyes|4 years ago|reply
Driven by the fact that using comparative adjectives in this context seems to be at best confusing, I thought I'd play around with some numbers to see if I could understand what the author was trying to convey.

First, it's important to clarify why comparative adjectives don't work here. Look at the following sentence.

- A $5 cookie is worth twice as much as a $2.50 cookie

Here, we establish the baseline (the $2.50 cookie), and express how much better the $5 cookie is.

We could also say the inverse:

- A $2.50 cookie is worth half as much as a $5 cookie.

What we can't do is the following:

- A $5 cookie is double more expensive than a $2.50 cookie.

We can make a statement (the cookie is more expensive), or share the factor by establishing the baseline (twice as expensive as), but not both at the same time.

The author tries to say 440% cheaper, (not mentioning storage or transfer) and I believe their logic was something along the lines of the below:

- 440% = 440/100

- Cheaper = Reciprocal of More expensive

- 440% cheaper = 1 / (440/100) = 100/440

- S3 is very difficult to estimate a 'per GB price' because it depends on where the data is being transferred to, various pricing tiers (S3, S3 intelligent, 'Glacier', 'infrequent access', 'One Zone', first 100GB free, egress through Cloudfront, and HTTP verb specifics). Fortunately, they have an estimate calculator, which gave me 9 USD for 100GB transferred out to the internet, or 0.09USD/GB for transfer.

- Storage is a different proposition, with Amazon telling me it'll cost 2.30 USD for 100GB as long as I never look at it (ie: 0.023USD/GB)

- Backblaze is much easier to reckon with, with $0.005/GB for storage, and $0.01 for transfer.

- Therefore, for transfer Amazon's 0.09 * (100/440) = 0.02, which is MORE than Backblaze would charge me.

- For storage, Amazon's 0.023 * (100/440) is indeed 0.005.

So, Backblaze does indeed seem to be [440%, reciprocal of more expensive] as Amazon for storage cost alone.

[+] ralferoo|4 years ago|reply
Then again, the title of the post says "practically free" and goes on to say it's actually $5 a month, so I took the rest of the figures with a grain of salt...
[+] guy98238710|4 years ago|reply
The wording is indeed confusing, but not every interpretation is wrong. They might mean 440% more efficient, i.e. 5.4x cheaper.
[+] zild3d|4 years ago|reply
yeah pretty sure they mean 77% cheaper
[+] parsadotsh|4 years ago|reply
It does make sense. Consider the phrase "twice as cheap"
[+] searchableguy|4 years ago|reply
Many of the files will violate cloudflare terms of service. You cannot put video files behind normal cloudflare cdn as an example.

This is a risky setup.

[+] cj|4 years ago|reply
I was expecting to read about how to set up the infrastructure to run my own CDN infrastructure for free (hard to believe is possible, so I clicked).

Instead, it's an article about how to use Cloudflare to deliver static assets for free, on Cloudflare's free tier.

Edit: I would love to read more about how to set up a cheap self-managed CDN, perhaps using cheap VPS servers spread out in different regions.

[+] ani-ani|4 years ago|reply
Assuming this is for websites, what's the recommended way of handling cache busting with this kind of setup? The article has a slightly awkward paragraph that tells you to set long TTLs for everything and concludes with "tweak these settings", which kind of sounds like "draw the rest of the owl". Might be a good reason to use something that integrates all this (eg. Cloudflare Pages, since you're already using Cloudflare).
[+] dinkleberg|4 years ago|reply
I know every use case is different, so this may not matter for most. But in my experience, the performance of B2 was quite poor in comparison to other S3 compatible options. It seemed like the crux of the issue was slowness in their API. Generating pre-signed URLs for file upload or download was quite a bit slower, resulting in a poor user experience in my application.

If you're just using it to upload public static content for your site, this shouldn't be an issue. But if you're dealing with private content it probably isn't the optimal solution.

[+] jrochkind1|4 years ago|reply
> Generating pre-signed URLs for file upload or download was quite a bit slower,

I'd be shocked if generating pre-signed URLs required talking to the Backblaze server, that should be something done totally in client code.

However, even with AWS S3, I discovered that the official AWS ruby SDK client was much slower that it could/should be at generating pre-signed URLs (and even just public URLs!), and was able to write my own ruby code to be significantly faster.

https://github.com/jrochkind/faster_s3_url

I'm curious for the specifics on what code you were using to generate pre-signed URLs for file upload or download with backblaze, and what you are comparing it to when you say it's a lot slower. It could be un-optimized code, but whose "fault" it is depends on what code it is, open source etc.

[+] dotancohen|4 years ago|reply
I would love to hear more. I had a gig where we considered S3 and B2 for serving very private files (financial records). With B2 I could not find a good way to ensure that, assuming the URL is known, a file could only be accessed by an authorized party.
[+] modeless|4 years ago|reply
I've been using Cloudflare free in front of App Engine's free tier for a few years and it really seems too good to be true. I can go viral and scale to infinity, for exactly $0.
[+] anaganisk|4 years ago|reply
The other day one of the commenters under a post wanted to spend $20 per month to host a static website to handle HN traffic, I just LOL’d. I tried to be good and explain why it was so unnecessary but nah they would rather bring a canon to a water gun fight.
[+] indigodaddy|4 years ago|reply
Cloudflare in front of Replit or Vercel would be same idea right
[+] anduru_h|4 years ago|reply
I've been using BunnyCDN - it's been pretty cheap (<$5 month for 250GBs of data transfer).
[+] mike503|4 years ago|reply
+1 for Bunny, if you cannot take advantage of a free tier somewhere and have to pay. Setup a client of mine on it for video and images, real-time image modifying/branding, smooth video playback (without using a special product) all using the equivalent of presigned URLs - for a surprisingly low amount of money each month. Lots of good stuff going on there.

They also have their own storage options that are tightly integrated to their CDN, but basic FTP and simple API for it still. No S3 or bulk options there yet. Promised S3 API support “soon” though

[+] ggm|4 years ago|reply
"if everyone does it, they won't let you do it" -the infinite cache life on CF only works because 99.99% of use of the cache stays in rational cache lifetimes. If everything had long persist, CF would begin cache ejection, and your cost goes up, or they change the ToS to forbid it.

LRU exists for a reason.

[+] aantix|4 years ago|reply
Interesting setup.

And with Rails, it appears that there’s a third party ActiveStorage adapter for BackBlaze.

https://github.com/jeygeethan/activestorage-backblaze

Direct uploading from client : https://github.com/jeygeethan/activestorage-backblaze-javasc...

[+] jrochkind1|4 years ago|reply
Backblaze also has an S3-compatible API, so you should be able to use the S3 adapter with backblaze too, instaed of the third-party backblaze-specific adpater using backblaze-specific API. You can use either S3 API or Backblaze API with the same bucket, simultaneously even.
[+] destitude|4 years ago|reply
Haven't a lot of people on HN warned against using Backblaze for backup because of issues restoring from backup? I recall reading someone having to pay to have a physical drive sent to them to restore a backup because of speed/cost issues trying to restore over network.
[+] hinkley|4 years ago|reply
Never underestimate the bandwidth of a station wagon full of data tapes hurtling down the highway.

Randall Munroe estimates it'll be 2040 before the Internet has more bandwidth than FedEx: https://what-if.xkcd.com/31/

[+] celsoazevedo|4 years ago|reply
You're probably thinking about their computer backup service. This post talks about B2, an object storage service like S3.

While B2 isn't as fast as S3 and some tasks are way slower (eg: deleting files), I'm able to max out my server's 1Gbps connection when sending or downloading files from their European DC (using rclone and a server also in Europe).

[+] wrycoder|4 years ago|reply
They will refund the drive cost when you mail it back.
[+] Rastonbury|4 years ago|reply
I think it's their consumer facing Dropbox like desktop tool not B2
[+] marcodiego|4 years ago|reply
We have a free CDN. It is called bittorrent.
[+] outloudvi|4 years ago|reply
B2-Cloudflare was a great companion when Cloudflare's Bandwidth Alliance was a thing and outgress from B2 to Cloudflare didn't cost anything, which means that outgress was completely free since Cloudflare don't charge on outgress.
[+] ricardobeat|4 years ago|reply
Why “was”? Seems like everything you mentioned is still true. It’s the whole point of the post.
[+] timtom39|4 years ago|reply
Bandwidth Alliance isn't a thing anymore? My deployment is still serving multiple TB a day free. Do you have a link?
[+] ksec|4 years ago|reply
This reads to me as B2 / Cloudflare are no longer in Bandwidth Alliance?
[+] sixhobbits|4 years ago|reply
I have been very happy with DigitalOcean spaces for $5/month including 250GB storage, 1TB outbound, and custom domains. Seems like something more closely comparable to this set up so I am surprised it isn't part of the comparison.
[+] aftbit|4 years ago|reply
I've done this by using Cloudflare Workers. I can confirm that I did not see any bandwidth charges at B2, although I've only tested a few GB of transit. Likely if you tried to host brew here, you'd get yelled at.