Enabling and setting CPU shares

Enable and set CPU shares to manage CPU resources, by using shares-based entitlements that are assigned to service classes and databases.

Before you begin

Note: For the CPU shares setting to be effective, you must enable the workload management dispatcher by configuring the wlm_dispatcher database manager configuration parameter. This action can be done either before or after you enable and set the CPU shares. See: Enabling the workload management dispatcher.

About this task

This task uses the command line processor.

Enable the CPU shares attributes by setting the value of the wlm_disp_cpu_shares database manager configuration parameter to YES.

Set the hard or soft CPU shares for services classes attribute by using the CREATE SERVICE CLASS or ALTER SERVICE CLASS statement.

Set the hard or soft CPU shares for databases by using the wlm_cpu_shares and wlm_cpu_share_mode database configuration parameters.

Generally, you set CPU depending on the priority and impact of the work:
  • Set hard CPU shares on service classes and databases that are running low-priority or high-impact work.
  • Set soft CPU shares on high-priority service classes and databases when CPU resources are strained.

If you are using multiple databases, set the CPU shares at the database level, so that your preferred CPU resource distribution happens between databases.


Restrictions

You can assign CPU shares to service classes that the workload management dispatcher can control, which are user and maintenance service classes.

The CPU resource allocations for system service classes cannot be controlled by the workload management dispatcher.

For users of Db2 11.5.5 and earlier, CPU Shares are not supported in an environment where WLM Admission Control is enabled. WLM Admission Control is enabled when the database manager configuration parameter wlm_admission_ctrl is set to YES.

Procedure

Skip to step 2 if the CPU shares attributes are already enabled.

To enable the CPU shares attributes:

  1. Using the command line processor (CLP), issue the UPDATE DATABASE MANAGER CONFIGURATION (or UPDATE DBM CFG) command and set the value of the wlm_disp_cpu_shares database manager configuration parameter to YES. The parameter value is updated immediately by first attaching to your Db2® instance.
    attach to instance-name
    update dbm cfg using wlm_disp_cpu_shares yes
    detach

To set the hard or soft CPU shares attribute at the database level:

  1. Set the wlm_cpu_shares and wlm_cpu_share_mode database configuration parameters. In this example, 5000 soft shares are set for each database:
    connect to database-name
    update db cfg using WLM_CPU_SHARES 5000 
    update db cfg using WLM_CPU_SHARE_MODE SOFT
    terminate

Skip to step 4 if an existing service class hard or soft CPU shares setting is to be altered.

To create a new service class and set the hard or soft CPU shares attribute:

  1. Issue the CREATE SERVICE CLASS statement to create a new service class and set the hard or soft CPU shares value to 5000 in this example:
    • create service class service-class-name hard cpu shares 5000
    • create service class service-class-name soft cpu shares 5000

To alter the hard or soft CPU shares setting for an existing service class:

  1. Issue the ALTER SERVICE CLASS statement to alter the hard or soft CPU shares value to 15000 in this example:
    • alter service class service-class-name hard cpu shares 15000
    • alter service class service-class-name soft cpu shares 15000

Results

The CPU shares attributes are enabled and you have set or altered the hard or soft CPU shares setting for the specified service class. Service classes and databases that assigned hard CPU shares can, under restricted conditions, claim CPU resources that other service classes and databases relinquish due to their lessened workload demand. However, service classes and databases that are assigned soft CPU shares, can always claim CPU resources that other service classes and databases relinquish due to their lessened workload demand.

What to do next

After you enable the workload management dispatcher to manage CPU resources, and enable the CPU shares attributes, and set the hard or soft CPU shares attribute, consider completing the following tasks: