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: