You are on page 1of 17

Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 1 de 17

Infrastructure
OFFERING EXPERTISE TRAINING NEWSROOM ABOUT DBI BLOG

CONTACT

Oracle 11g Instance Caging – limit database


 CPU
consumption
By Jérôme Witt March 7, 2011 Application integration & Middleware 10 Comments

As you certainly already have heard, Oracle 11g comes with a new feature called “Instance caging”.
This feature allows Oracle DBAs to easily manage Oracle Instance CPU consumption. How does it
work? Quite easily … see below.

First, two simple scenarios for your understanding:

Scenario 1: Server over-provisioning, 4 Databases sharing a 4 CPU-machine.

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 2 de 17

Infrastructure
OFFERING EXPERTISE TRAINING NEWSROOM ABOUT DBI BLOG

CONTACT

With heavy load on all databases, each one of them would equally consume:
3/(3+3+3+3) = 0.25 => 25%.

If only two databases are active, then one instance will consume:
3/(3+3) =0.5 => 50% of the CPU.
Per default, the init parameter CPU_COUNT is set to {Max. Number of CPU -1}.

Scenario 2: Now, assume you have a server with 16 CPUs and 4 databases running on it. Several of
these databases are not critical. But one, the production line, is!

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 3 de 17

Infrastructure
OFFERING EXPERTISE TRAINING NEWSROOM ABOUT DBI BLOG

CONTACT

Using Oracle 11g Instance caging, you are able to manage the maximal amount of CPU consumed by
each oracle instances.
Instance A could consume up to 62.5% (10/16=0.625) of CPU-capacity.
To enable instance caging, create an Oracle resource plan, active the plan and set the right
CPU_COUNT amount.

Step 1: enable Resource Manager


The first step consists in creating a simple resource manager plan.
BEGIN

— Pending area mandatory for each Resource Manager action

DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();

–create resource consumer groups

DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP (

CONSUMER_GROUP => ‘OLTP_CG’,

COMMENT => ‘OLTP high priority’

);

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 4 de 17

Infrastructure
OFFERING EXPERTISE TRAINING NEWSROOM ABOUT DBI BLOG

CONTACT

CONSUMER_GROUP => ‘LOW_CG’,

COMMENT => ‘other eclectic applications’

);

–create a resource plan

DBMS_RESOURCE_MANAGER.CREATE_PLAN(

PLAN => ‘ACTIVITY_PLAN’,

COMMENT => ‘Normal activity plan’,

MGMT_MTH=> ‘EMPHASIS’);

–validate & submit the pending area

DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();

DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();

END;

To enable the resource plan, set the resource_manager_plan parameters as follows:

SQL> ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = ‘ACTIVITY_PLAN';

Setting the resource manager plan, activates the resource manager.

Step 2: Set cpu_count

SQL> ALTER SYSTEM SET CPU_COUNT = 16;

>To burn all available CPU (dynamically of course :), we will start 16 parallel sessions running the
following code:
DECLARE

L_n NUMBER;

BEGIN

WHILE (TRUE)

LOOP

L_ n:= dbms_random.random();

END LOOP;

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 5 de 17

END;
Infrastructure
OFFERING EXPERTISE TRAINING NEWSROOM ABOUT DBI BLOG

CONTACT

oracle@sbsubs177:bscc177 > prstat -t -s cpu -n 5

NPROC USERNAME SWAP RSS MEMORY TIME CPU

72 oracle 1398M 1501M 4.6% 1:12:25 96%

1 smmsp 1512K 4416K 0.0% 0:00:18 0.0%

6 daemon 6728K 6424K 0.0% 0:00:03 0.0%

23 root 106M 57M 0.2% 0:38:43 0.0%

Total: 102 processes, 274 lwps, load averages: 17.11, 10.56, 5.02

Dividing CPU to 50 % of the amount of CPU’s

SQL> ALTER SYSTEM SET CPU_COUNT = 8;

oracle@sbsubs177:bscc177 > prstat -t -s cpu -n 5

NPROC USERNAME SWAP RSS MEMORY TIME CPU

72 oracle 1398M 1501M 4.6% 1:36:20 51%

1 smmsp 1512K 4184K 0.0% 0:00:18 0.0%

6 daemon 6728K 6424K 0.0% 0:00:03 0.0%

23 root 106M 57M 0.2% 0:38:43 0.0%

Total: 102 processes, 275 lwps, load averages: 11.14, 10.97, 5.97

Dividing CPU to 25 % of the amount of CPU’s

SQL> ALTER SYSTEM SET CPU_COUNT = 4;

oracle@sbsubs177:bscc177 > prstat -t -s cpu -n 5

NPROC USERNAME SWAP RSS MEMORY TIME CPU

72 oracle 1398M 1503M 4.6% 1:47:28 26%

1 smmsp 1512K 4184K 0.0% 0:00:18 0.0%

6 daemon 6728K 6424K 0.0% 0:00:03 0.0%

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 6 de 17

23 root 106M 57M 0.2% 0:38:43 0.0%


Infrastructure
OFFERING ? EXPERTISE ? TRAINING ? NEWSROOM ? ABOUT DBI ? BLOG ?

CONTACT

Let’s shortly summarize all steps to create an overall Resource Manager plan:

1. Create groups : (see above) – consumer groups can be viewed by querying


DBA_RSRC_CONSUMER_GROUP

OLTP_CG : OLTP consumer group, unlimited resource access


REPORTING_CG : Our reporting application which should not burn all our available CPU-power
LOW_CG : our low priority group , maximum CPU-usage 25%

2. Create Resource Manager plan (see above)

3. Create Resource Manager directives, plan directives are switch conditions.

if a User/Session from consumer group REPORTING_CG consumes 50% CPU (parameter MGMT_P1)
during 10 CPU seconds (paramter SWITCH_TIME), he will be automatically switched to the
LOW_CG consumer group
LOW_CG is a plan directive that limits CPU usage to 25% (parameter MAX_UTILIZATION_LIMIT)

P. S. : If you try looking up the parameter MAX_UTILIZATION LIMIT in the Oracle 11gR2 Administration
guide, it’s a gift, it is only m entioned in the exam ple pages

-– create plan directives


BEGIN
DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (
PLAN => ‘ACTIVITY_PLAN’,
GROUP_OR_SUBPLAN => ‘REPORTING_CG’,
COMMENT => ‘switch REPORTING group to a lower priority consumer
group’,
MGMT_P1 => 50,
SWITCH_GROUP => ‘LOW_CG’,

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 7 de 17

Infrastructure
OFFERING . EXPERTISE . TRAINING . NEWSROOM . ABOUT DBI . BLOG .

CONTACT

COMMENT => ‘sets the max CPU used for LOW_GC’,


MAX_UTILIZATION_LIMIT => 25
);
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (
PLAN => ‘ACTIVITY_PLAN’,
GROUP_OR_SUBPLAN => ‘OTHER_GROUPS’,
COMMENT => ‘This one is required’,
MGMT_P1 => 10
);
DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
END;
/

4. Set the initial resource group for database schemas, “query-able” from
DBA_USERS.INITIAL_RSRC_CONSUMER_GROUP:

BEGIN

DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING

(DBMS_RESOURCE_MANAGER.ORACLE_USER,’REPORT_USER’,’REPORTING_CG’);

DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING

(DBMS_RESOURCE_MANAGER.ORACLE_USER,’OTHER_USER’,’LOW_CG’);

DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();

DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();

END;

SQL> select username,INITIAL_RSRC_CONSUMER_GROUP from dba_users where username like ‘%_USER';

USERNAME INITIAL_RSRC_CONSUMER_GROUP

—————– ——————————

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 8 de 17

Infrastructure
OFFERING 8 EXPERTISE 8 TRAINING 8 NEWSROOM 8 ABOUT DBI 8 BLOG 8

CONTACT

burns all available CPU (CPU_COUNT set to 16).

The V$SESSION.RESOURCE_CONSUMER_GROUP view shows the current consumer group:

SQL> select username,RESOURCE_CONSUMER_GROUP,sid,serial# from v$session where username is not null

and schemaname!=’SYS’ and rownum=1 ;

USERNAME RESOURCE_CONSUMER_GROUP SID SERIAL#

————- ———————— —– ——-

REPORT_USER OTHER_GROUPS 146 1

Because our resource plan directives are not accurate, the REPORTING_CG consumer group switches
automatically to OTHERS_GROUPS and consumes all available CPU. The Resource manager plans should be
as structured as possible to avoid switching connected session directly to the default OTHER_GROUPS
consumer group.

The procedure…

DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_SESS
(‘v$session.sid’,’v$session.serial’#,’REPORTING_GC’)

…can be used to switch back all users sessions to the resource consumer group REPORTING_CG.

SQL> select username,RESOURCE_CONSUMER_GROUP,sid,serial# from v$session where username is not null

and schemaname!=’SYS’ and rownum=1 ;

USERNAME RESOURCE_CONSUMER_GROUP SID SERIAL#

————- ———————— —– ——-

REPORT_USER LOW_CG 146 1

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 9 de 17

Infrastructure
OFFERING 3 EXPERTISE 3 TRAINING 3 NEWSROOM 3 ABOUT DBI 3 BLOG 3

CONTACT

NPROC USERNAME SWAP RSS MEMORY TIME CPU


113 oracle 1598M 1648M 5.0% 0:30:12 23%
1 smmsp 1512K 3704K 0.0% 0:00:18 0.0%
6 daemon 6728K 5152K 0.0% 0:00:03 0.0%
22 root 104M 54M 0.2% 0:39:12 0.0%
Total: 142 processes, 316 lwps, load averages: 6.25, 5.11, 4.37

I hope you enjoyed reading this post. We have just scratched the surface of the Resource Manager, which is
able to…

manage the degree of parallelism (number of parallel execution servers)


manage active session (nulber of concurrent active sessions)
limit UNDO usage
limite execution time (maximum execution time allowed for an operation)
and so on … all features are well described in the Oracle 11gR2 Database Administration
documentation

By the way, Instance Caging cannot reduce the number of licensed CPUs!

10 Comments

mubeen says: Reply to mubeen


December 13, 2011 at 5 h 51 min

Thanks for posting in details. I have a quick question.

Let’s say my server has 16 CPU. I like to have 2 databases on that machine,
production & test.

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 10 de 17

in Production database:
Infrastructure
OFFERING 3 EXPERTISE 3 TRAINING 3 NEWSROOM 3 ABOUT DBI 3 BLOG 3

CONTACT

Is it enough ? thanks

Piotr Flakowski says: Reply to Piotr


July 8, 2012 at 15 h 04 min

Hi, and when my problem is that I have application running on the application
server/java based, and the one oracle instance is using 100% of the 4-core
processor running w2k8 64 bit os?

Jérôme Witt says: Reply to Jérôme


July 11, 2012 at 7 h 11 min

Hi Piotr,

Well, this should also be true for MS w2k8 Follow the instructions.
Pay attention to the performance, you may dramatically increase the response
time by reducing the CPU power…

Regards

Perry Kahlon says: Reply to Perry


April 2, 2014 at 19 h 30 min

Hi Jerome.. I have a question. Suppose if we have 8 CPUs on server and we


assign 2 CPUs to a database. Now, will other processes on server be able to
use these 2 CPUs or will these be dedicated to database only? FYI, we are

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 11 de 17

Infrastructure
OFFERING EXPERTISE TRAINING NEWSROOM ABOUT DBI BLOG

CONTACT

Jérôme Witt says: Reply to Jérôme


April 22, 2014 at 14 h 21 min

Hi Perry,
The spare CPU power is of course available for other processes ( i.e non-
caged database)! By setting the CPU_COUNT you only tell to the Oracle
RDBMS kernel the number of CPUs available for Oracle Database to use.

Have fun with your ODA


Regards,

Ranjit Rakwal says: Reply to Ranjit


October 13, 2014 at 21 h 16 min

Hi Jerome,
One of my ODA has 12 databases and 16 cores available.
If I enable instance caging on 2 databases with 4 cpu’s each and leave rest of
10 database with out instance caging.
What will happen if 95% of the 16 CPU is being used by non caged databases
and os processes. Suppose the two databases for which instance caging is
enabled need 40% of the CPU and only 5% is available.

Regards

Ranjit Rakwal

Siva says: Reply to Siva


January 9, 2015 at 8 h 27 min

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 12 de 17

Infrastructure
OFFERING EXPERTISE TRAINING NEWSROOM ABOUT DBI BLOG

CONTACT

Regards,
Siva

Siva says: Reply to Siva


January 9, 2015 at 8 h 29 min

and one more thing I am a Server Administrator and I don’t know about dba
program.

Randy says: Reply to Randy


February 4, 2015 at 14 h 29 min

Hi Jerome,
I am confused on 2 points
1. after you ran:
DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING
(DBMS_RESOURCE_MANAGER.ORACLE_USER,’REPORT_USER’,’REPORTING_CG’);
Unless its because you did not grant switch group rights, why is report_user
starting his session in other_groups?

2. Why are the directives not accurate or structured?


How could they be more structured?

Thanks
Randy

Jérôme Witt says: Reply to Jérôme

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 13 de 17

December 14, 2011 at 18 h 06 min


Infrastructure
OFFERING ! EXPERTISE ! TRAINING ! NEWSROOM ! ABOUT DBI ! BLOG !

CONTACT

Reminder : Instance caging works also increasing the CPU_COUNT (on the fly).

You will have to test each setting

Regards

Leave a Reply
Name *

Email *

Website

5− = one

SUBMIT COMMENT

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 14 de 17

Infrastructure
OFFERING % EXPERTISE % TRAINING % NEWSROOM % ABOUT DBI % BLOG %

CONTACT

CATEGORIES

Application integration & Middleware

Business Intelligence

Database Administration & Monitoring

Database management

Development & Performance

Entreprise content management

Hardware & Storage

Operation systems

Technology Survey

RECENT ARTICLES

Windows Containers: Migration

12c Multitenant: PDB spfile parameters for standby database

The privileges to connect to a container

Windows Container: installation and utilization

SQL Server 2016 : nonclustered columnstore index and aggregate pushdown

TAG CLOUD

AlwaysOn Analysis Services Availability Groups Cloud Cloud Computing Cluster Database

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 15 de 17

DB
Infrastructure
OFFERING 3 EXPERTISE 3 TRAINING 3 NEWSROOM 3 ABOUT DBI 3 A BLOG 3

In-Memory Installation Integration Services Java

CONTACT
Migration Monitoring Multitenant Database Optimizer

X
Oracle Oracle 10g To 8i Oracle 11g Oracle 12c
Oracle Enterprise Manager Oracle Enterprise Manager Cloud 12c Oracle OpenWorld Oracle WebLogic

Performance PostgreSQL PowerShell Reporting Services Security SQ SQL Server


L
SQL Server 2008

SQL Server 2012 SQL Server 2014 SQL Server 2016 Storage Troubleshooting UKOU
G

BLOG ROLL

Florian Haas' blog

Dirk Nachbar's blog on Oracle Fusion Middleware & Application Server

Oracle Scratchpad - Jonathan Lewis' blog

Martin Bach's blog

Striving for optimal performance - Chris Antognini's blog

The Tom Kyte Blog (Ask Tom)

Blog of Adar-Consult

Alex Gorbachev's blog

Marcus Mönnig's Oracle & Mumbai Blog

Jérôme Witt

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 16 de 17

Senior Consultant
Infrastructure
OFFERING EXPERTISE TRAINING NEWSROOM ABOUT DBI BLOG

CONTACT

Name

Company

E-Mail

Phone Number

Message 

SEND

EX P E R T I S E I N D A T A B A S E & M I D D L E W A R E

Oracle database expertise (12c, 11g, 10g)


SQL Server expertise (2014, 2012, 2008)
SharePoint expertise (2013, 2010, 2007)
EMC Documentum expertise
Linux expertise (Oracle Linux, Red Hat)

TRAININGS IN DATABASE & MIDDLEWARE

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016
Oracle 11g Instance Caging - limit database CPU consumption - Blog dbi services Página 17 de 17

Microsoft
Infrastructure
OFFERING EXPERTISE TRAINING NEWSROOM ABOUT DBI BLOG

CONTACT

USEFUL INFORMATION

News & Events


Jobs openings
Offices
Blog of dbi services
Imprint

© 2015 dbi services sa

http://blog.dbi-services.com/oracle-11g-instance-caging-limit-database-cpu-consumpt... 29/03/2016

You might also like