Greening your server – and your data center? – for profit and planet
It is a truth universally – well, almost universally acknowledged – that man-made climate change is pushing the Earth to untenable levels of ecological disquiet, and that therefore it would be entirely excellent if we all cut down our carbon footprint and stopped taking a metaphorical blowtorch to our energy reserves. Some of our technological marvels, like data center and cloud innovations, are especially energy-thirsty.
It is another truth, almost as universally acknowledged, that we live in an age where technology is at its coolest since at least the age of Roman aqueducts and we want as much of it as possible. Squaring those two truths is never easy – but as an experiment that’s just been uploaded to GitHub has just proved, it is possible to set about greening your server, saving you money, saving the planet energy, and posing an absorbing puzzle into the bargain.
It is a third truth, hardly ever as yet acknowledged, that if greening your server works in a domestic setting, there’s technically no reason it shouldn’t work on a large, commercial scale too, which could make it very much worth investigating and potentially investing in, given the colossal energy needs of data centers and server farms.
The experiment was written up by Maximillian Golla, who realized his permanently-on home server, used for things like Plex (remotely) and Time Machine backups (locally), was using 43 watts in idle mode. In Germany, as of October, 2022, when he began thinking about it, domestic electricity costs were at 49 euro cent/kWh. For comparison, they currently average 0.16 US Dollars per kWh for households and 0.12 US Dollars for businesses across the US.
The problem Golla set out to solve was this: whether there was a way to automatically suspend the server as and when it wasn’t being used, but to prevent it from actually sleeping if either of the two main functions for which he was using it were active. In addition, he specified the condition that he should be able to wake up the server remotely in case he needed to use Plex while he was away from home.
That three-stage problem would be analogous to lots of business case uses in data centers, and could help minimize the power drain they represent, without substantially lowering their usefulness.
For reference, Golla’s particular experiment was conducted with these parameters and specifications: Intel i5-11400; ASRock B560 Pro4; Crucial DDR4 2x 8GB; 5x disks (1x M.2 NVMe SSD, 3x 5400 RPM, 1x 7200 RPM). He also installed PowerTOP2 and tuned some settings, including enabling audio codec and SATA link power management, to allow him to lower the figure for idle power consumption.
Golla also had a Raspberry Pi 4 Model B 4GB running all the time, mostly used to run Home Assistant (HASS) and Pi-Hole.
The experiment’s parameters.
Thinking initially that there would be lots of commercial solutions available to meet his power-lowering, money-saving, server-greening needs, Golla was fairly shocked to discover they simply didn’t exist.
That left him with two main requirements:
- A script that would suspend the server automatically when it wasn’t in use, and
- A (mobile-friendly) website that would allow him to wake up the server whenever he needed it (in this case, to use Plex remotely).
On a fundamental level, the idea had legs, as Macs in his local network accessed the server via SMB to run backups of Time Machine, while Golla used HTTPS access to use his Plex. Marrying the two connecting technologies was part of the issue, as he needed a way to wake the server remotely via smartphone.
The fact that his Raspberry Pi was running constantly and hosting Home Assistant – which already offered a Wake on LAN and Device Tracker integration – offered hope that the problem might be soluble.
After significant trial and error, and some coding which we’re in no sense going to share without permission – feel free to investigate his blog, or find the project on GitHub – Golla came up with the idea of the server implementing a ring buffer, checking for activities once per minute.
The first solution.
To monitor Plex activities, he accessed a local Plex API, and for the Time Machine element, he monitored any file access at /mnt using lsof (list open files). Whenever there was no activity for 15 consecutive minutes, the server went to sleep.
For the purposes of the experiment, “no activity” translates as nobody streaming anything, a video pause didn’t count as “activity,” and no backup was running.
A web server on the Raspberry Pi hosted a website that found the current state of the server, as provided by the Home Assistant REST API.
That means the server could be woken remotely as needed with one button-press, sending a magic packet that used a wakeonlan Perl script.
There’s always going to be an issue of when the server should sleep, and when it would be better for it not to do so. Golla’s blog goes into detail on how to determine those factors, and how to monitor backups.
And he acknowledges that this wakeonlan idea is just one way of getting around the problem he identified, and that there may be many others, with perhaps greater elegance and utility – that’s why he’s posted the project to GitHub, to allow the open source community at large to pick apart the idea and find better ways to do the same thing.
His fundamental question still stands, though. Why aren’t there already lots of commercial ways to do this? At 0.12 US Dollars per kWh, it’s worth remembering that most data centers average an energy spend of around 1000 kWh per square meter.
While your data center mileage may – and in fact, undeniably will – vary, the likes of Microsoft’s data center in Iowa utilizes 1.2 million square feet. That adds up to around $144 million of electricity costs and change – not to mention the green impact of delivering that amount of energy through traditional fossil fuels (assuming that’s how the power is generated). Multiply that across the whole data center sector, and if nothing else, the scale of the potential for cost savings becomes entirely visible.
Golla’s results saved him around 60 Euros of energy over the course of 49 days – something in the region of 120 kWh worth on his tiny domestic scale. There are also of course issues of scaling to the data center world, given the nature of the activities his servers were involved with. But the experiment seems to provide at least the first steps toward a way of drastically cutting both the economic and the ecological impact of one of our favorite 21st century technologies, the data center.
Where the research goes in the future can only be exciting to watch.
20 March 2023