
How to Serve over 100K Web Pages a Day on a Slower Home Internet Connection - sT370ma2
https://cheapskatesguide.org/articles/low-bandwidth-hosting-tips.html
======
scalableUnicon
Somewhat unrelated but, there are some WordPress themes that are trying to
keep the bytes sent minimum. One such example is:
[https://sustywp.com/](https://sustywp.com/) and there's an excellent article
by its author: [https://blog.jacklenox.com/2018/06/04/delivering-
wordpress-i...](https://blog.jacklenox.com/2018/06/04/delivering-wordpress-
in-7kb/)

~~~
vwcx
Thanks for sharing. I admire this guy's drive.

The ideal world is one where environmental sustainability and server
efficiency are hand in hand like this.

------
ryanmjacobs
I just recently started hosting my personal website in my closet on a laptop:
[https://notryan.com](https://notryan.com).

I also host a Discourse forum. It's pretty snappy for being in my closet
([https://forum.webfpga.com](https://forum.webfpga.com)) Beats paying
DigitalOcean $15/month ($180/year!) for a machine with 2vCPU + 2 GB RAM (the
minimum for Discourse).

I think more people should consider self-hosting, especially if it's not
critical. It makes the Internet more diverse for sure.

~~~
afterwalk
The static ip is free?

~~~
znpy
My ISP gives a public and static IPv4 if you ask for it. Yes it's free.

Also, with IPv6 you have plenty of IPs...

~~~
lstamour
In my case I have a dynamic IP but I use a Linux box as a router and set up
Google DNS record sets for my domains and after every reconnect to Internet
(or PPP connection in this case), a shell script checks to see if the IP
address changed by comparing with a text file, and if it has, it updates the
IP address using the gcloud CLI utility.

The DNS timeout is set relatively low, 5 minutes. I used Google Cloud DNS
because it’s scalable, cheap (the setup costs under $2/month for low traffic)
and has a great API and command line tool. Just took a half day of tinkering
to get it all set up and most days I forget it’s there. (I should probably set
up monitoring, but it’s fine most days...)

If using CloudFlare, it’s possible you could push your dynamic IP to CF as a
DNS host. Haven’t looked into it yet.

And of course there’s the DynDNS approach but most of those approaches seemed
more complicated or costly these days. I also use gcloud to update the DNS for
LetsEncrypt roughly once a month, so it does double duty. The language for the
gcloud DNS CLI tool is a bit technical but try it, test it out, and it’ll
start to make more sense by example:
[https://cloud.google.com/sdk/gcloud/reference/dns](https://cloud.google.com/sdk/gcloud/reference/dns)

For a bit more security, the apps I’m running are in their own virtual
machines and I’ve tried to enable default auto updates everywhere. I keep
telling myself I’ll set up something more complicated to create a continuous
deployment pipeline with test cases and automatic rollback but I haven’t yet
gotten around to it. (Though it would be fun to set up my own virtual PPP
server at some point for running test scenarios, etc.)

~~~
pvtmert
I am using digitalocean's dns api for similar needs. setting
ext.mac.mydomain.com and int.mac.mydomain.com internal and external addresses
from crontab.

since i'm using mac, you may need to change ipconfig command to hostname
-i/-I)

    
    
        DO_INT={internal_record_id}
        DO_EXT={external_record_id}
        DO_BASE=https://api.digitalocean.com/v2/domains/{yourdomain}
        DO_TOKEN={your_token}
        DO_TYPE=content-type:application/json
        */15 */1  * * *  (set -o pipefail; /usr/sbin/ipconfig getifaddr en0 | curl -sX PUT -H "${DO_TYPE}" -H "Authorization: Bearer ${DO_TOKEN}" "${DO_BASE}/records/${DO_INT}" -d "{ \"data\": \"$(cat)\" }" | tee /tmp/ip.int;) &>/dev/null
        */15 */1  * * *  (set -o pipefail; curl -sf wtfismyip.com/text      | curl -sX PUT -H "${DO_TYPE}" -H "Authorization: Bearer ${DO_TOKEN}" "${DO_BASE}/records/${DO_EXT}" -d "{ \"data\": \"$(cat)\" }" | tee /tmp/ip.ext;) &>/dev/null

------
Ecco
Item #9 (use a CDN) is pretty much the exact opposite of the title (serve from
home connection)...

~~~
jaimex2
Yup. If you're going to do that just host the entire thing on github pages and
call it a day.

~~~
eitland
Note that the author specifically mentions this and writes about using it for
new posts and then falling back to selfhosting.

That way you can own your data and serve more visitors.

~~~
dpix
Sure, you can own your own data but if you're serving a public website does it
make any difference?

~~~
astrobe_
"Own your data" maybe is not the right term. What is needed here is that your
data does not vanish because the hosting service goes down or under or
terminates your account.

Maybe things like Mediagoblin or IPFS could do that job.

------
sylvain_kerkour
Hi OP, you seem to be the author of the blog (according to your post history).
Your contact email seems not working so I will write it here: Just a big thank
you for you blog! I take so much pleasure to read it at least once a week!
THIS is the internet I like!

------
arcade79
Reading through the webpage, I was thinking that points 1, 2 and 4 really
wasn't relevant. We're talking about bandwidth limitations being the key
factor here - not the rest.

1\. Page Loading Issues are irrelevant, unless it's because of large items
served over limited bandwidth. 2\. Static vs Dynamic webpages are irrelevant,
if the pages themselves are small. Dynamic of course incurs some CPU on the
server-side, but that is a machine not bandwidth issue. 3\. Limiting the
amount of data is obviously important. 4\. Number of requests to the server is
only relevant for the request-size, CPU and tcp-overhead (which can be
alleviated via multiplexing). 5\. Yes, do compress the pages. 6\. Agree,
website development kits often makes the pages much larger. 7\. Certainly, but
this shouldn't be necessary if you have good cache-headers.

One thing that was not mentioned, was ensuring that static items are cachable
by the browser. This has a huge impact.

~~~
ldoughty
7 is CDN, and is necessary in the case he described shortly before -- a "hot
article". Presumably, a hot article will not get lots of repeat traffic from
the same visitor (sure, someone might browse, but you're probably getting 90%
one-time visitors). Cache headers do nothing here.. a CDN is the only viable
solution... And frankly, using CloudFront for 3 years at work, I started
putting my own websites behind a CDN because it costs pennies to do so.

This does not mean I disagree with your other statements, I too found it a mix
bag of somewhat obvious or slow-server specific (not just low-bandwidth)

------
willvarfar
This is a tangent, but I want to add to the less-is-more vibe!

I run some surprisingly-spiky-and-high-traffic blogs for independent
journalists and authors, that kind of thing. Lots of media files.

There are two ways this typically goes: either you use some platform, and try
and get a custom domain name to badge it with, or else you imagine some
complicated content-management system with app servers, databases, elastic
search clusters etc?

At the time wordpress etc weren't attractive. I have no idea what that
landscape is like now, or even what was so unattractive about wp then, but
anyway...

So we're doing it with an old python tornado webserver with one core, 256MB
RAM VM at a small hosting provider. (I think we started with 128MB RAM, but
that offering got discontinued years ago. It might now be 512MB, I'd have to
check. Whateever it is, its the smallest VM we can buy.) The webserver is
started-if-crashed using cron minute and flock -n.

The key part of the equation is that the hosting provider I use did away with
monthly quotas. Instead, they just throttle bandwidth. So when the HN or some
other crowd descends, the pages just take longer to load. There is never the
risk of a nastygram asking for more money or threatening to turn off stuff or
error messages saying some backend db is unavailable etc.

Total cost? Under $20/month. I think domains cost more than hosting.

The last time I even checked up on this little vm? More than a year ago, I
think. Perhaps two? Hmm, maybe I should search for the ssh details...

My personal blog is static and is on gh-pages. A fine enough choice for
techies.

~~~
rubatuga
$20 seems a bit expensive considering there are $5 VMs

~~~
willvarfar
Yes we probably aren't using the cheapest host in the world. It probably
wasn't even the cheapest when we chose it. We chose it because I'd used them
in my day job and liked their style and support. And the bandwidth throttle
rather than quota is really attractive too.

And I think that more than half of the monthly cost is actually the amortized
domain renewal fees etc, not the vms themselves.

So we could probably save a few dollars if we shopped around and moved? But
I've just spent more time writing on HN today than I normally spend in a year
on thinking about these old servers....

~~~
onli
It's just a few dollars, but a big percentage. $20 is very expensive for what
you have. You could get a $2.50 IPv6 Vultr instance, $3.50 with IPv4. 500GB
traffic there. Scaleway also starts in that price range, and if nothing
changed includes unlimited traffic. See [https://www.scaleway.com/en/virtual-
instances/development/](https://www.scaleway.com/en/virtual-
instances/development/) and [https://www.vultr.com/products/cloud-
compute/](https://www.vultr.com/products/cloud-compute/). The domain will cost
likely $1 the month.

------
ramraj07
How about just putting your static site in S3? What happens when traffic
spikes (other than increase in bandwidth)?

~~~
hagy
Exactly. For an entirely static website, I can't see any reason not to host
content in cloud storage and serve through a CDN (e.g., CloudFront or
Cloudflare). You get the advantage of low cost when running at low volume and
the ability to scale up as needed.

Further, your users will get lower latency and faster downloads when accessing
one of the globally-distributed edge caches. And lastly, you don't have to
expose your own IP address, which puts at risk of DDoS.

Does anyone have a good argument for self-hosting an entirely static website?

~~~
_wldu
It's more fun. You have complete control and you learn more. It's like
building a Morse code key from spare parts rather than buying one from the
store.

Having said that, I think NearlyFreeSpeech provides a great web hosting
service for pennies a day for those who don't want to host at home. I've used
them for years.
[https://www.nearlyfreespeech.net/services/pricing](https://www.nearlyfreespeech.net/services/pricing)

~~~
ramraj07
It's more fun for me trying to host a site on S3 and I get to learn more about
AWS in general. My goal is to have a site that costs a dollar a month baseline
and even if something goes viral the expected bill can never be more than
$10-20

------
meerita
I use Digital Ocean $5 VMs and I never had any problem serving +100k a day on
static pages.

~~~
icebraining
Sure, but $5/month is still $60/year. You could probably buy a new Raspberry
Pi every year and pay for its electricity for that kind of money.

(This assumes you already have an internet connection at home, of course)

~~~
ryanmjacobs
^ This exactly. A half-decent used Thinkpad can be picked up for slightly
north of $120. And it will have 4-8x RAM and at least 4-5x CPU performance.
And you own it! The only thing you potentially miss out on is: uptime SLAs
("reliability") and a higher-speed internet connection.

You also might miss out on a public IPv4 address, but that's whole 'nother
issue... FRP (fast reverse proxy) is a decent workaround for this.

~~~
donjoe
Now take into account electricity costs. Where I live, running a Lenovo
constantly @10w for a year would cost me $30. Then you avg the remaining
lifetime of your laptop (5yrs) and the time you spent setting it up and you
will find out, a $5 droplet is a cheaper option ;-)

~~~
ryanmjacobs
Fair point, it depends on your workload a lot. If you're hosting a few static
sites, a droplet _might_ be a better option. Previously, I was paying an arm
and a leg for $90 worth of droplets a month to cope with my remote-compile
applications. Plus, I don't pay for electricity at my current apartment. It's
included in my rent, so I'm really paying for the electricity whether or not I
use it (within limits).

------
me551ah
Alternative.

Get a cheap openvz box from lowendbox which will cost you between 3-15$ a
year.

[https://lowendbox.com/tag/yearly/](https://lowendbox.com/tag/yearly/)

~~~
mudeth
I think OpenVZ is obsolete at this point. It still uses the 2.6 kernel and you
cannot upgrade. Also the architecture makes it easier to oversell.

KVM is a better choice for public-facing sites, even if it's pricier.

------
pvillano
Shameless plug for my 8kb website (if you don't include the 30x larger pdf of
my resume).

S3 hosting + Cloudflare SSL free tiers

[https://saej.in/](https://saej.in/)

------
rcarmo
My personal web site spent years on slow cable/DSL, and I used Coral CDN at
the time to deal with peak traffic. Today I have 1Gbps/200Mbps fiber and keep
it running off a tiny free VPS with Cloudflare, and sometimes wonder if I need
the VPS at all.

(One of the reasons I moved it off my LAN was security - not providing an
ingress point, etc.)

~~~
rathel
It's not reassuring that the domain nyud.net CoralCDN is using has expired.

~~~
weinzierl
From what I remember it was always just a research project...

------
superkuh
> your website may occasionally miss potential traffic during "high-traffic"
> periods.

The thing with personal home websites is that there's really no actual problem
if the site gets overloaded, or if it goes down for a day or a week or is only
up intermittently at all.

These requirements of constant availability and massive scaling aren't
universal requirements. It's okay if a wave of massive attention is more than
your upstream can support. If people are interested they'll come back. If they
don't it's fine too.

------
cjdell
Another way would be to upload your site to your local IPFS node. Your files
will be automatically cached by other IPFS nodes as people discover your site
providing free load balancing and redundancy.

Your site will still be viewable even after you turn your local node off until
all traffic goes to zero and the caches eventually expire.

[https://docs.ipfs.io/guides/examples/websites/](https://docs.ipfs.io/guides/examples/websites/)

~~~
ajayyy
I think web torrent would work better in this context

------
nickdothutton
After making a rare popular post (32K hits in a few hours) I moved my static
site (a gohugo.io effort) to AWS Lightsail. For less than a fistful of dollars
per month it’s someone else’s problem. I keep page size down (it’s text heavy)
and so far I haven’t needed any CDN.

If I’m having trouble viewing a page on someone’s hammered server I either
look in Google’s cache or use links/elinks to grab the text (usually what I’m
interested in).

------
hakube
Host your website on Netlify and Cloudflare so you don't have to worry about
bandwidth, power/network interruption

~~~
Lammy
"Join a silo" is exactly the last thing somebody interested in selfhosting for
selfhosting's sake is going to want to do =p

~~~
gruez
The article literally says to use a CDN.

------
PeterStuer
I do wonder how all this compares in overall costs and performance to just
serving the static website from S3 or B2?

[https://www.grahn.io/posts/2020-02-08-s3-vs-b2-static-web-
ho...](https://www.grahn.io/posts/2020-02-08-s3-vs-b2-static-web-hosting/)

------
bullen
I dither all my images on the front page:
[http://sprout.rupy.se](http://sprout.rupy.se)

The platform is open-source:
[https://github.com/tinspin/sprout](https://github.com/tinspin/sprout)

~~~
mkl
Dithering doesn't compress very well, so JPEG can do far better quality for
the same file size, e.g.
[https://i.imgur.com/FXQWF23.jpg](https://i.imgur.com/FXQWF23.jpg) instead of
your
[http://sprout.rupy.se/file/3/0/0/annaleefisher-200.gif](http://sprout.rupy.se/file/3/0/0/annaleefisher-200.gif)

BTW, your drag and drop triggers on right click, so weird things happen when
using the right click menu.

~~~
bullen
Sure but then you need to pre-compress the file, using CPU to zip files on the
fly like most servers do is bad.

I only add compression on a need basis manually. CPU is the most scarce
resource.

~~~
mkl
You need CPU to dither and compress to GIF too, and for me with Imagemagick
that takes three times as long as compressing the JPEG version.

~~~
bullen
Dithering is done once (not every request) so not a problem, I will add "once"
gzip compression to images at some point but only when the load on my blog
increases to the point of breaking bandwidth. I suspect CPU will falter first
so no point worrying really!

~~~
mkl
I don't understand, so maybe we're talking past each other. JPEG compression
is only done once as well.

Also, gzipping a GIF is actually likely to make it bigger!

~~~
bullen
Ok, I thought you meant HTTP compression, but yeah it makes it bigger! jpeg is
not interesting to begin with because of artifacts. The dithering is a style,
all-in-all my choice had very little to do with actual size savings... it's
also simpler = can be displayed on monochrome displays, the code to make it
and render it is simpler. etc. etc. Sure in pure bandwidth savings you'll win
every day of the week, but in style? Life without art is meaningless for
humans. Dithering is minimalism of expression!

------
rakoo
To go along the self-hosting crowd, the whole decentralized web with
alternatives to HTTP is solving issues like uptime and low upstream bandwidth
by distributing distribution itself, the way bittorrent does. Dat (via beaker
browser) and zeronet come to mind.

Contrapoint: content must be static

------
joenathanone
My ISP (Cox) doesn't allow inbound traffic on port 80. Anyone know any tricks
of getting around that? I'm currently using a reverse proxy on a friends
server to tunnel through an alternative port, but I'm looking for a better
solution.

~~~
kop316
If you're doing it to an alternative port, why are you reverse proxying in the
first place?

Another option is to reverse proxy to a cloud provider that can provide a
static IP.

~~~
joenathanone
The reverse proxy is a work around so I can use port 80, I have my web address
point to my friends server which reverse proxies to my home server, masking
the alternative port to the user.

------
xrisk
doesn’t putting CF in front of your home web server mostly solve this problem?
CF will cache static assets for you and take all the pain of a traffic surge
away.

also prevents leaking your home IP address.

------
ronyfadel
Or just use Netlify for static websites. It’s free. One of my blog posts got
50k views in 24 hours and Netlify didn’t bat an eye.

~~~
sneak
Netlify has strict limits in their TOS on what you are allowed to host there.
There’s lots of legal content that you might want to publish that you aren’t
allowed to put on Netlify.

Additionally, their uploader CLI is spyware, and their corporate stance on
this is that you agreed to their uploader tool spying on you when you created
your Netlify account.

They also can’t pull from private git hosting, only the big public ones (which
are themselves ethically questionable), which makes using Netlify for builds a
bit of an issue if you, for example, self host Gitea or GitLab.

I use a PaaS (sort of a self-hosted Heroku) called CapRover that pulls/builds
from a self-hosted Gitea on branch change. It’s a relatively small change to
drop a two-stage Dockerfile into an jekyll/hugo repo that does the build in
step one then copies only the resulting static files into a totally off the
shelf/vanilla nginx container in stage 2 for runtime hosting.

For my main website, I still have cloudflare in front of that.

~~~
ronyfadel
For readers of this comment and myself: \- why is the uploader spyware? \-
what kind of legal content is not permitted?

What you’re doing is exactly the sort of thing I don’t want to worry about

~~~
sneak
It silently uploads your usage data without consent, which includes your IP
and thus coarse location data as well as any vendor relationships you use it
within (eg hosting or CI).

It even sent a “telemetry disabled” telemetry event when/after you explicitly
indicated you didn’t want telemetry sent, until I repeatedly complained (they
brushed it off initially):
[https://github.com/netlify/cli/issues/739](https://github.com/netlify/cli/issues/739)

I just don’t believe that the company has any meaningful training or
priorities around privacy.

As for the types of content you can’t post, I encourage you to peruse their
TOS:

[https://www.netlify.com/tos/](https://www.netlify.com/tos/)

An excerpt of some of their prohibitions:

> _Content with the sole purpose of causing harm or inciting hate, or content
> that could be reasonably considered as slanderous or libelous._

I personally would like to be able to post political cartoons or other
political content expressing and inciting hate toward, for example, violent or
inhuman ideologies, and those would be posted for the express purpose of
causing harm and damage to the political campaigns they target.

Netlify should not be policing legal, political speech on their platform.

You also aren’t allowed to host files over 10MB(!) so that rules out hosting
your own music, podcasts, high res photography, most types of software
downloads, or videos on your website, all pretty normal/standard things to
host on a website in 2020.

------
sT370ma2
I am enjoying reading everyone's comments. There is a lot here for me to think
about. Thank you!

------
fouric
> The SSL handshake alone can take as long as a third of a second.

Is this true? If so, then it's a good reason for me not to enable SSL/TLS on
my sites that don't need it (e.g. read-only documents or blog posts).

~~~
forty
All websites need SSL, even if the content is not sensitive. Someone could
inject something like "I'm raising money for a charity, send money >>HERE<<,
thanks!" and people that goes on your non sensitive website could get tricked.
That's just a simple example, but a more competent attacker would also use
your unencrypted traffic to inject malicious code that target some browser
vulnerability, or make the visitor download a malware, ...

------
ciprian_craciun
The article features some very good advice, regardless of how you actually
host the site, that should be followed by many other sites around the web...

It basically boils down to the old KISS principle "keep-it-stupid-simple".

~~~
redis_mlc
> the old KISS principle "keep-it-stupid-simple"

Actually, that's wrong in an important way.

KISS is "keep it simple, stupid", with the emphasis on the last word,
referring to you.

~~~
ryanmjacobs
I prefer "Keep It Simple, Silly"

------
fareesh
For the kind of site described here, there are plenty of CDNs which will just
treat it as a rounding error in terms of their running costs, if at all it
costs anything, and give it to you for free

------
agustif
lowtech magazine [1] is an amazing example at sustainablity serving a website,
they use solar powered only infra and the website is only available
theoretically, if there's been enough sun to power the servers that day (In
Barcelona, at least we've sun much of the year)

[1] [https://www.lowtechmagazine.com](https://www.lowtechmagazine.com)

------
j0057
I feel a lot of people are missing the point of self-hosting here. Do we
really want to run everything under the sun in three big cloud providers?

------
TedDoesntTalk
This reads like a list from the 90s and first decade of the 21st century to
optimize page load times. It’s nearly identical.

------
aloukissas
Or, you know, use netlify or vercel and get all of that out of the box without
thinking about it :)

~~~
justusthane
Sure, that’s an option. But being able to do it yourself is also cool,
especially if it’s a hobby. That’s what hacking is about.

------
throwaway55554
What are some good ways to isolate that server from the rest of your LAN?

~~~
timbit42
Routers.

------
delduca
I use cloudflare argo tunnel for this.

------
jonplackett
The pink background on this site really screwed with my eyes. It was like my
brain was constantly trying to white balance correct it.

~~~
BenjiWiebe
I know, after I read a couple articles on it, and switched back to my HN app's
white background, the white looked very cyan for a while.

------
fortran77
Use the CloudFlare free tier, too!

------
gjs278
I ran garyshood.com off of a pentium 3 dell poweredge and a comcast connection
in its peak (2009-2012). I couldn't offer an upload speed of more than
20-40kb/s without slowing down the house. but with traffic shaping rules and
following most of what he's outlined here, it was easy. it wasn't even
cpubound, it was just network bound, but I could still handle 100-300k unique
visits a month. I did have to host the downloadable exe for the autoclicker on
a third party for $3 a month, even at 120kb that thing would use too much
house bandwidth.

