๐Ÿ’ป mbrizic

< back
techserverslife
๐Ÿ“… 2023-11-02 ๐Ÿ•’ 5 minutes to read

Solar-Hosting This Blog From a $20 PC

This website can now be hosted from my clothesline, using this contraption:

Images showing a portable solar panel with a small PC packed inside of it

This is a $20 single-board computer working as a portable, completely wireless, zero downtime, battery-backup solar-powered server. If you're seeing green links on this website, it means you've been served by it! If not, try reloading a few times and you should see it, provided it didn't go down due to high load.

Let's see what's inside:

Image showing what's inside of the solar panel, containing a Orange Pi Zero and a power bank

The heart of this setup is Orange Pi Zero, a single-board computer that I bought five years ago, that has spent most of that time unused in a drawer, like most of such devices do. It's not much, but it can handle 30 req/s just fine, at least on a size-aware website like this one. My initial DigitalOcean VPS where this was hosted could support up to 60 req/s, so considering the price, this is not half bad.

As the Pi is located in my home where I don't have a static IP address, it's exposed through noip.me. It's like a dynamic DNS where you define a domain, like mbrizic.hopto.org and then your server updates it every day with its actual IP address. The setup is pretty simple and it works with no fuss.

As I don't trust it enough yet, I'm still keeping my original, "legacy" VPS as a kind of backup in case the Pi goes down. So actually I set up a load balancer there that redirects either to the green or blue version of the site, preferring the green one. All those extra hops mean it's not as fast as the old one was, but that's the compromise I was willing to take.

Next on, there's this portable solar charger to power it. It's declared as 10W, which is not much but is 20x of the miniscule 0.5W that the Orange Pi actually needs. This results in the panel being able to power it just fine even in indirect sunlight, even now in November.

But the sun is not always shining, so there's a backup battery as well. It's a 20000 mAh 74 Wh power bank, which is not much as power banks go, but it's still overpowered for this use case. The math tells us it can keep the Pi running for around 150 hours, so almost a full week without the sun.

So basically, the solar charger fills up the power bank which powers up the Pi. So far, it's had a 100% uptime and should continue to do so, barring any hardware or software failures, or the death of the sun.

Interestingly, the equipment to power it costs way more than the device itself - the charger was $40, power bank $30. Although realistically it could work with a lot less.

The Pi is connected to the access point wirelessly. It's not ideal ping-wise, but it's another compromise favoring portability over performance.

Why?

Really it was just a fun idea I wanted to try. But there were two themes to notice here: tinkerability and sustainability.

Regarding the first one, there's this oft-repeated meme that says: "There's no cloud - it's just someone else's computer". Everyone knows it's the case, but how many of us have ever deployed something on a bare metal server? I would guess that percentage is in the low single digits. I know I never did it in my ~10 years in software. Deployment has always been this magical thing that happens somewhere somehow when you merge the code. This project helped me white-box that process and affirm that ultimately, it's computers all the way down.

The other theme here is sustainability. This is not well known, but The Internet's energy usage is bigger than we think. Roughly 4% of the world's carbon footprint comes from it. It might not sound that big, but it's as much as the entire air travel sector. The internet is not as green as we think it is.

With the very approximate numbers from very different sources on the internet, the maths goes like this. Streaming a 90-minute 4k video transfers 20 GB over the wire. Each gigabyte sent requires around 60 Wh of energy, which results in 30 grams of CO2 per gigabyte. This means watching a single movie emits 0.6 kg of CO2 in the atmosphere.

For comparison, buying a printed book emits around 7.5 kg of CO2. Even though buying something made from chopped trees sounds like an ecologically worse option, it's equivalent to streaming just 12.5 hours of 4k video. Which is also equivalent to driving a gasoline car for 50 kilometers.

But we don't really have the perspective that those things can even be compared with The Internet, because we think The Internet is made of aether and magic fairy dust. In reality, it's a Lovecraftian monster of blinking computers, routers, and UPS-es, an Exodia stowed away in pieces across the world in huge warehouses, all terraformed in humidity and temperature to make a climate fit for The Monster. You couldn't even perceive The Internet in its true form; you would instantly lose your mind.

So for a change, it's nice to have something that doesn't ask for much. Something that you can touch with physical hands instead of with a terminal, that sits on your desk working quietly and drawing only milliwatts. And I think this could work even for bigger projects than this blog.

Current state and the next one

Even though it can work like that, I'm currently not using this setup as outlined in the opening paragraphs. Sorry for the clickbait!

I moved it back inside because it didn't make much sense to keep the battery out in the sun. So I scrapped the solar charger and the battery and I'm just powering it from the grid. But since I have solar on my roof anyway, this is still Certified Greenโ„ข.

I also connected it to a router with an Ethernet cable to get the maximum performance from our regular home internet connection. Plugged the Pi to be powered from the router's USB port and now it looks like this:

Image showing Orange Pi server connected to a router

It's contrary to the popular advice to "treat the servers as cattle instead of pets", but I think it's really nice to have something physical that you can hit with a hammer when it stops working. But for now, I am pleasantly surprised at how well a simple setup like this one is working. It's also running Pi-hole on a local network with no issues, with average CPU usage around 1%.

I'm secretly hoping this post blows up, so I can see if the Pi will, too.