Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

2.5. tuned and ktune

tuned is a daemon that monitors the use of system components and dynamically tunes system settings based on that monitoring information. Dynamic tuning accounts for the way that various system components are used differently throughout the uptime for any given system. For example, the hard drive is used heavily during startup and login, but is barely used later when a user might mainly work with applications like OpenOffice or email clients. Similarly, the CPU and network devices are used differently at different times. tuned monitors the activity of these components and reacts to changes in their use.
As a practical example, consider a typical office workstation. Most of the time, the Ethernet network interface will be very inactive. Only a few emails will go in and out every once in a while or some web pages might be loaded. For those kinds of loads, the network interface does not have to run at full speed all the time, as it does by default. tuned has a monitoring and tuning plugin for network devices that can detect that low activity and then automatically lower the speed of that interface, typically resulting in lower power usage. If activity on the interface increases drastically for a longer period of time, for example because a DVD image is being downloaded or an email with a large attachment is opened, tuned detects this and sets the interface speed to maximum to offer the best performance while the activity level is so high. This principle is used for the other plugins for CPU and hard disks as well.
Network devices are not configured to behave this way by default because speed changes can take several seconds to take effect and therefore directly and visibly impact the user experience. Similar considerations apply for the CPU and hard drive tuning plugins. When a hard drive has been spun down, it can take several seconds for it to spin up again which results in an observed lack of responsiveness of the system during that period. The latency side effect is smallest for the CPU plugin, but it is still at least measurable, though hardly noticeable by a user.
Alongside of tuned, Red Hat Enterprise Linux 6 also offers ktune. ktune was introduced in Red Hat Enterprise Linux 5.3 as a framework and service to optimize the performance of a machine for a specific use cases. Since then, ktune has improved to such a degree that we now use it as the static part of our general tuning framework. It is mainly used in the different predefined profiles described in Section 2.5.2, “Tuned-adm”.
Install the tuned package and its associated systemtap scripts with the command:
yum install tuned
Installing the tuned package also sets up a sample configuration file at /etc/tuned.conf and activates the default profile.
Start tuned by running:
service tuned start
To start tuned every time the machine boots, run:
chkconfig tuned on
tuned itself has additional options that you can use when you run it manually. The available options are:
-d, --daemon
start tuned as a daemon instead of in the foreground.
-c, --conffile
use a configuration file with the specified name and path, for example, --conffile=/etc/tuned2.conf. The default is /etc/tuned.conf.
-D, --debug
use the highest level of logging.

2.5.1. The tuned.conf file

The tuned.conf file contains configuration settings for tuned. By default, it is located at /etc/tuned.conf, but you can specify a different name and location by starting tuned with the --conffile option.
The config file must always contain a [main] section that defines the general parameters for tuned. The file then contains a section for each plugin.
The [main] section contains the following options:
interval
the interval at which tuned should monitor and tune the system, in seconds. The default value is 10.
verbose
specifies whether output should be verbose. The default value is False.
logging
specifies the minimum priority of messages to be logged. In descending order, allowable values are: critical, error, warning, info, and debug. The default value is info.
logging_disable
specifies the maximum priority of messages to be logged; any messages with this priority or lower will not be logged. In descending order, allowable values are: critical, error, warning, info, and debug. The value notset disables this option.
Each plugin has its own section, specified with the name of the plugin in square brackets; for example: [CPUTuning]. Each plugin can have its own options, but the following apply to all plugins:
enabled
specifies whether the plugin is enabled or not. The default value is True.
verbose
specifies whether output should be verbose. If not set for this plugin, the value is inherited from [main].
logging
specifies the minimum priority of messages to be logged. If not set for this plugin, the value is inherited from [main].

Example 2.3. A sample tuned.conf file

[main]
interval=10
pidfile=/var/run/tuned.pid
logging=info
logging_disable=notset

# Disk monitoring section

[DiskMonitor]
enabled=True
logging=debug

# Disk tuning section

[DiskTuning]
enabled=True
hdparm=False
alpm=False
logging=debug

# Net monitoring section

[NetMonitor]
enabled=True
logging=debug

# Net tuning section

[NetTuning]
enabled=True
logging=debug

# CPU monitoring section

[CPUMonitor]
# Enabled or disable the plugin. Default is True. Any other value
# disables it.
enabled=True

# CPU tuning section

[CPUTuning]
# Enabled or disable the plugin. Default is True. Any other value
# disables it.
enabled=True