Save Money by Scheduling your Servers

Mother and Son sleeping with Robot

Ever since homes starting to have more than one computer similarly home servers are becoming common. The most common server in homes nowadays are the in-prominent WiFi router — the central distributor of Internet connectivity. File servers are also becoming common — typically inexpensive Network-Attached Storage (NAS) or “Personal Cloud” devices — for centralizing backups and functions as the home’s media center storage. Some of these home NAS even feature an HDMI output port for playing movies directly from its hard drive platters.

Continuously running a home NAS may not be the best thing to do. Unlike a refrigerator, a NAS does not need to “keep its content fresh” and be powered on 24×7. It needs to be running only when someone needs to use it — just like a television or air conditioner.  Moreover, turning it off would provide cost savings in terms of electricity costs and extends the life of the device itself. That is, unless people in your home live in vastly different time zones and at every hour there would always be someone who is home, awake, and need to use the file server.

A typical two-drive home NAS would cost about $44 annually in electricity charges when kept constantly running. Well, at least mine does. This figure was calculated from our home’s WD MyCloud EX2 — a low-power ARM-based file server with two 4TB WD Red drives. WD rates the device at 23.3 watts when fully operational. Where I live, the power company charges 21.39 cents per kilowatt-hours. Of course, your own figures would be differ – but you could use the following Calca formula to calculate your own power consumption estimates.

power consumption = 23.3 W
annual consumption = power consumption * 24 h * 365.25 / (1000 W/kW) => 204.2478 h*kW
electricity tariff = 0.2139 SGD / (kW*h)
annual cost = annual consumption * electricity tariff => 43.6886 SGD

The more important consideration would be the longevity or the hard drives themselves. Notably the hassle that you’ll get when a drive fails and the associated risk to your data. Hard drives typically lasts about three years when run continuously. According to Backblaze, their drives’ failure rates starts to increase starting at age three and they expect that half will die at age six. If your NAS configuration is not running in a fail-safe configuration (such as RAID 1 or RAID 5), having a failed drive would spell disaster to your data. Even those redundant configurations would also be vulnerable during a recovery — when a drive just failed and the enclosure is currently rebuilding the array, you can’t afford to have a second failure

Note that the vulnerable period is by no means a short amount of time. It’s from the time you notice that a drive failed, ordered a new one, installing it to the enclosure, until the time that it finished rebuilding — this could take a week in total for a home NAS. From personal experience, it took almost two days for a rebuild to finish and the unit becoming fully operational — copying about 3TB of data to a newly-installed drive in our WD MyCloud EX2.

In any case, having some down-time would be good for those notably mechanical drives since it gives them a chance to cool down. This allows the metals to return to its relaxed state and prevents permanent warping. Especially important in tropical areas where these drives typically operates at 60℃ because room temperatures are typically 27℃ – 34℃.

Good network drives for the home would have a power scheduler. You can set it up such that whenever everyone is asleep then your drives would be asleep as well – saving power and prolonging its lifespan.  Another likely candidate for downtimes are the times when everyone are at work or school. The better NAS firmware would have a day-of-week option in its scheduler so you can use different weekday and weekend downtime schedules.

For example, here’s how you set a schedule for WD’s range of semi-pro network drives:

  1. Log in to the NAS’ web-based administrative interface.
  2. Open the Settings tab.
  3. Look in the Energy Saver section
  4. Click on Configure.
  5. Select the Power Schedule option
  6. Setup the power on and power off times to match your household’s schedule.
WD MyCloud EX2 Power Schedule

You might be thinking, “What if on an odd day – in the middle of the night – I needed to use the drive?” Then Wake-on-LAN is your answer. Wake-on-LAN is a standard network protocol to bring devices out of standby. In short it works by broadcasting the identity of the device to activate on the local area network and the network adapter of the device would pick it up and bring the rest of the unit into full power mode. 

There are specialized network management tools to use Wake-on-LAN. But you can also use the following Python script. Simply modify the ethernet address (also called MAC address – which stands for Media Access Control and not a line of computers made by Apple) in the script to match your NAS and the broadcast address to match your home network and you’re ready to go. Install the script in your location of choice and you’ll have a command line tool to wake your network drive.

#!/usr/bin/env python
# coding: utf-8
import socket

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

s.sendto('\xff'*6 +
	# Replace the following hex octets with the target device's MAC address
	'\xAB\xCD\xEF\x01\x02\x03' * 16,
	# Replace the following IP address with your network's broadcast address
	('192.168.1.255', 9))

On Unix-like systems (which includes macOS), save this as a file named wakeup-mydrive in the /usr/local/bin folder and change the permission to be executable using as follows. Use the Terminal app on macOS to access the command line. If you are using other operating systems, please make adjustments appropriately to your environment.

chmod +x /usr/local/bin/wakeup-mydrive

You can get a device’s ethernet address easily using the ARP command. Plug in your device’s IP address in the following command to get its corresponding MAC address.

$ arp 192.168.1.2
? (arp 192.168.1.2) at 40:30:4:67:44:9 on en0 ifscope [ethernet]

Those series of six numbers separated by colons comprises the MAC address of the device having the IP address on the left.

Whereas to get the broadcast address you will need to calculate it from your home network’s IP address range and subnet mask. Log in to your home router’s administrative interface and look for these two values, usually under the “DHCP Configuration” or “LAN TCP/IP Setup” heading.

  • The router’s IP Address. Usually this would be something like 192.168.1.1
  • IP Subnet Mask. This often looks like 255.255.255.0
Then you’ll need to calculate the broadcast address unique to your network. Simply convert the router’s IP address into its binary representation, perform a bitwise NOT operation, and then combine it with the subnet mask using a bitwise OR.
broadcast address = IP address | ~(subnet mask)

Finally an easy way getting the IP address of the drive is to use the ping command. Replace the command below with your drive’s hostname and then you can get its corresponding IP address.

$ ping -c 4 mydrive.local
PING mydrive.local (192.168.1.2): 56 data bytes
64 bytes from 192.168.1.2: icmp_seq=0 ttl=64 time=0.884 ms
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.949 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=1.527 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=1.029 ms

--- mydrive.local ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.884/1.097/1.527/0.253 ms

Wow – that’s a lot of steps!

We hear you. That’s why we’re working on a Wake-on-LAN application to make it easier to wakeup your NAS or other devices in your network. We’re starting with the Apple TV since this covers the main use case of “wanting to watch videos at night” and running a command line tool isn’t much of an option from the TV. Stay tuned for support on other platforms.

If you’re interested, sign up on the early adopter list in the form below. As these beta user slots are limited, we can’t guarantee a place for everyone. Sign up quickly and don’t get left behind.

Get Early Access

* indicates required

That’s all for now. Until next time. 

Tags: , , , , , ,