Title: Considerations for server hardware
Date: 2019-7-10
Tags: hardware, sbc, power consumption
url: choosing-a-homebrew-server.html
save_as: choosing-a-homebrew-server.html
Summary: What makes a suitable homebrew server and where to get it?
Category: fundamentals
slug: 002

[TOC]

## Introduction

You want to get started with self-hosting. This means you will need a computer that will be your server. But what makes a good server?

First, while dedicated server equipment does exist, in the case of the homebrew server it is more helpful to think of a 'server' as a function rather than as a special machine.

![]({attach}images/nas_drawing.svg)

Why? Because dedicated servers are expensive, loud, specialized and power hungry devices. At the same time any spare computer with a network port running GNU/Linux can *become* a server.

It really depends what exactly you plan to do with it, but the odds are that 10 year old laptop you have lying around is more than up to the task of hosting light personal websites, a chat server, mail and more!

## Considerations for servers

One of the main strategies of the homebrewserver.club is re-use. You re-use your existing internet connection at home and likewise you can also re-use old equipment you have as a server.

In general there are a few things you want to take in consideration when determining what hardware to use.

### Power usage

All computers use power, but some use more than others. The function of the server is to be on-line and on the network 24/7 ([although that is not always necessary](https://solar.lowtechmagazine.com/2018/09/how-to-build-a-lowtech-website.html)). That means power usage is an important consideration, not only because it will cost you money but also because it will have an environmental impact.

![]({attach}images/dontturnoffthisisaserv.svg){: class="img-right"}

You can get an approximation of power usage of a machine by looking at the power rating on the power supply or AC adapter. This value is usually expressed in Watt (or W). That number represents the theoretical *maximum* draw of that system, it might use less but not more. The laptop this article is written on is rated 65W but average consumption is about 10W

So how to calculate what that costs for a year of usage? First let's assume that this value is indeed the Watt per hour (Wh). Multiply that number by 24 to get the usage in a day.

`10 Wh * 24 hours = 240Wh or 0.24KWh`

Having the KWh figure will let you use that value to compare against your utilities bill.

Multiply it by the number of days in a year to get a sense of the costs on a yearly basis.

`240 Wh * 365 days = 87600 Wh or 87.6 KWh`

The price for electricity where I am is €0,24 per KWh so on a yearly basis that is €21 euros. On a monthly basis that is €1,75.

#### Considering power consumption at extreme ends.

A PC tower made for gaming that needs a 300 Watt supply can use up to 2,628 KWh of electricity a year, which would cost up to €630. That is only a little less than the average inhabitant of this planet uses *in total during a year*[^1]. At the same time a Single Board Computer ([like this one](https://solar.lowtechmagazine.com/2018/09/how-to-build-a-lowtech-website.html) uses a maximum of 1.3 Watt (without peripherals). That comes down to 11.3 KWh or €3,20 on a yearly basis. Now these are both rough measures and power usage will likely be lower. However, this calculation does indicate that the choice of hardware and resulting power consumption do matter.

#### Energy consumption vs embodied energy.

While older equipment will use more power for the same (or less) performance as newer equipment this should not be your only consideration, especially when running on renewable power sources. In fact, the overwhelmingly largest part of energy usage of digital technology comes from [manufacture and not usage](https://solar.lowtechmagazine.com/2009/06/embodied-energy-of-digital-technology.html). Environmentally, it can make more sense to reuse an older, less energy efficient, device rather than investing in a newer energy efficient device.

## Benefits and disadvantages of laptops as servers

Laptops make good homebrew servers since they are widely available, relatively powerful and energy efficient. Aside from that they have the benefit of having a screen, keyboard and battery. 

If you are just starting out with running a server and are not yet so comfortable with the [command line and ssh]({filename}ssh.md) it can be a real benefit as you can work on the machine directly. Aside from that the laptop battery can mitigate sudden power outages, so that the laptop can shut itself down gracefully if power runs out.

Laptops will also have the ability to hold one or more hard disks and plenty of USB ports for connecting multiple peripherals. 

It is not unlikely that you have one lying around or will be able to find one in a thrift store or on the second hand market.

Disadvantages can be size, sound, heat generation and power consumption (in particular if you don't tune the power management to turn off the screen).

## Single Board Computers

Arguably the ideal homebrew server hardware is the Single Board Computer (SBC). These are often very small computers on a single chip. They are aimed at hobbyists and meant for prototyping. Popular brands are [RaspberryPi](https://www.raspberrypi.org/), [BeagleBone](https://beagleboard.org/bone), [Hardkernel](https://www.hardkernel.com/) and [Olimex](https://www.olimex.com/). 

![]({attach}images/homebrewserver.svg)

They typically use the same ARM processors as used in smart phones meaning they are extremely energy efficient, using only a few Watts of energy under full load. Most models don't use active cooling so they make no sound, which is a boon in domestic environments. They can also be very cheap, ranging from €10 to €50.

The disadvantages are that, compared to a laptop, they are relatively 'incomplete'. You will need at the very least get an SD card and 5V charger to use them. They don't have a battery meaning that a power outage will shut it off without warning, possibly corrupting the SD-card. In terms of performance they usually have less RAM available than a laptop. Their bus bandwidth to read/write disks they can also be lacking.

Having said that there are some boards which are really well optimized for homebrew server usage, such as the Olimex boards. These have SATA ports (for connecting HDDs), are able to use Li-Po batteries, Gigabit Ethernet ports and decent amounts of RAM. You will also find many SBCs on the second hand market.

In general there are quite some Free Software distributions optimized for single board computers such as [Armbian](https://armbian.com).

## Virtual Private Server

Sometimes it is not possible to take the 'home' in homebrewserver.club literally because of your Internet Service Provider. 

A possible alternative is then to consider a Virtual Private Server (VPS). These are servers, that for all practical purposes (including root access) are usable in the same way as a physical server. These VPSes are usually located in datacenters and offered by hosting companies. They are software only, hence virtual, and usually multiple VPSs share a single physical machine.

They can be found for as little as €3 a month. 

![]({attach}images/tserver.svg){: class="img-right"}

The great advantage of a VPS is that you won't have port restrictions, traffic shaping and generally a fast uplink. Aside from that, a VPS means no hardware maintenance and it's not your personal IP-address.

The downsides are that you are essentially renting, storage space tends to be relatively expensive, you might not always have full control over the kernel and OS. For the paranoid it might mean that since your entire system is running in a physical machine's RAM, it is possible to retrieve your sensitive data without you knowing.


## Costs of the homebrew server

One of the things that might hold one back are the costs involved in the whole undertaking.

As an example one can take my personal setup which I have been running since 2014. At the time I paid around €75 for a new Olimex Micro (2ghz, 2 cores, 1GB ram) including peripherals, such as a high performance SD card and power supply. Later I spent another €80 for a 2TB HDD. In terms of energy usage the upper bound is at 10Wh meaning €21 yearly.

So in total `€75 + €80 + €105 (€21x 5 years) = €260`. Per year this means €52 or about €4,30 a month maximum. So while the upfront cost can be substantial, the cost over time is really manageable. Especially if you share it with a bunch of friends!

If you can reuse old equipment the costs would be only for electricity, since you've already been paying for your ISP connection and reuse hardware.

As for a VPS, if one compares the processing power of lower-tier VPS providers one can get 1 core 2Ghz and 2GB RAM for about €3. This is equivalent to low-end SBCs but if one starts to add storage to the VPS, the price quickly ramps up.



[^1]: See per capita electricity consumption for the world population: <https://en.wikipedia.org/wiki/List_of_countries_by_electricity_consumption>
