Академический Документы
Профессиональный Документы
Культура Документы
. . . . . . . .
This paper is useful for aDBA and a DB architect. It explains how best we
can do workload management in a consolidated Oracle environment. Discuss
about database resource manager, instance caging feature of Oracle with
benchmark test results.
Operating system schedulers are responsible for managing all the processes
running on a server. A server with four CPU cores can only execute four
processes at a time. The rest of the processes are ready for execution but
will be waiting on the server run queue. The workload on the server includes
all the processes on the CPU and on the run queue. Any process that is on
the CPU has to have its corresponding memory in the physical memory of
the server. In case of the server not having enough physical memory to load
the process memory then the OS will use swap space. Operating systems
usually use a proprietary scheduling algorithm to manage the processes.
Such sophisticated scheduling algorithms are important for the computer
systems to provide the applications with the desired throughput and re-
sponse time. Every operating system has its own operating system sched-
uler. Some of the most important implementations are Solaris resource
manager, Solaris Fair Share Scheduler, Completely Fair scheduler from
Linux.
It is also worth noting, that Oracle has made several architectural changes
to its Database Server model by allowing up to 250 User databases to run
within a single System Database or Container
Note In general, Oracle does not recommend using Operating system Workload Managers in conjunc-
tion with the Oracle Database Resource Manager. For more information, please refer to
http://docs.oracle.com/cd/B28359_01/server.111/b28310/dbrm010.htm#i1010600
Element Description
Resource Consumer A set of sessions that are grouped together according to thei
Groups resource requirements. The resource manager allocates re
sources to consumer groups and not to individual sessions
The individual sessions are mapped to a consumer group us
ing the following session attributes - Service, module, action
oracle username, OS username, and program name.
Resource Plan Di- Resource plan directives are a set of resource limits for a par
rectives ticular consumer group. The resource plan and resource plan
directives are in a parent-child relationship. A set of direc
tives can target only one consumer group at a time.
Resource Plan Resource plan includes all the directives for different con
sumer groups. Only one resource plan can be active at
time.
The DBA now creates a simple resource plan with plan directives restricting
CPU utilization for a particular consumer group. The DBA groups the data-
base users into two resource consumer groups namely OLTP and DSS. The
resource plan OLTP_DSS_DAYTIME_PLAN will have three resource plan di-
rectives one each for OLTP, DSS, and OTHER_GROUPS consumer groups
with a limit on CPU utilization.
With lot of known issues and bugs in Oracle 9i, DBRM was further enhanced
with following new features in Oracle 10g.
With the release of 11g, DBRM was further enhanced with the following fea-
tures.
Server processing power is increasing day by day and most of the time serv-
ers are under-utilized or over-sized. Also managing multiple servers in-
creases administration cost. Hence, the IT Industry in general, and Data
Center management groups in particular, are looking for server consolidation
options. There are various options available in the market e.g. Hard Parti-
tions, O/S workload managers, Virtualization, Resource Managers and DB
(Oracle) Server Consolidation using Instance Caging.
Last but not the least, Oracle provides a resource manager and instance
caging feature which can prove very beneficial in Database Consolidated en-
vironments i.e. environments where multiple databases are consolidated
into a few servers with high processing power.
Both these features can be combined and used very effectively to guarantee
SLAs in a DB consolidated environment, as this paper explores and aims to
show
Partitioning approach
In this approach, CPUs are assigned to databases and sum of assigned
CPUs are equal to or less than total CPUs in the server. This approach
can be considered for mission critical databases. Hence, one database
performance issue doesnt effects another database and provides pre-
dictable performance. Let us consider one server contains 4 CPUs and
4 databases are running in it and each CPU is allocated to each data-
base. So, each database consumes maximum one CPU (25% of the to-
tal CPUs) when other databases are idle.
The main advantage of instance caging is that it does not require any new
software to be installed or licensed.
The v$rsrcmgrmetric_history view shows CPU consumed time and CPU wait
time for each minute in past one hour for each consumer group.
Excessive overhead When many server processes are running, context switching occurs
between oracle server processes, as well as, between Oracle and non-
Oracle processes
Insufficient schedule When a database server holds latches, the OS de-
schedules those database server processes
Equal resource allocation The OS allocates equal resources to all active processes. Due to this,
the database server is not able to prioritize tasks based on a
database priority
Inability to manage database Parallel execution and active sessions are not managed by the OS.
specific resources
To avoid the above problems, Oracle Resource Management and the Instance Caging features
can be employed.
The goal of designing a Resource plan is to achieve a balance between the available resources,
the known priority of tasks & processes and imposing limits on resource metrics which control
the amount of resources available to a database as a whole, and also govern how these available
resources are, in turn, distributed to the contending processes
With the help of a resource plan, CPU resources are allocated properly
based on known workloads. With this, one can achieve SLAs even if the
The above are the pre-dominant considerations taken into account when de-
signing resource management plans within the Oracle database.
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_SIMPLE_PLAN(SIMPLE_PLAN => 'sam-
ple_plan',
CONSUMER_GROUP1 => 'group1', GROUP1_CPU => 60,
CONSUMER_GROUP2 => 'group2', GROUP2_CPU => 40);
END;
To create complex plans, you have to follow a three-step process which con-
sists of creating, validating and then submitting a pending (work) area
EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA;
EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA;
Once you verify plan, you can then submit the pending area.
EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA;
You can clear an existing pending area using the below procedure.
EXEC DBMS_RESOURCE_MANAGER.CLEAR_PENDING_AREA;
You must call the CREATE_PENDING_AREA procedure before you can make
any change in plan.
You can setup the consumer group such that it will be allowed to switch its
consumer group immediately using SWITCH_CONSUMMER_GROUP_FOR_SESS
procedure from lower resource group to higher resource group and
vice versa.
You can switch all sessions of specific user using below procedure. Below ex-
ample move all CRM users to high group.
EXEC DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_USER
('CRM','high_group');
You can create mixed workload plan using resource plan. Below plan is
summarized in the following table:
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
DBMS_RESOURCE_MANAGER.CREATE_PLAN(
PLAN => 'SIBLE_PLAN',
COMMENT => 'Resource plan for SIBLE Application'
);
DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(
CONSUMER_GROUP => 'OLTP',
DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(
CONSUMER_GROUP => 'OLAP',
COMMENT => 'Resource consumer group for SIBLE Night jobs'
);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
PLAN => 'sible_plan',
GROUP_OR_SUBPLAN => 'OLTP',
COMMENT => 'OLTP jobs',
CPU_P1 => 60,
SWITCH_GROUP => 'OLAP',
SWITCH_ESTIMATE => TRUE,
UNDO_POOL => 400);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
PLAN => 'sible_plan',
GROUP_OR_SUBPLAN => 'OLAP',
COMMENT => 'OLAP jobs', CPU_P2 => 100,
ACTIVE_SESS_POOL_P1 => 3, QUEUEING_P1 => 300,
MAX_EST_EXEC_TIME => 1200);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
PLAN => 'sible_plan',
GROUP_OR_SUBPLAN => 'OTHER_GROUPS', COMMENT => 'mandatory',
CPU_P3 => 100);
DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
END;
To manage multiple instances on a single server, you can use the Instance
Caging feature. With this feature, you can limit the available CPU at each
Oracle database instance level. This feature does not permit the Oracle da-
tabase instance to use more CPU cores than what it is configured to use.
This is specified in the Database Configuration file
For example, if you want to restrict some database users from running que-
ries using TOAD that are resource intensive then you can place those ses-
sions into a consumer group ADHOC_QUERIES by using the PL/SQL block
below:
After this PL/SQL block is executed whenever database user uses TOAD
software to login to the database, the session is automatically placed into
the ADHOC_QUERIES resource consumer group. Any time the session per-
forms a data pump operation then that session switches into a pre-defined
resource consumer group named ETL_GROUP. The value attribute accepts
wild-card characters similar to the SQL like operator.
As seen in the example above the database sessions and the consumer
groups are linked together using consumer group mapping rules. The ses-
sion and its consumer group can be identified using the data dictionary view
v$session.resource_consumer_group. Once a mapping rule is set up using
the DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING proce-
dure then the session is mapped into a consumer group either during login
or run-time. Oracle database has certain pre-defined mapping rules created
during the install.
For example, a database user named SCOTT logs into the database using
TOAD. This database user is mapped into the ADHOC_QUERIES consumer
group by default. The database user SCOTT knows that it is now off-peak
hours for the online users and can use more resources than what is assigned
to the ADHOC_QUERIES. The user SCOTT can now switch to a different con-
sumer group that the administrator has set up for him named AD-
HOC_QUERIES_OFFPEAK. He can switch into a different consumer group us-
ing the following PL/SQL procedure
DBMS_SESSION.SWITCH_CONSUMER_GROUP. This switch will be successful
provided the administrator has granted the user SCOTT permissions to
switch to this new consumer group.
Begin
DBMS_SESSION.SWITCH_CONSUMER_GROUP_FOR_USER (
user => SCOTT,
consumer_group => ADHOC_QUERIES_OFFPEAK
);
End;
/
This will switch the consumer group for all database sessions connected as
user SCOTT. The database user should have permissions to switch into a
new consumer group. When a session switches into a new consumer group,
the switch does not happen immediately but executes during the next data-
base call. The administrator must have granted the permissions directly or
through a role so the user can switch into the new consumer group.
Begin
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP (
grantee_name => SCOTT,
consumer_group => ADHOC_QUERIES_OFFPEAK,
grant_option => FALSE
If the administrator grants permission to PUBLIC then any user can switch to
that particular consumer group. Any database user can switch to the pre-
defined consumer group OTHER_GROUPS as the grant is issued to PUBLIC.
Scheduler Windows are pre-defined time ranges and they are intricately
linked with Resource Management in Oracle. Resource Plans can be created
to automatically become active when a window slides into the next one. This
allows the Administrator to ensure that workloads which change over a pe-
riod of time have appropriate resource plans defined as the Window
changes.
Scheduler Windows are linked with the Oracle Scheduler functionality and it
is possible to link Resource Plans with Scheduler windows which cause those
plans to be activated when the Window becomes operational.
6.1 CPU
1. Management attributes
2. Maximum utilization limit
In some cases, the lower priority consumer group can use up all the CPU
when there is low load from the higher priority consumer group. In such in-
stances, the maximum utilization attribute is helpful. The maximum utiliza-
tion attribute imposes an absolute upper limit on the CPU utilization for a re-
source consumer group.
When a resource plan is created, there are certain limits put on CPU, mem-
ory, and undo utilization. When such a threshold increases, one of the possi-
ble actions is to automatically switch the session to a different consumer
group with higher thresholds. This is possible to switch this session tempo-
rarily to higher consumer group until the SQL call is completed using this re-
source plan directive.
This resource plan directive can be used to cancel long running SQL state-
ments when resource usage exceeds certain limits.
This resource plan directive specifies the maximum execution time allowed
for an operation. If the database estimates that, a particular operation will
run longer then that operation is terminated with an error message.
This resource plan directive controls the total amount of undo for uncommit-
ted transactions that can be generated by a resource consumer group.
This resource plan directive can specify the amount of time that a session
can be idle, after which it is terminated. This allows the administrator to en-
sure that sessions connected for a long period of time and holding onto re-
sources that are needed by other sessions are terminated after a pre-
configured period of time.
7.0 Objectives
CPU_COUNT
MAX_UTILIZATION_LIMIT Resource Management directive
CPU allocation ratios to consumer groups
First of all, we run two tests to determine the TPM (Transactions per minute)
for the database in NOARCHIVELOG mode and in ARCHIVELOG mode. This
test is being done purely to determine if the rest of the tests can be done in
NOARCHIVELOG mode to ease the testing progress by eliminating the gen-
eration of archive logs in the test environment.
As can be seen below, the maximum TPM that could be achieved in this test
was 15764 TPM
As can be seen below, the maximum TPM that could be achieved in this test
was 15650 TPM
BEGIN
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();
dbms_resource_manager.create_consumer_group(
consumer_group=> 'SOE_GROUP',comment => 'Group for SOE Users');
dbms_resource_manager.submit_pending_area();
BEGIN
dbms_resource_manager_privs.grant_switch_consumer_group(
grantee_name=>'SOE',consumer_group=>'SOE_GROUP',grant_option=>FALSE
);
END;
END;
/
BEGIN
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();
--Create the SOE_PLAN
dbms_resource_manager.create_plan(
plan => 'SOE_PLAN',
comment=>'Planfor SOE_GROUP',
active_sess_pool_mth=>'ACTIVE_SESS_POOL_ABSOLUTE',
parallel_degree_limit_mth=>'PARALLEL_DEGREE_LIMIT_ABSOLUTE');
--Create the Plan Directives for the OTHER_GROUPS under the SOE_Plan
-- We have specified MGMT_P1 as 50 which means that not more than 50% of the CPU can
be
-- used by the sessions which are not part of SOE_GROUP
dbms_resource_manager.create_plan_directive(
plan => 'SOE_PLAN',
group_or_subplan => 'OTHER_GROUPS',
comment => 'Directives for Othergroups',
max_utilization_limit => null,
mgmt_p1 => 50, mgmt_p2 => null, mgmt_p3 => null, mgmt_p4 => null,
mgmt_p5 => null, mgmt_p6 => null, mgmt_p7 => null, mgmt_p8 => null ,
parallel_degree_limit_p1 => null ,
parallel_target_percentage => null ,
parallel_queue_timeout => null ,
switch_io_reqs => null,
switch_io_megabytes => null ,
active_sess_pool_p1 => null,
queueing_p1 => null,
switch_group => null,
switch_time => null,
switch_estimate => FALSE,
undo_pool => null ,
max_idle_time => null,
max_idle_blocker_time => null,
switch_for_call => null
);
--Create the Plan Directives for the SOE_GROUP under the SOE_Plan
-- We have specified MGMT_P1 as 50 which means that not more than 50% of the CPU can
be
-- used by the sessions which are part of SOE_GROUP
dbms_resource_manager.create_plan_directive(
plan => 'SOE_PLAN',
group_or_subplan => 'SOE_GROUP',
comment => 'Directives for SOE Group',
max_utilization_limit => null,
mgmt_p1 => 50, mgmt_p2 => null, mgmt_p3 => null, mgmt_p4 => null,
mgmt_p5 => null, mgmt_p6 => null, mgmt_p7 => null, mgmt_p8 => null ,
parallel_degree_limit_p1 => null ,
parallel_target_percentage => null ,
parallel_queue_timeout => null ,
switch_io_reqs => null,
switch_io_megabytes => null ,
active_sess_pool_p1 => null,
queueing_p1 => null,
dbms_resource_manager.submit_pending_area();
END;
/
It is important to note with the above specification, that when the CPU is
saturated, the Oracle Resource Manager will ensure that not more than 50% of
the CPU is used by either the SOE_GROUP or the OTHER_GROUPs. However, if
spare CPU is available, either of these groups will be allowed to use more
than 50% of the CPU.
BEGIN
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP
(
'SOE', 'SOE_GROUP', true
);
END;
/
execute DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
BEGIN
DBMS_RESOURCE_MANAGER.set_consumer_group_mapping (
attribute => DBMS_RESOURCE_MANAGER.oracle_user,
value => 'SOE',
consumer_group => 'SOE_GROUP');
END;
/
execute DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
Once the above steps are executed, we can view the Consumer group map-
ping from OEM which shows us that the SOE user now belongs to the
SOE_GROUP.
In this test scenario, we are going to limit the maximum CPU that the
SOE_GROUP can use to 50%
BEGIN
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();
dbms_resource_manager.update_plan_directive(
plan => 'SOE_PLAN',
group_or_subplan => 'SOE_GROUP',
new_comment => null,
new_max_utilization_limit => 50
);
dbms_resource_manager.submit_pending_area();
END;
/
This test is run without altering the CPU_COUNT but with resource plan
(SOE_PLAN) enabled with the MAX_UTILIZATION_LIMIT directive specified
to 50% for the SOE_GROUP
As can be seen from the benchmark window below, we were able to achieve
a maximum throughput of 15824 TPM and an average throughput of 13028
TPM
This is our culminating test scenario with 2 databases RMLAB and RMLAB2,
both running on the same server having 16CPU cores and 16GB of memory.
The below script allows us to set the maximum utilization limit to 25% of the
overall CPUs available to this DB. In addition, it allows us to specify that not
more than 50% of the maximum can be utilized by the SOE_GROUP of con-
sumers.
The same steps are run on both the databases thus imposing the same lim-
its on consumer groups connecting to both these databases (RMLAB and
RMLAB2)
BEGIN
dbms_resource_manager.clear_pending_area();
dbms_resource_manager.create_pending_area();
dbms_resource_manager.update_plan_directive(
plan => 'SOE_PLAN',
group_or_subplan => 'SOE_GROUP',
new_comment => null,
new_max_utilization_limit => 25, new_mgmt_p1 => 50
);
dbms_resource_manager.submit_pending_area();
END;
/
This shows the overall picture with respect to number of sessions waiting for
CPU. Also note that we have enabled instance caging by setting the value of
CPU_COUNT but we've chosen to specify the value of this parameter to the
maximum number of CPU cores available on this server. In other words, we
have enabled the instance caging algorithm but chosen to manage the work-
7.5.2 RMLAB The Database view of CPU utilization and waiting sessions
For the RMLAB database, the average CPU used is hovering around 25%
which is the limit we forced. We can also see that the average number of
CPUs waiting for CPU cycles is around 67
7.5.3 RMLAB2 The Database view of CPU utilization and waiting sessions
Even for the RMLAB2 database, the average CPU used is hovering around
25% which is the limit we forced. We can see the average number of waiting
sessions are around 72.
7.5.4 OS CPU Stats OS level view of the run queue and idle CPU
The snapshot below shows the run queue and idle CPU available on the
Server when this benchmark was conducted
The boxed area of the snapshot below shows the Throughput per minute
(TPM) benchmark for this test.
The boxed area of the snapshot below shows the Throughput per minute
(TPM) benchmark for this test.
Now, we stop the RMLAB2 database to observe the effect of resource man-
agement within the surviving RMLAB database
We can see from the below Database view, that the average CPU utilization
is still around 25% but the number of waiting sessions have come down
from 67 to 49. This is due to the fact that the RMLAB2 consumer groups are
no longer competing for CPU on this server.
Once the RMLAB2 is stopped we can see the that the Average waiting ses-
sions has dropped from around 72 to around 48 since more CPU is available
to RMLAB connections.
The OS CPU idle time also, as expected, shows a significant increase in the
idle CPU available.
We can see that that throughput has increased from around 11,000 to
15,000
The various tests done, their settings and observed readings are docu-
mented in the below table.
Note the TPM, OS CPU Idle and Sessions Waiting for CPU columns in the
above benchmark table. As the aim of this exercise is to ensure that we
have an optimal balance between these 3 measurements, we can see the
marked difference between these two sections
The above results show us that in the first scenario, we achieved a higher
TPM but at the cost of completely saturating the OS resources which means
that other concurrent workloads would suffer. In the second scenario, we
achieved a lesser TPM but ensuring that the OS resources are not compro-
mised. Workload Management and Optimization is all about balancing these
3 attributes and the Oracle Database Resource Managers provides Adminis-
trators with the tools to do so.
Any database feature that the administrator uses needs monitoring to con-
firm if it is working as expected and if the feature requires any tuning ef-
forts. For such situations, the administrator turns to the data dictionary
views for assistance. For the database resource manager several dynamic
performance views exist in the data dictionary to monitor and tune this da-
tabase feature. The views provide information about currently active re-
source plans, historical activations of resource plans, and historical statistics
on resource consumption and CPU waits by both resource consumer group
and session. This section will discuss some of the important views in detail.
The following dynamic views allow the DBA to monitor and manage the re-
source management in the database.
V$RSRC_PLAN
V$RSRC_CONSUMER_GROUP
V$RSRC_SESSION_INFO
V$RSRC_PLAN_HISTORY
V$RSRC_CONS_GROUP_HISTORY
9.4 Privileges
USERNAME INITIAL_RSRC_CONSUMER_GROUP
------------- ------------------------------
SYS SYS_GROUP
SYSTEM SYS_GROUP
SCOTT DEFAULT_CONSUMER_GROUP
http://docs.oracle.com/cd/B28359_01/server.111/b28310/dbrm009.htm#A
DMIN11906
The below script allows us to see the CPU utilized, average running sessions
and average waiting sessions for each of the consumer groups in the data-
base
from v$rsrcmgrmetric_history
;
MOS note 1207483.1 recommends list of patches that the customer must
apply when using the database resource manager.
MOS note 949033.1 describes this issue with a solution. The solution is to disable the usage
of the default resource plan during the weekday window.
http://docs.oracle.com/cd/B28359_01/server.111/b28310/dbrm011.htm#CHDFFJGJ
IBM. the IBM logo, ibm.com, AIX, POWER, POWER6, POWER7, Systems Storage, Power Systems and
System x are trademarks or registered trademarks of International Business Machines Corporation in the
United States, other countries, or both:
UNIX is a registered trademark of The Open Group in the United States and other countries.
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the
United States, other countries, or both.
Linux is a trademark of Linus Torvalds in the United States, other countries, or both.
Other company, product, or service names may be trademarks or service marks of others.
The information provided in this document is distributed AS IS without any warranty, either express or
implied.
The information in this document may include technical inaccuracies or typographical errors.
Information concerning non-IBM products was obtained from a supplier of these products, published an-
nouncement material, or other publicly available sources and does not constitute an endorsement of such
products by IBM. Sources for non-IBM list prices and performance numbers are taken from publicly avail-
able information, including vendor announcements and vendor worldwide homepages. IBM has not tested
these products and cannot confirm the accuracy of performance, capability, or any other claims related to
non-IBM products. Questions on the capability of non-IBM products should be addressed to the supplier
of those products.
All statements regarding IBM future direction and intent are subject to change or withdrawal without no-
tice, and represent goals and objectives only. Contact your local IBM office or IBM authorized reseller for
the full text of the specific Statement of Direction.
Some information addresses anticipated future capabilities. Such information is not intended as a defini-
tive statement of a commitment to specific levels of performance, function or delivery schedules with re-
spect to any future products. Such commitments are only made in IBM product announcements. The in-
formation is presented here to communicate IBM's current investment and development activities as a
good faith effort to help with our customers' future planning.
Performance is based on measurements and projections using standard IBM benchmarks in a controlled
environment. The actual throughput or performance that any user will experience will vary depending
upon considerations such as the amount of multiprogramming in the user's job stream, the I/O configura-
tion, the storage configuration, and the workload processed. Therefore, no assurance can be given that
an individual user will achieve throughput or performance improvements equivalent to the ratios stated
here.
Photographs shown are of engineering prototypes. Changes may be incorporated in production models.