Subscribe to the feed

by Wander Boessenkool (Red Hat)

Tuning systems can be a time consuming art. Not only does it involve extensive profiling of your systems, as well as continuous monitoring, but keeping tuning setting applied continuously can be quite a chore as well. Especially if the tuning needs of your systems change throughout the day.

Imagine a database system that is used to process orders from customers. In this specific system orders come in in bulk between 08:00 and 18:00, but the other 14 hours in a day and during the weekends the machine is mostly idling. We could tune this system for power efficiency, so as not to waste to much energy during the 118 hours a week it is doing almost nothing, or we could tune it for peak performance during the 50 hours a week the system is heavily utilized.

With a traditional setup switching between those two extremes would be either very cumbersome, with an administrator having to make those changes by hand, or it would require extensive scripting and testing to automate.

Introducing Tuned, the Automatic Tuning Daemon

With the release of Red Hat Enterprise Linux 6 a third solution has become available: tuned. tuned is a system service that lets you select a tuning profile from one of the nine profiles shipped with Red Hat Enterprise Linux 6, or any that you've written yourself. Tuning profiles include sysctl settings (/proc/sys/), settings for disk-elevators, power management options, transparent hugepages, and any scripts that you might want to add yourself.

Switching between profiles with tuned only takes one command, and as such this makes it a prime candidate for inclusion in cron jobs. In the example above we could configure a cron job to switch to a maximum performance profile on weekdays at 08:00, and then back to maximum power savings on weekdays at 18:00.

Installing and configuring Tuned

To start using tuned we will first need to install the packages for it:

[root@server ~]# yum install tuned

After the packages are installed we can query the status of the tuning daemons using the tuned-adm active command:

[root@server ~]# tuned-adm active
Current active profile: off
Service tuned: disabled, stopped
Service ktune: disabled, stopped

As we can see in the output above we haven't yet selected a tuning profile, and both the daemons (tuned and ktune) are stopped, and not configured to start at system boot.

To view a list of available tuning profiles you can use the tuned-adm list command:

[root@server ~]# tuned-adm list
Available profiles:
- desktop-powersave
- enterprise-storage
- server-powersave
- default
- throughput-performance
- laptop-battery-powersave
- spindown-disk
- latency-performance
- laptop-ac-powersave
Current active profile: off

Let's say that we are interested in the throughput-performance profile. Selecting a profile can be done with the tuned-adm profile command:

[root@server ~]# tuned-adm profile throughput-performance

Running the command tuned-adm active now gives us some new output:

[root@server ~]# tuned-adm active
Current active profile: throughput-performance
Service tuned: enabled, running
Service ktune: enabled, running

Not only did the tuned-adm profile command set our profile choice, it also started the daemons for us and enabled the daemons to start at boot.

If at any time you want to completely disable the tuning daemon you can do so by running the command tuned-adm off:

[root@server ~]# tuned-adm off

This will not only revert all your settings to what they were before tuned started, it will also disable the tuning services from running at boot.

With this information in mind the example in our introduction can be implemented by creating a new file in /etc/cron.d, let's call it /etc/cron.d/tuning

0 8 * * 1-5 /usr/bin/tuned-adm profile throughput-performance
0 18 * * 1-5 /usr/bin/tuned-adm profile server-powersave

With these cron jobs in place our server will switch to a maximum throughput profile every weekday at 08:00, and back to a power saving profile weekdays at 18:00.

Creating Tuning Profiles

If you want to go beyond the nine profiles shipped with tuned you can create your own. All tuning profiles get their own sub-directory under /etc/tune-profiles, and creating a new one is as easy a copying an existing one. For example let's say that we want to base a new profile of the the existing server-powersave profile:

[root@server ~]# cd /etc/tune-profiles
[root@server tune-profiles]# cp -av server-powersave my-powersave

Inside your new directory you should now find four files:

  • tuned.conf: In this file you can enable/disable the three main tuned plugins (disk, network, and CPU). When enabled these plugins will monitor your system and switch to power saving mode for their respective subsystems whenever that subsystem has a low load.
  • ktune.sysconfig: In this file you can enable/disable the use of ktune and set a disk elevator to be used for your hard drives. Disk elevators are the queuing algorithms used fo re-ordering and merging requests send to a disk.
  • sysctl.ktune: In here you can change sysctl settings. Bear in mind that when a profile is activated the settings from /etc/sysctl.conf will also be applied after this file has been parsed.
  • ktune.sh: In this script you should have two functions: start() {} and stop() {}. The start function will be called when the profile is activated (also on boot), and the stop function will be called when we de-activate this profile. ktune.sh should always source the file /etc/tune-profiles/functions, which provides you with a lot of utility functions for power management, disk tuning, enabling and disabling transparent hugepages, etc. One of the most important functions in this file is process, which is usually called like process ${@} at the end of your ktune.sh script. The process function has all the default logic in it for handling starting, stopping, and restarting your profile.


About the author

UI_Icon-Red_Hat-Close-A-Black-RGB

Browse by channel

automation icon

Automation

The latest on IT automation for tech, teams, and environments

AI icon

Artificial intelligence

Updates on the platforms that free customers to run AI workloads anywhere

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon

Security

The latest on how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the platforms that simplify operations at the edge

Infrastructure icon

Infrastructure

The latest on the world’s leading enterprise Linux platform

application development icon

Applications

Inside our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech