On the Linux operating system, the optional integration between DB2® service classes and Linux classes (control groups) permits you to control the amount of processor resource allocated to each service class. If enabled, all threads running in a DB2 service class are mapped to a Linux class where they are subject to the processor resource controls you define.
To make use of Linux workload management support, you require a Linux kernel version 2.6.26 or later on a 64-bit system and the libcgroup library package.
Linux workload management supports a hierarchy of classes with superclasses and subclasses, with processor shares for subclasses divided in proportion to the shares of the parent class. These shares provide a method of control over processor resource such that all threads in the system will always run, but the amount of processor time each thread receives is dependent on the number of shares assigned to the Linux class.
Processor resource on the Linux operating system is assigned in shares relative to the Linux workload management default class, which by default has a processor share at a value of 1024. If you define no other Linux classes, all threads run in this default class. If you define a class that has a share value equal to 1024, then this class receives the same amount of processor resource as the Linux default class with the default processor share. Similarly, a class with a share of 2048 receives a target processor usage quota twice that of the default class. On more complex systems, you should consider raising the processor share of the Linux default class, which improves the granularity for shares across the system so that you can assign processor resources more accurately.
You should use a 1:1 mapping between DB2 service classes and Linux classes which permits you to adjust the Linux processor shares assigned to activities in each DB2 service class individually according to business priority. It is important that you associate every DB2 service class with a Linux WLM class, either by setting an outbound correlator for each service superclass and subclass, or through inheritance from the parent service class for subclasses. This includes the default SYSDEFAULTSYSTEMCLASS, SYSDEFAULTMAINTENANCECLASS and SYSDEFAULTUSERCLASS service classes.
The following figure shows how two DB2 service subclasses under the same user defined service superclass can get mapped 1:1 to Linux subclasses under a common superclass. In this example, the work identified and assigned by two workloads for each DB2 service subclass is subject to the processor resource controls imposed by the corresponding Linux subclasses (_DB2_SUBCLASSA, _DB2_SUBCLASSB). Also shown are three Linux classes that correspond to the default DB2 workload management service classes (_DB2_DEF_USER, _DB2_DEF_SYSTEM, _DB2_DEF_MAINT). If you integrate DB2 workload management with Linux workload management, you should always create these additional Linux classes to match the default DB2 service classes. To avoid any bottleneck, the Linux class corresponding to the DB2 default system class should receive more processor shares than any other Linux class that DB2 activities map to, whilst the Linux class corresponding to the default maintenance class should receive less processor shares.
The steps for integrating DB2 workload management with Linux workload management, which runs as an operating system service, are as follows:
# Superclass name
group _name
{
perm
{
task
{
uid = db2inst1;
gid = db2iadm1;
}
admin
{
uid = db2inst1;
gid = db2iadm1;
}
}
cpu
{
cpu.shares = 1024;
}
}
For the integration with DB2 workload management to work, you must ensure that the Linux workload management service is properly installed, configured, and active. If the DB2 data server cannot communicate with the Linux workload management service, a message is logged to the db2diag log files and DB2 administrator log. Database activities will continue to execute.
The DB2 data server cannot detect whether the outbound correlator that it passes to external workload managers is recognized by Linux workload management. You must verify that the OUTBOUND CORRELATOR value specified for a DB2 service class matches the Linux class name so that DB2 threads are mapped to the Linux class. If an outbound correlator is not recognized, database activities will continue to execute.
The following example illustrates how you can make use of Linux workload management processor controls by integrating with DB2 workload management. In this example, we create two user-defined DB2 service classes, one for batch applications (BATCHAPPS) and one for online applications (ONLINEAPPS). For simplicity, this example does not show the default service classes, which should be included in an implementation that creates the recommended 1:1 mapping between DB2 service classes and Linux classes. Because response time is critical for the online applications, we want the ONLINEAPPS service class to receive three times the amount of processor shares relative to work that runs in the Linux default class (3 x 1024 = 3072 shares). Batch applications have a lower business priority, and the BATCHAPPS class should be assigned half the processor resource of work that runs in the Linux default class (1024 / 2 = 512 shares). All other work on the system will run in the Linux default class. Note that this example does not create Linux classes corresponding to the three default DB2 workload management service classes.
To create this setup, first create the two corresponding Linux classes _BATCHAPPS and _ONLINEAPPS and set their relative processor shares by editing the /etc/cgconfig.conf tasks file. After editing, the tasks file contains the following two entries, one for each Linux class:
# Superclass ONLINEAPPS
group _ONLINEAPPS
{
perm
{
task
{
uid = db2inst1;
gid = db2iadm1;
}
admin
{
uid = db2inst1;
gid = db2iadm1;
}
}
cpu
{
# 3 x 1024 = 3072 shares
cpu.shares = 3072;
}
}
# Superclass BATCHAPPS
group _BATCHAPPS
{
perm
{
task
{
uid = db2inst1;
gid = db2iadm1;
}
admin
{
uid = db2inst1;
gid = db2iadm1;
}
}
cpu
{
# 1024 / 2 = 512 shares
cpu.shares = 512;
}
}
Linux class | Shares | Absolute processor time in percent |
---|---|---|
Default class | 1024 (default) | 1024 / 4608 = 22% |
_ONLINEAPPS | 1024 x 3 = 3072 | 3072 / 4608 = 67% |
_BATCHAPPS | 1024 x ½ = 512 | 512 / 4608 = 11% |
Total = 1024 + 3072 + 512 = 4608 shares |
Once the Linux WLM classes are created, you can start the Linux workload management service:
service cgconfig start
Next, create the associated DB2 service classes with the following statements:
DB2 CREATE SERVICE CLASS BATCHAPPS OUTBOUND CORRELATOR '_BATCHAPPS'
DB2 CREATE SERVICE CLASS ONLINEAPPS OUTBOUND CORRELATOR '_ONLINEAPPS'
To find out which threads are running in a Linux class, issue the cat command. For the business critical _ONLINEAPPS Linux class, the command and output look as follows. You can see that there are six thread running in this Linux class:
cat /cgroup/_ONLINEAPPS/tasks
1056
1087
1107
985
1036
1205