Solar-powered home web server lasted 15 months: 95,26% uptime

Solar-powered home web server lasted 15 months: 95,26% uptime
The first solar server prototype with a charge controller. Photo: solar.lowtechmagazine.com

In September 2018, an enthusiast from Low-tech Magazine launched a "low-tech" web server project. The task was to reduce energy consumption so that a single solar panel was enough for a home self-hosted server. This is not easy, because the site must work 24 hours a day. Let's see what happened in the end.

You can join the server solar.lowtechmagazine.com, check the current power consumption and battery level. The site is optimized for the minimum number of requests from the page and the minimum traffic, so it must withstand the traffic jump from Habr. According to the developer's calculations, the energy consumption per unique visitor is 0,021 Wh.

Just before dawn on January 31, 2020, it had 42% battery left. Sunrise in Barcelona at 8:04 local time, after which the current from the solar panel should go.

Solar-powered home web server lasted 15 months: 95,26% uptime

What for?

Ten years ago experts predictedthat the development of the Internet contributes to the "dematerialization" of society, universal digitalization - and, as a result, a decrease in overall energy consumption. They were wrong. In fact, the Internet itself demanded huge amounts of energyand these volumes continue to grow.

IT companies have launched initiatives to switch to alternative power sources, but this is not possible right now. All data centers consume three times more energy than all the solar and wind installations in the world generate. Worse, the production and regular replacement of solar panels and wind turbines also requires energy, therefore, it is simply impossible today to refuse fossil fuels (oil, gas, uranium). But these reserves will not last long, so we will inevitably have to think about how to live on renewable sources. Including operation of computer infrastructure, including web servers.

Low-tech Magazine considers a problem too fast bloat of web pages. Average page size increased from 2010 to 2018 from 0,45 MB to 1,7 MB, and mobile sites from 0,15 MB to 1,6 MB, conservatively.

Increase in traffic volumes ahead of progress in energy efficiency (the energy required to transfer 1 megabyte of information), which causes a constant increase in the energy consumption of the Internet. Heavier and more loaded sites not only increase the load on the network infrastructure, but also shorten the “life cycle” of computers and smartphones, which have to be thrown away more often and new ones made, which also very energy intensive process..

And of course, the increase in load is created by the very way of life: people spend almost all their time on the Internet and rely heavily on various web services. It is already difficult to imagine modern society without a cloud IT infrastructure (social networks, instant messengers, mail, etc.)

Server and website configuration

В this article the hardware configuration and software stack of the web server are described in detail.

single board computer Olimex Olinuxino A20 Lime 2 selected for low power consumption and useful additional features, such as the presence of a power management chip AXP209. It allows you to request statistics on the current voltage and current from the board and from the battery. The microcircuit automatically switches power between the battery and the DC connector, where current flows from the solar panel. Thus, uninterrupted power supply of the server with battery support is possible.

Solar-powered home web server lasted 15 months: 95,26% uptime
Olimex Olinuxino A20 Lime 2

Initially, a lithium-polymer battery with a capacity of 6600 mAh (about 24 Wh) was chosen as the battery, then an 84,4 Wh lead-acid battery was installed.

The operating system boots from the SD card. Although the OS takes up no more than 1 GB and the static website about 30 MB, it didn't make economic sense to buy a card smaller than the Class 10 16 GB.

The server connects to the Net through a 100 Mbit home connection in Barcelona and a standard consumer router. It has a static IP address reserved for it. Almost anyone can set up such a site in their apartment, you need to slightly change the firewall setting to forward ports to the local IP:

Port 80 to 80 for HTTP Port 443 to 443 for HTTPS Port 22 to 22 for SSH

Operating system Armbian Stretch based on Debian distribution and kernel SUNXI, which is designed for single boards with AllWinner chips.

Solar-powered home web server lasted 15 months: 95,26% uptime
A 50-watt solar panel for a web server and a 10-watt panel for living room lighting in the author's apartment

Static site generated by the system Pelican (site generator in Python). Static sites load faster and do not create a load on the CPU, so they are much more efficient than dynamically generated pages in terms of power consumption. See the theme source code. here.

A very important point is image compression, because without this optimization it is almost impossible to make web pages smaller than 1 megabyte. For optimization, it was decided to convert the photos into halftone images. For example, here is a photograph of female telephone operators on the switchboard in the last century, 253 KB.

Solar-powered home web server lasted 15 months: 95,26% uptime

And here is the optimized grayscale image with the size 36,5 KB with three colors (black, white, grey). Due to the optical illusion, it seems to the viewer that the number of colors is more than three.

Solar-powered home web server lasted 15 months: 95,26% uptime

Halftone photographs were chosen not only to optimize the size (a rather dubious decision), but also for aesthetic reasons. This old image processing technique has certain stylistic features, so the site has a unique design in a sense.

623 illustrations on the Low-tech Magazine website after optimization decreased in size from 194,2 MB to 21,3 MB, that is, by 89%.

All old articles were converted to Markdown for ease of writing new articles, as well as for ease of backup via git. All scripts and trackers, as well as logos, were removed from the site. The default font in the client browser is used. As a "logo" - the name of the magazine in capital letters with an arrow to the left: LOW←TECH MAGAZINE. Only 16 bytes instead of a picture.

In case of downtime, the possibility of "offline reading" is organized: texts and pictures are exported to an RSS feed. 100% content caching enabled, including HTML.

Another optimization is to enable the HTTP2 setting in nginx, which slightly reduces traffic and reduces page load times compared to HTTP/1.1. The table compares the results for five different pages.

| | FP | WE | HS | FW | cw | |----------|-------|-------|-------|-------|------ -| | HTTP/1.1 | 1.46s | 1.87s | 1.54s | 1.86s | 1.89s | | http2 | 1.30s | 1.49s | 1.54s | 1.79s | 1.55s | | images | 9 | 21 | 11 | 19 | 23 | | savings | 11% | 21% | 0% | 4% | 18% |

Full nginx configuration:

root@solarserver:/var/log/nginx# cat /etc/nginx/sites-enabled/solar.lowtechmagazine.com

# Expires map
map $sent_http_content_type $expires {
default off;
text/html 7d;
text/css max;
application/javascript max;
~image/ max;
}

server {
listen 80;
server_name solar.lowtechmagazine.com;

location / {
return 301 https://$server_name$request_uri;
}
}

