Hacker News new | ask | show | jobs
by thamer 2220 days ago
I use Hugo (https://gohugo.io/) to generate static pages and host them on Amazon S3, with CloudFront on top of it for fast delivery. AWS also provides a free SSL certificate, and DNS with Route53.

I couldn't be happier with the setup: it's cheap, fast, requires zero maintenance and pretty much never goes down. Cost is close to nil: the most expensive part is for Route53 at $0.50 per Hosted Zone, and then S3+CloudFront add a few cents more.

If folks want to see how fast static pages can be on a CDN, the site is at https://re.kv.io

P.S. I didn't have to install Docker or MySQL.

2 comments

The only problem with that setup is if a post goes viral CloudFront will cost you a pretty penny. I had one post with ~1MB of assets that was read (IIRC) 70k times in a month and got an ~$80 bill. I’ve since switched to Cloudflare.
The AWS Calculator[1] reports that 70 GB (70k times 1 MB) of transfer out of CloudFront costs ~$3 and another 70 GB to the origin costs about another $3 – this would only be the case if the 1 MB was dynamically generated. The free tier is 50 GB and 2 million requests per month, and beyond that it’s ~0.085/GB in the US so 70 GB would cost 70 * 0.085 = $5.95. You also need to count $0.01 per 10k HTTPS requests, or $0.07 for 70k.

I'm not sure how you got this bill, none of these numbers are anywhere near $80.

[1] https://calculator.s3.amazonaws.com/index.html

OK, I was off quite a bit and the total of all assets on the page is 27MB. That's mostly due to several HD pics on the page and one 2-second soundless looping MP4.

The total CloudFront bill was $87.65, the bulk being $74.98 spent in North America (2.5M requests @ $2.52, 852.518 GB data transferred @ $72.46). Those prices are as of March 2019. Doing that math that's only 31.5K page loads in North America (my 70K view number is from Google Analytics worldwide and may have straddled months, or counted re-views, I dunno).

Now, I remember running those pics through TinyJPG so they are as compressed as possible. And I could probably add some kind of JavaScript lazy loading library to only load images as users scroll down to them. Or, I could just use Cloudflare and not think about it. /shrug

If you're just hosting purely static assets why not use a free hosting with GitHub pages and a custom domain? It comes with free SSL (now) and I assume it could handle all sorts of traffic spikes. I might not be aware of any major downsides so I'm curious why people decide to use a paid (even if it's super cheap) option. I believe also Gitlab offers similar options.
I've had poor experiences in the past with GitHub pages, with pages failing to build or hosting being terribly slow. This was years ago though, things may have changed since then.

That said, I can still count 9 occurrences of degraded performance for a total of 16 hours and 40 minutes in the past 90 days for GitHub pages on https://www.githubstatus.com/ – as a matter of fact performance is shown as degraded right now. That's pretty terrible.