19 ms·
How to Serve over 100K Web Pages a Day on a Slower Home Internet Connection
- gjs278 6y agoI 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.
- ronyfadel 6y agoOr 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.
- Tistron 6y agoI'm also using this, and now that I need some dynamic stuff to allow booking me in my calendar, I found that I also get simple access to aws lambdas for free, way enough for little me.
- sneak 6y agoNetlify 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 6y agoFor 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 6y agoIt 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.
- willvarfar 6y agoThis 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 6y ago$20 seems a bit expensive considering there are $5 VMs
- willvarfar 6y agoYes 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....
- cjdell 6y agoAnother 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 6y agoI think web torrent would work better in this context
- sylvain_kerkour 6y agoHi 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!
- ciprian_craciun 6y agoThe 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 6y ago> 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 6y agoI prefer "Keep It Simple, Silly"
- PeterStuer 6y agoI 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-hosting/ https://www.grahn.io/posts/2020-02-08-s3-vs-b2-static-web-ho...
- meerita 6y agoI use Digital Ocean $5 VMs and I never had any problem serving +100k a day on static pages.
- icebraining 6y agoSure, 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 6y ago^ 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 6y agoNow 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 6y agoFair 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).
- znpy 6y ago
- ramraj07 6y agoHow about just putting your static site in S3? What happens when traffic spikes (other than increase in bandwidth)?
- hagy 6y agoExactly. 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?
- majewsky 6y agoI don't want to make my visitors more trackable than absolutely necessary. Sure, my ISP and their ISP will know that they connected to me, but not to which site thanks to TLS. If I host on CloudFront, Amazon knows exactly which pages they viewed at which time because they can see inside the TLS connection.
- jlgaddis 6y ago> ...but not to which site thanks to TLS. Are you sure? > The desired hostname is not encrypted, so an eavesdropper can see which site is being requested. [0] ESNI is meant to fix this but isn't, yet, widely deployed (AFAIK). --- [0]: https://en.wikipedia.org/wiki/Server_Name_Indication https://en.wikipedia.org/wiki/Server_Name_Indication
- haggy 6y agoYes and no. The classic adage of "what if" tends to fly into these conversations prematurely. Let's face facts. Most personal sites won't see a giant boost in traffic unexpectedly. Which means hosting and paying a cloud provider is completely unnecessary. If you happen to become popular enough (the 1%) THEN you start to consider some scaling patterns.
- hakube 6y agoHost your website on Netlify and Cloudflare so you don't have to worry about bandwidth, power/network interruption
- ryanmjacobs 6y agoAs someone who just moved away from the exact Github->Netlify-Cloudflare stack... here's my two cents. Yes, it does make deploys easier. You don't "have to think" anymore. Well, that's the argument. I self-host by creating a git bare repo on a server, ala `git init --bare mysite.com.git` and cloning that repo again for the web server (`git clone mysite.com.git mysite.com`). Now add this git hook in the bare repo: #!/bin/bash cd /home/ryan/mysite.com unset GIT_DIR git restore . git pull exec ./build.sh >/dev/null Now my deploys take a second and become visible immediately. If you are intending on serving 1000s of requests per second, sure you might need CDNs and caching. But... if your hosting a portfolio/blog website, you might not need it. On top of that, demonstrating knowledge of backends is never a bad thing for a personal website.
- oefrha 6y ago1. Your deployment is not atomic. Probably should consider checking out to and building in a different directory, then atomically switch (symlink is an easy way to achieve atomicity). 2. Using a good CDN ensures your site is fairly responsive on (hopefully) all continents. Your server probably isn’t. Your closet server — even less.
- ryanmjacobs 6y agoOh shoot yeah symlinking sounds like a good idea. I should try that out. The thing is, for the amount of visitors I have, both of those points are kinda moot.
- oefrha 6y agoAtomic update is just good engineering practice regardless, and it’s pretty easy to work into your existing flow. As for responsiveness, it’s a good thing to proactively prepare for an HN hug of death ;) It also starts to matter when the traffic crosses into 100k a day, as is the case in TFA.
- ryanmjacobs 6y agoI 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 6y agoThe static ip is free?
- ryanmjacobs 6y agoI've searched far and wide haha; the cheapest I can find them is $3.50/month from Vultr. I'm almost ready to switch to DDNS though. The threat of DDOS scares me a little bit. We have 300 mbps down though, so I don't forsee it being a terrible problem. I guess I would just call my ISP if something sketchy was going on. I'd like to imagine that my content is not DDOS-worthy though :)
- Riverheart 6y agoIs the server doing the hosting isolated from your regular network?
- ryanmjacobs 6y agoYup :) I'm running 5 KVM virtual machines, all behind a KVM NAT interface. They're not necessarily all on one laptop haha, but still on-premise. I can do live migrations between the hardware boxes with KVM without restarting the machines. Pretty cool stuff. Then they connect to a public-facing VPS that shuttles traffic to and from. I've tested out different ratelimiting strategies too. KVM's ratelimitter is surprisingly accurate. Probably gonna stick with a 10 mbps uplink and downlink pipe. Seems consistent and reliable, and still a fraction of my 300 mbps up / 30 mbps down home internet. Doubt my ISP cares about my uploading. Literally if a couple people hop on Zoom, they would be using more internet bandwidth than my servers do.
- me551ah 6y agoAlternative. 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 6y agoI 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.
- rcarmo 6y agoMy 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 6y agoIt's not reassuring that the domain nyud.net CoralCDN is using has expired.
- weinzierl 6y agoFrom what I remember it was always just a research project...
- themaxdavitt 6y agoI was just about to try to grab this and try to contact them to return it, but the WHOIS records say it actually is still registered to them, and it expires in 2023. Phew! Maybe they need to update some DNS records?
- anaxag0ras 6y agoCan you post the link to the tiny free VPS you're using? I was thinking of using Heroku free tier but the 'cold start' latency is too much.
- bufferoverflow 6y agoI'm pretty sure both AWS and Google Cloud have a free tier enough to run basic websites. I've been running mine on Google Cloud. AWS has all kinds of nice freebies too. Like 25GB of DynamoDB with 200M requests/month, and AWS Lambda with 1 million requests/month.
- dillonmckay 6y agoCan you setup a local server in a DMZ?
- bullen 6y agoI 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
- ryanmjacobs 6y agoWow that loads so fast. I should start doing that.
- mkl 6y agoYou really shouldn't. You can get smaller file sizes with better quality using better formats, e.g. JPEG. (See my sibling comment.)
- ryanmjacobs 6y agoMmm gotcha, I'll have to run some tests. I've never considered using dithering before, but the minimalist asthetic looks kinda cool. But you're right that it wouldn't make much sense if JPG is better though..
- NikolaeVarius 6y ago234 requests 555.06 KB / 371.64 KB transferred Finish: 41.65 s DOMContentLoaded: 672 ms load: 1.45 s Still going....
- mkl 6y agoDithering 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.
- awiesenhofer 6y agoTotally agree on size, but i quite prefer the dithered look over the highly visible jpg artifacts
- arcade79 6y agoReading 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.
- DaniloDias 6y agoIt’s pretty bold to say #2 is irrelevant. I don’t have data to point to, but anecdotally I believe I have perceived the performance impact of node pages over static pages. Do you have data to support your claim? He’s clearly running in constrained hardware.
- ldoughty 6y ago7 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)
- FemmeAndroid 6y ago> 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. Huh? Sure, it's not a bandwidth issue, but the article is about more than serving on low-bandwidth. It's about using limited hardware more generally. From the first two sentences: > The cheapest way to run a website is from the home Internet connection that you already have. It's essentially free if you host your website on a very low-power computer like a Raspberry Pi. I guess the headline refers to bandwidth, and there's some bandwidth-specific framing, but the article is discussing more than just low-bandwidth situations.
- xrisk 6y agodoesn’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.
- fareesh 6y agoFor 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
- rakoo 6y agoTo 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
- scalableUnicon 6y agoSomewhat 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-in-7kb/ https://blog.jacklenox.com/2018/06/04/delivering-wordpress-i...
- vwcx 6y agoThanks 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.
- aloukissas 6y agoOr, you know, use netlify or vercel and get all of that out of the box without thinking about it :)
- justusthane 6y agoSure, 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 6y agoWhat are some good ways to isolate that server from the rest of your LAN?
- timbit42 6y agoRouters.
- TedDoesntTalk 6y agoThis reads like a list from the 90s and first decade of the 21st century to optimize page load times. It’s nearly identical.
- sT370ma2 6y agoI am enjoying reading everyone's comments. There is a lot here for me to think about. Thank you!
- Ecco 6y agoItem #9 (use a CDN) is pretty much the exact opposite of the title (serve from home connection)...
- jaimex2 6y agoYup. If you're going to do that just host the entire thing on github pages and call it a day.
- eitland 6y agoNote 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 6y agoSure, you can own your own data but if you're serving a public website does it make any difference?
- astrobe_ 6y ago"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.
- jonplackett 6y agoThe pink background on this site really screwed with my eyes. It was like my brain was constantly trying to white balance correct it.
- BenjiWiebe 6y agoI 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.
- pvillano 6y agoShameless 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/
- fortran77 6y agoUse the CloudFlare free tier, too!
- delduca 6y agoI use cloudflare argo tunnel for this.
- nickdothutton 6y agoAfter 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).
- j0057 6y agoI 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?
- fouric 6y ago> 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 6y agoAll 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, ...
- labcomputer 6y agoWhat's to stop an adversary from modifying the page in-transit to load malicious javascript?
- ex3ndr 6y agoIt could take much longer. Ping between US and EU is ~100-150ms. If TLS is an old one with 3 round trips it is a full second.
- wongarsu 6y agoA single ping to the other side of the earth takes a theoretical minimum of 133ms, and more realistically about 300ms. An SSL handshake has to exchange data twice (thrice?), so even without processing delays at all we easily get a third of a second or longer if you're far enough away. That said, SSL is useful on read-only documents: it provides integrity. Without SSL anyone between your server and the end user can just change the page content, whether that's for misinformation, false-flag-attacks, inserting malware, scanning for censored content (which is known to happen) or for inserting ads (which also happens).
- superkuh 6y ago> 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.
- joenathanone 6y agoMy 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 6y agoIf 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 6y agoThe 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.
- agustif 6y agolowtech 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