Tuning CoreOS Container Linux power management

CPU governor

By default, Container Linux uses the "performance" CPU governor meaning that the CPU operates at the maximum frequency regardless of load. This is reasonable for a system that is under constant load or cannot tolerate increased latency. On the other hand, if the system is idle much of the time and latency is not a concern, power savings may be desired.

Several governors are available:

Governor Description
performance Default. Operate at the maximum frequency
ondemand Dynamically scale frequency at 75% cpu load
conservative Dynamically scale frequency at 95% cpu load
powersave Operate at the minimum frequency
userspace Controlled by a userspace application via the scaling_setspeed file

The "conservative" governor can be used instead using the following shell commands:

modprobe cpufreq_conservative
echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor > /dev/null

This can be configured with a Container Linux Config as well:

This is the human-readable config file. This should not be immediately passed to Container Linux. Learn more.
# This config is meant to be consumed by the config transpiler, which will
# generate the corresponding Ignition config. Do not pass this config directly
# to instances of Container Linux.

systemd:
  units:
    - name: cpu-governor.service
      enable: true
      contents: |
        [Unit]
        Description=Enable CPU power saving

        [Service]
        Type=oneshot
        RemainAfterExit=yes
        ExecStart=/usr/sbin/modprobe cpufreq_conservative
        ExecStart=/usr/bin/sh -c '/usr/bin/echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor'

        [Install]
        WantedBy=multi-user.target
This is the raw machine configuration, which is not intended for editing. Learn more. Validate the config here.
{
  "ignition": {
    "config": {},
    "timeouts": {},
    "version": "2.1.0"
  },
  "networkd": {},
  "passwd": {},
  "storage": {},
  "systemd": {
    "units": [
      {
        "contents": "[Unit]\nDescription=Enable CPU power saving\n\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStart=/usr/sbin/modprobe cpufreq_conservative\nExecStart=/usr/bin/sh -c '/usr/bin/echo \"conservative\" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor'\n\n[Install]\nWantedBy=multi-user.target",
        "enable": true,
        "name": "cpu-governor.service"
      }
    ]
  }
}

More information on further tuning each governor is available in the Kernel Documentation