server{
listen 443 ssl http2;
server_name solar.lowtechmagazine.com;

charset UTF-8; #improve page speed by sending the charset with the first response.

location / {
root /var/www/html/;
index index.html;
autoindex off;
}


#Caching (save html pages for 7 days, rest as long as possible, no caching on frontpage)
expires $expires;

location @index {
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-cache, no-store';
etag off;
expires off;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /var/www/;
#}

#Compression

gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;


#Caching (save html page for 7 days, rest as long as possible)
expires $expires;

# Logs
access_log /var/log/nginx/solar.lowtechmagazine.com_ssl.access.log;
error_log /var/log/nginx/solar.lowtechmagazine.com_ssl.error.log;

# SSL Settings:
ssl_certificate /etc/letsencrypt/live/solar.lowtechmagazine.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/solar.lowtechmagazine.com/privkey.pem;

# Improve HTTPS performance with session resumption
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;

# Enable server-side protection against BEAST attacks
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

# Disable SSLv3
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

# Lower the buffer size to increase TTFB
ssl_buffer_size 4k;

# Diffie-Hellman parameter for DHE ciphersuites
# $ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096
ssl_dhparam /etc/ssl/certs/dhparam.pem;

# Enable HSTS (https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security)
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";

# Enable OCSP stapling (http://blog.mozilla.org/security/2013/07/29/ocsp-stapling-in-firefox)
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/letsencrypt/live/solar.lowtechmagazine.com/fullchain.pem;
resolver 87.98.175.85 193.183.98.66 valid=300s;
resolver_timeout 5s;
}

Results of 15 months of work

For the period from December 12, 2018 to November 28, 2019, the server showed uptime 95,26%. This means that the downtime for the year was 399 hours due to bad weather.

But if you do not take into account the last two months, then the uptime was 98,2%, and the downtime was only 152 hours, the developers write. Uptime dropped to 80% in the last two months when power consumption increased due to a software update. The site went down for several hours every night.

According to statistics, for the year (from December 3, 2018 to November 24, 2019), the server's electricity consumption was 9,53 kWh. Significant losses in the photovoltaic system due to voltage conversion and battery discharge have been recorded. The solar controller showed an annual consumption of 18,10 kWh, which means the system efficiency is about 50%.

Solar-powered home web server lasted 15 months: 95,26% uptime
Simplified diagram. It does not show the voltage converter from 12 to 5 volts and the battery ampere-hour meter.

During the study period, 865 unique visitors visited the site. Including all energy losses in the solar installation, the energy consumption per unique visitor was 000 Wh. Thus, one kilowatt-hour of generated solar energy is enough to serve almost 0,021 unique visitors.

During the experiment, solar panels of various sizes were tested. The table shows the calculations for how long it will take to charge batteries of different capacities when using solar panels of different sizes.

Solar-powered home web server lasted 15 months: 95,26% uptime

The average web server power consumption during the first year, including all power losses, was 1,97 watts. The calculation shows that to maintain a website at night on the shortest night of the year (8 hours 50 minutes, June 21) you need 17,40 watt-hours of storage power, and on the longest night (14 hours 49 minutes, December 21) you need 29,19 .XNUMX Wh.

Solar-powered home web server lasted 15 months: 95,26% uptime

Since lead-acid batteries should not be discharged below half capacity, the server requires a 60 Wh battery to survive the longest night with optimal daylight (2x29,19 Wh). For most of the year, the system ran with an 86,4Wh battery and a 50W solar panel, when the aforementioned 95-98% uptime was achieved.

Uptime 100%

For 100% uptime, you need to increase the battery capacity. To make up for one day of very bad weather (no significant electricity generation), 47,28 watt-hours (24 hours × 1,97 watts) of storage is needed.

From December 1, 2019 to January 12, 2020, a 168-watt battery was installed in the system, which has a practical storage capacity of 84 watt-hours. This storage is enough to keep the site running for two nights and one day. The configuration was tested during the darkest period of the year, but the weather was relatively good - and during the specified period, the uptime was 100%.

But in order to guarantee 100% uptime for several years, you will have to consider the worst case scenario, when bad weather persists for several days. The calculation shows that to keep the site online for four days with low or no power generation, you need a 440 watt-hour lead-acid battery, that is, the size of a car battery.

In practice, in good weather, a 48 Wh lead-acid battery will keep the server running overnight from March to September. A 24 Wh battery will last the server for a maximum of 6 hours, which means it will shut down every night, albeit at different times depending on the month.

By and large, some sites do not need to work at night, when the number of visitors is minimal, according to the guys from Low-tech Magazine. For example, if this is a regional city publication where visitors from other time zones do not enter, but only local residents.

That is, for sites with different traffic and different uptime, batteries of different capacities and solar panels of different sizes are needed.

Solar-powered home web server lasted 15 months: 95,26% uptime

Solar-powered home web server lasted 15 months: 95,26% uptime

The author gives a calculation of how much energy is required for production solar panels themselves (embodied energy) and how much is obtained if we divide this number by the expected service life of 10 years.

Solar-powered home web server lasted 15 months: 95,26% uptime

Thus, it is possible to calculate the analogue of the fossil fuel that is used for the production and operation of the panels. Low-tech Magazine found that in its first year of operation, their system (50 Wh panel, 86,4 Wh battery) "generated" approximately 9 kg of emissions, or the equivalent of burning 3 liters of gasoline: about the same as a car for 50 km of travel.

Solar-powered home web server lasted 15 months: 95,26% uptime

If the server is powered not from solar panels, but from the general power grid, then the emission equivalent seems to be six times lower: 1,54 kg (in the Spanish energy sector, the share of alternative energy and nuclear power plants is high). But this comparison is not entirely correct, the author writes, because it takes into account the embodied energy of solar infrastructure, but does not take into account this indicator for the overall power grid, that is, the costs of its construction and support.

Further improvements

Over the past time, a number of optimizations have been carried out that have reduced server power consumption. For example, at some point, the developer noticed that 6,63 TB out of a total of 11,15 TB of traffic is generated by one incorrect implementation of the RSS feed, which pulls content every few minutes. After fixing this bug, server power consumption (excluding power losses) decreased from 1,14 watts to about 0,95 watts. The gain may seem small, but the difference of 0,19 watts means 4,56 watt-hours per day, which corresponds to more than 2,5 hours of server battery life.

During the first year, the efficiency was only 50%. Losses were observed when charging and discharging the battery (22%), as well as when converting voltage from 12V (solar photovoltaic system) to 5V (USB), where the losses are up to 28%. The developer admits that he has a suboptimal voltage converter (controller without built-in USB), so you can optimize this moment or switch to a 5V solar installation.

To improve energy storage efficiency, lead-acid batteries can be replaced with more expensive lithium-ion batteries, which have lower charge/discharge losses (<10%). Now the designer is considering a compact compressed air energy storage system (CAES), which has a lifespan of decades, which means a smaller carbon footprint for its production.

Solar-powered home web server lasted 15 months: 95,26% uptime
Compact compressed air energy accumulator, source

The installation of an additional wind turbine is being considered (it can be make from wood) and installing a solar tracker to turn the panels towards the sun. The tracker allows you to increase electricity generation by 30%.

Solar-powered home web server lasted 15 months: 95,26% uptime

Another way to increase the efficiency of the system is to scale it. Raise more websites on the server and run more servers. Then the energy consumption per site will decrease.

Solar-powered home web server lasted 15 months: 95,26% uptime
Solar hosting company. Illustration: Diego Marmolejo

If you cover the entire apartment balcony with solar panels and open a solar web hosting company, then the cost per client will be significantly lower than for a single website: economies of scale.

Overall, this experiment demonstrates that, within certain limits, a computer infrastructure can run on renewable energy sources.

Theoretically, such a server could even do without a battery if mirrored in other parts of the world. For example, put mirrors in New Zealand and Chile. There solar panels will work when it is night in Barcelona.

Source: habr.com

Add a comment