---
date: 2023-12-08
title: Optimizing Power Consumption
tags:
  - homelab
  - hardware
  - power efficiency
---     
I mentioned in [an earlier post](https://blog.mcknight.tech/2023/11/29/Homelab-Upgrades/) that one of my concerns with my current setup is the
power consumption of everything in my rack. After writing, I realized that I know what the load is on my UPS, but I don't know how each component
draws on its own or what everything actually costs to run. I also haven't looked into tuning things for power consumption for some time, so lets see 
if there are any savings to be had there. I picked up a couple of inexpensive ZWave switches that have current monitoring and added them to HomeAssistant 
to monitor my Unraid server and pfSense router. I can approximate the network switches' power usage by subtracting those 2 measurements from the UPS'
measured usage.

## Baseline Idle Power Usage
I connected my Unraid server to one of the monitoring outlets yesterday afternoon, so I have some data including minimal usage overnight. I see that
150-170W was used while streaming some media via Plex and then at bed time usage dropped to 140W with overnight load staying between 130-160W. There was
one peak at 165W, presumably when some scheduled tasks run at 4:30AM.

Checking the UEFI, I saw the fans all set to "Full Speed". I updated all of them to "Balanced" profiles and that helped with noise in my office which is
a huge plus, but power usage is mostly unchanged. This is by no means a scientific test but does indicate there is little power efficiency to be gained
by messing with fan curves.

For my pfSense router, things are more consistent with power draw right around 58W with a range of 57-60W. I went into the BIOS and disabled
overclocking and  turned fans to "Eco mode" but saw very little change.

Doing the math, my UPS measures about 250W of usage with about 150W and 60W going to my Unraid server and pfSense router, respectively. This leaves 40W
going to the 2 Ubiquiti switches in the rack.

## Looking for Power Savings
There are a couple places I think I can save energy, so what can I do to validate that before investing more time and money? For the router, I 
know there's not much room to optimize what I have, so I can compare my measured power draw against other hardware options. For the server, I think there
is some more investigation to do:

### Spinning Rust
Looking at my Unraid array, I see that all 7 spinning disks are active. I am able to manually spin down 4 of them (one has activity which also
keeps the 2 parity disks active). This takes power draw from 154W to 134W; that's a full 20W savings! Guessing that Frigate would be the only
service that won't write to my cache pool, I spun that down and then manually spun down everything in the array again. I'm now down to 111W,
until the disks spin back up.

This gives me some ideas about planning my storage solution. First, I'll want to try and get all of the services with regular disk IO using SSD-based
storage. Second, if I can keep file metadata in RAM or SSD storage, that will hopefully prevent the disk from needing to be spun up just to open a network
directory with the added benefit of not having to wait for disks to spin up just to look at directory contents.

### pfSense Router
As mentioned [in my earlier post](https://blog.mcknight.tech/2023/11/29/Homelab-Upgrades/#pfSense-Router-Appliance), a more efficient router was part of 
my initial upgrade plan. Looking at some of the [official Netgate options](https://www.pfsense.org/products/), I should be able to get the job done with
20W for a savings of 40W.

## Conclusion
Adding up my potential savings, I optimistically have about 80W I can save at idle which comes to somewhere around 60kWh/month; that costs me a whole
$6.50/month. That's not even a trip to Starbucks in terms of energy costs. This doesn't match my expectations from reading forum threads about optimizing
every watt for cost savings, but according to [this random study](https://www.statista.com/statistics/263492/electricity-prices-in-selected-countries/),
this may be because energy costs in much of Europe are much higher (I would be looking at up to $32.80/month savings in Italy according to this study).

This changes my perspective about where to spend time and effort in my upgrades; yes I can get a more efficient router, but I'm only going to save about 
$3/month so that's not a good enough reason for me to spend $200. A new router could get me another 1U of available rack space, but I don't think I 
will need that either in the immediate future. For the hard drives, I do still want to keep those spun down as much as possible just for longevity; also, 
the issue of waiting for drives to spin up just to load network shares is a pretty common annoyance for me. 

This was a worthwhile investment of $50 and some time to actually do the math on what I stand to save with more efficient hardware. Another of many lessons
that you shouldn't believe everything you read on the internet and spending the time to at least sanity check your assumptions with concrete data is always
worth it.

