Show Table of Contents

Chapter 4. Control Group Application Examples
This chapter provides application examples that take advantage of the cgroup functionality.
4.1. Prioritizing Database I/O
Running each instance of a database server inside its own dedicated virtual guest allows you to allocate resources per database based on their priority. Consider the following example: a system is running two database servers inside two KVM guests. One of the databases is a high priority database and the other one a low priority database. When both database servers are run simultaneously, the I/O throughput is decreased to accommodate requests from both databases equally; Figure 4.1, “I/O throughput without resource allocation” indicates this scenario — once the low priority database is started (around time 45), I/O throughput is the same for both database servers.

Figure 4.1. I/O throughput without resource allocation
To prioritize the high priority database server, it can be assigned to a cgroup with a high number of reserved I/O operations, whereas the low priority database server can be assigned to a cgroup with a low number of reserved I/O operations. To achieve this, follow the steps in Procedure 4.1, “I/O Throughput Prioritization”, all of which are performed on the host system.
Procedure 4.1. I/O Throughput Prioritization
- Make sure resource accounting is on for both services:
~]#
systemctlset-propertydb1.serviceBlockIOAccounting=true~]#systemctlset-propertydb2.serviceBlockIOAccounting=true - Set a ratio of 10:1 for the high and low priority services. Processes running in those service units will use only the resources made available to them
~]#
systemctlset-propertydb1.serviceBlockIOWeight=1000~]#systemctlset-propertydb2.serviceBlockIOWeight=100
Figure 4.2, “I/O throughput with resource allocation” illustrates the outcome of limiting the low priority database and prioritizing the high priority database. As soon as the database servers are moved to their appropriate cgroups (around time 75), I/O throughput is divided between both servers with the ratio of 10:1.

Figure 4.2. I/O throughput with resource allocation
Alternatively, block device I/O throttling can be used for the low priority database to limit its number of read and write operations. For more information, see the description of the
blkio controller in Controller-Specific Kernel Documentation.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.