How I slimmed Web-facing servers in my office from 670W to less than 20W...
In 2007 I decided to replace a whole set of ancient Internet servers (~700W) with one energy-efficient laptop (~30W) to save electricity and maintenance effort. The system was intended to be efficient enough to power purely from solar PV for most of the year, though just avoiding wasted energy is the main driver.
(Note that as of October 2009 this laptop was redeployed elsewhere having been replaced with a ~4W Linux 'embedded' SheevaPlug.)
A typical modern long-battery-life laptop can operate comfortably on 30W or so, up to maybe twice that on heavy load with all the bells and whistles blasting! My aim here is to have a machine that I can tune even further, possibly 20W or less absolute minimum base load to support all services, getting the applications to be able to run on less juice when on battery power (eg when the sun isn't actually out and the batteries are not fully charged, when running on solar PV).
The always-on server applications that I need to run 24x7 include:
(I may also want to use the laptop as a WiFi access point, so that I can stop using my existing stand-alone LinkSys unit which eats ~12W. I can still use the 'wireless kill' switch on the laptop to save the 1W-or-so that this will probably add to the laptop's consumption when I know that I don't need WiFi at all. At of 2008/08/15 the laptop's ipw3945 wireless Linux driver does not support 'master' mode and thus cannot be an Access Point.)
All my applications would run on almost any modern laptop operating system, eg Mac OS X, Linux, Solaris, Windows XP, though I don't trust Windows from a security or stability point of view after long experience, and all my existing servers are Linux or Solaris, ie a UNIX variant, and they can run for months without intervention from me. UNIX also has the ability to plug in power-management software reasonably easily, though in practice Linux probably has the biggest tech-savvy power-wise laptop user base!
Linux comes with some tools such as laptop-mode these days, and on a moderately-efficient laptop with the screen off and disc activity minimised (or some FLASH/NVRAM cache) to allow spin-down, 25W or less base load from 12V DC seems entirely attainable. An SMTP mail server fending off 10s of thousands of SPAMs per day, and HTTP Web servers handling lots of requests, will both at least likely need their logging minimised or batched for example.
There exist reasonably efficient and cheap 12V DC automotive/car laptop power adaptors that I can use to power the laptop from my 12V DC solar PV system when I have adequate power available.
Update 2007/06/21: I have ordered a Linux laptop equipped with 8GB of SD memory card (and 2GB of RAM) to minimise the need to go to power-hungry disc. I can at least start saving energy now, even if I don't yet switch to solar...
Here are some of the techniques that I may use to try to minimise power consumption:
echo 1 > /proc/sys/vm/swappinessor add to
vm.swappiness = 1for the next boot.
I also need to ensure that the system shuts down safely when battery does run out to avoid losing or corrupting data.
Given a target/base power consumption of ~25W (ie about 2A@12V), this implies a sizing of a solar PV supply roughly as follows:
I'm seriously considering a very small wind-turbine as a top-up in winter, as the 4:1 summer:winter insolation ratio otherwise makes for a horribly expensive or less-useful summer-only system.
Update 2007/06/28: I have sketched a circuit that could allow the laptop to run on 12V solar power whenever it is available, and falls back to mains power otherwise. This allows us to make maximum use of solar power, and draws no power from the mains when on solar. This design assumes that there is a LVD (Low-Voltage Disconnect) controller upstream that will protect the battery when its voltage drops too far, and further that this will not oscillate on and off rapidly when the battery is in a marginal state.
Update 2007/06/29: At the prompting of this FieldLines thread, I've designed an improved circuit to sense the state of the 12V DC supply (ie the battery) and switch back to mains long before the battery is exhausted, leaving me lots of juice for lights and consuming only a few microamps from the 12V supply while the laptop is on mains power. This detector is designed to switch the laptop to mains when the battery voltage drops below 12V, and back to battery when the battery voltage rises above 13V, roughly 0.5V above the thresholds in my SHS-6 solar controller, thus leaving the extra juice for lighting (etc). This should also make for much shallower cycling of the battery. (12V from the battery while discharging represents ~50% discharge, and discharging much further than this regularly risks permanent battery damage. The battery voltage should only exceed 13V when on charge and above about 50%; it should never normally exceed this while resting even with no load, so simply disconnecting the laptop should not see the voltage exceed this and thus 13V+ upper threshold should prevent oscillation. It might be wise to move the upper setpoint higher to (say) 13.5V to 14V, which is only likely to achieved when the battery is charging and almost full, ie in a very healthy state.)
Update 2007/07/02: Simplified design with just two relays, and adjusted battery thresholds of 12V to disconnect from the battery and 13.8V before reconnect (which should mean that the battery is being charged and is nearly fully charged). (See the XCircuit .ps file.)
Update 2007/07/04: Having now been able to observe the resting/unloaded voltage of my 12V SLA accurately with my E-flite power meter I think that I going to have to bring the upper threshold (to reconnect the laptop to the batteries) under 13V or we may never get reconnection. I'll simply have to see how stable that proves, or if it is prone to oscillation as the laptop load is removed from the 12V supply. The laptop LVD should be higher than that of my lighting, to ensure that we don't get any unnecessary lights-out without warning.
Update 2007/07/08: 'Gutsy' tickless kernel, laptop-mode and cpufreqd running: power consumption from mains ~27W.
Update 2007/07/09: NTPD (without local radio clock) and mirror of Gallery (Java Web app) running. Power still ~27W from mains.
Update 2007/07/09: k8055 USB board and executable now working, so I can have my battery-state sensor inputs.
Update 2007/07/11: Tested Vanson SDR-120W to power the laptop from the 12V battery, which works fine and uses about 21W which is about 5W less than the mains adaptor draws to power the same workload. Unfortunately, even with no load, the Vanson trips the overload/short detector on the SHS-6, and so cannot be driven by it as things stand. I will probably have to build my own low-voltage disconnect (LVD) circuit and draw power directly from the battery. I think that I'll have the secondary 'battery OK' threshold set at ~12.5V with a small hysteresis (maybe 0.1V) for the laptop to decide when it can run power-intensive tasks, else even this many not happen each day, even with plentiful sunshine. In any case, it should be significantly above the LVD for the laptop and lighting so as to leave plenty of reserve for overnight and overcast days.
Update 2007/07/20: The old servers have been off since this morning as a kind of a test, though I don't have all services (eg mail) working on the new server yet, The study is about 6°C cooler than before and quiet enough that for the first time I can hear the Linux laptop's fan, so I've been tweaking the cpufreqd settings a little to see if I can keep the fan off all or most of the time to save a little wear and noise and power. (Temperature below about 51°C or 30% of maximum in cpufreqd terms.) When the CPU fan is off and the hard disc spun down there are no moving parts!
Update 2007/07/23: The old servers are now off, permanently I hope except to access files for archiving and a couple of other small jobs. Components to build LVD circuit for laptop DC/DC converter should arrive today.
Update 2007/08/05: The laptop ran for nearly 5 hours from solar power today. Estimated normal power consumption 18W to 20W from 12V via 70W DC-DC Vanson, but the main Java app has had to be pinned to 'low-power' mode for now (until I can set up another battery threshold/input sensor probably, or until I get a bigger battery that will cope with the 'full power' (50W+) power draw better).
Update 2007/08/06: Still getting some oscillation/cycling when the battery voltage/SOC is marginal, so after adding a larger 10µF 'delay' capacitor to the voltage sensor, I today raised the upper 'switch-on' voltage threshold to about 13.45V which should only be reachable if the battery is charging and at ~80% charged. The lower threshold is still at about 12.15V (ie with the battery discharging at an SOC of ~50%+ charged). I'm still getting a bit of cycling, maybe 2 or 3 on/off cycles, but much better.
Update 2007/08/08: Switched on default gzip compression (mod-deflate) in my Apache Web server for text pages such as HTML with all default CPU/memory-friendly settings (8kB buffer, default compression, ie not maximum). Though compressing each page takes a tiny bit of CPU, it may take several times fewer packets to send thus reducing bandwidth, and network wakeups/interrupts which may save a little power too.
Update 2007/08/20: I'm having trouble with cpufreqd half-failing and refusing to come out of "On Demand Low" mode, so I'm working on a hand-crafted Java-based replacement for my purposes. With one CPU clamped down to minimum speed, the other given full range (and using the on-demand governor), and the 'sched_mc_power_savings' flag set to keep one core as idle as possible, power draw from internal batteries seems to be hovering at around 17W, which is excellent. A snapshot of the code is available as a BZIP2ed GNU-tar image.
Update 2007/08/26: Laptop was off-grid with solar PV for ~7.3hrs today!
Update 2008/06/07: Laptop was off-grid with solar PV for over 12hrs today! (Off-grid PV array is now ~120Wp.)
Update 2009/07/06: I've just ordered a SheevaPlug (512MB Flash, 512MB RAM, 1.2GHz ARM CPU, USB and Ethernet, running Linux, in a small 'wallwart' mains-plug package) with a view to getting my entire server down to under 10W, using external plug-in low-power extern HDD/SSD, I/O board and ADSL/WiFi, with the whole lot possibly powered from my off-grid PV system even in winter. (The plug arrived 2009/08/17 after a little prompting from me, and uses ~7W out of the box.) I've made an initial tweek to the the Gallery Web app so that it'll run comfortably within 256MB-ish, down from 1GB minimum, ie less than half of the physical memory. Mainly took all night thinking (and working on another aspect) and then about 10 lines of code... Now if only all applications could halve their resource requirements that easily. Actually I'd like something with a little bit of direct digital discrete I/O so I don't need to use my K8055 board, and either support for more SDHC or direct drive for an external low-power HDD or SSD for my ~160GB of bulk data, or another USB so I could plug both those peripherals in without a USB hub. I think that in principle I could bring one of those (SATA for example) out from the plug, and I don't think the Open RD client gives enough more to be worth the extra space and cost (and probably consumption). I'm hoping that Zero/Shark will give me decent Java performance on the ARM. I've verified which Linux build is most power-efficient due to being 'tickless'.
See more of the SheevaPlug setup.
The laptop used is a Lambda 320N sourced from XePhi with a small screen, 1.73GHz Intel Dual Core CPU, 2GB RAM, 120GB hard drive, DVD-RW and WiFi, and fitted out with a 4G SD memory card in the SD port, from which the machine can boot and run without waking the hard disc often. The aim is to minimise hard disc traffic and keep it spun down to save power.
Adam of XePhi loaded Ubuntu (7.04: "Feisty Fawn") and configured it to boot from the 4GB SD card, and with the SD partitions shadowed on the hard disc so that if the SD card 'wears out' I will be able to easily bring up the system and construct a new bootable SD card with dd one command (plus a fixup for the SD card filesystem UUIDs and boot order in /etc/fstab and /boot/grub/menu.list)... Adam also set up the machine as for a typical secure 'server' with most services shut down and most ports firewalled off. This is the state that I have any new dedicated Linux Web host handed over to me too. Adam gave me superb support by email long after delivery to get things working 'just right' with a new kernel and the power-saving stuff, etc, etc!
(Note that "Feisty Fawn" does not support all the latest power-reduction tweaks, such as tickless kernel, and full cpu frequency management: the next release ("Gutsy Gibbon") contains more and so an upgrade should help reduce consumption, in particular the new 'tickless idle' feature to allow the CPU to sleep longer. I have installed and I am running the newer (Gutsy) kernel.)
A very useful tool is PowerTop from Intel, which helps spot which applications may be wasting CPU cycles and thus power.
A Linux package called laptop-mode can tweak a number of aspects of a machine to reduce its power consumption, the main feature being its ability to spin-down and shut-down hard discs/drives that are idle, and tweaking various parts of Linux to make that happen much more often than it otherwise could.
To install the laptop-mode stuff I will need to do:
apt-get install laptop-mode-tools apt-get install laptop-mode
I edit /etc/laptop-mode/laptop-mode.conf to ensure that:
Adding a line:
/usr/sbin/laptop-mode startto /etc/rc.local to ensure that laptop-mode gets enabled automatically at boot.
Note that since the cpufreq kernel module(s) do not seem to load automatically, I may precede the laptop-mode start with a suitable modprobe or three, such as:
We can check if laptop-mode is active with:
(I tried to use cpufreqd for a while, but it jammed and got 'stuck' needing a manual restart, so I crafted a simple Java-based 'JCPUFreqD' that does what I need, available as a BZIP2ed GNU-tar image.)
Essentially the rules of CPU power management to bear in mind are:
Here were some steps that I took to minimise CPU/system power, but keep performance good when power is available:
for f in /sys/bus/usb/devices/*/power/autosuspend; do if [ -f "$f" ]; then echo 1 > $f; fi; done
When the battery voltage is reasonably high the laptop is taken off-grid: ~20W.
When the battery voltage gets even higher, the laptop does all sorts of extra optional work (such as computations for my AI project): another ~30W.
This means that the system can absorb up to ~50W of excess available power with useful computational work, eg the entire output of an 8-turbine MotorWind.
For stability I have discovered that it is wise to slowly ramp up consumption, eg by raising maximum CPU clock, then slowly adding more load to the CPUs, etc, etc, over a matter of several minutes, and then back off very quickly to a minimal draw (a la TCP slow-start) if any of the sensors suggest that battery voltage is dropping.
If it ever looks like that will not be enough then we can tune the software workload to use 100% CPU since the laptop maximum consumption is ~60W. Note that I can probably also power my new ZyXEL ADSL modem (as of 2008/06) directly from 12V DC if required.
Thus I'm using the Net as a software dump load for my RE system!
Some random notes for the moment until they get better organised...
The machine that serves this site is powered by local off-grid solar and wind renewable energy as far as possible, backed up by on-grid renewables including as of 2008/03 a substantial grid-tie solar PV system, and 100% renewable grid power (mainly wind) from Ecotricity; power draw is ~1W.
Please email corrections, comments and suggestions.
Copyright © Damon Hart-Davis 2007-2017.